|
|
8d3578 |
From 441e05790e5efec4928af3d0f93c4eba72d979ae Mon Sep 17 00:00:00 2001
|
|
|
8d3578 |
From: Jakub Hrozek <jhrozek@redhat.com>
|
|
|
8d3578 |
Date: Tue, 25 Jun 2019 15:01:15 +0200
|
|
|
8d3578 |
Subject: [PATCH 61/64] IPA/AD/SDAP/BE: Generate refresh callbacks with a macro
|
|
|
8d3578 |
|
|
|
8d3578 |
Related: https://pagure.io/SSSD/sssd/issue/4012
|
|
|
8d3578 |
|
|
|
8d3578 |
The per-object type refresh functions are more or less boilerplate code.
|
|
|
8d3578 |
Even though macro-generated code should be used very rarely, here the
|
|
|
8d3578 |
generated code does not contain any logic at all so it makese sense to
|
|
|
8d3578 |
generate it with macros.
|
|
|
8d3578 |
|
|
|
8d3578 |
Reviewed-by: Sumit Bose <sbose@redhat.com>
|
|
|
8d3578 |
(cherry picked from commit 60c876aefe2efc5a67929f9b3890b627cea7c549)
|
|
|
8d3578 |
|
|
|
8d3578 |
Reviewed-by: Sumit Bose <sbose@redhat.com>
|
|
|
8d3578 |
---
|
|
|
8d3578 |
src/providers/ad/ad_refresh.c | 71 ++-----------------------------
|
|
|
8d3578 |
src/providers/be_refresh.h | 20 +++++++++
|
|
|
8d3578 |
src/providers/ipa/ipa_refresh.c | 71 ++-----------------------------
|
|
|
8d3578 |
src/providers/ldap/sdap_refresh.c | 71 ++-----------------------------
|
|
|
8d3578 |
4 files changed, 32 insertions(+), 201 deletions(-)
|
|
|
8d3578 |
|
|
|
8d3578 |
diff --git a/src/providers/ad/ad_refresh.c b/src/providers/ad/ad_refresh.c
|
|
|
8d3578 |
index ed51b305a..0c2ebce5e 100644
|
|
|
8d3578 |
--- a/src/providers/ad/ad_refresh.c
|
|
|
8d3578 |
+++ b/src/providers/ad/ad_refresh.c
|
|
|
8d3578 |
@@ -188,73 +188,10 @@ static errno_t ad_refresh_recv(struct tevent_req *req)
|
|
|
8d3578 |
return EOK;
|
|
|
8d3578 |
}
|
|
|
8d3578 |
|
|
|
8d3578 |
-static struct tevent_req *
|
|
|
8d3578 |
-ad_refresh_initgroups_send(TALLOC_CTX *mem_ctx,
|
|
|
8d3578 |
- struct tevent_context *ev,
|
|
|
8d3578 |
- struct be_ctx *be_ctx,
|
|
|
8d3578 |
- struct sss_domain_info *domain,
|
|
|
8d3578 |
- char **names,
|
|
|
8d3578 |
- void *pvt)
|
|
|
8d3578 |
-{
|
|
|
8d3578 |
- return ad_refresh_send(mem_ctx, ev, be_ctx, domain,
|
|
|
8d3578 |
- BE_REQ_INITGROUPS, names, pvt);
|
|
|
8d3578 |
-}
|
|
|
8d3578 |
-
|
|
|
8d3578 |
-static errno_t ad_refresh_initgroups_recv(struct tevent_req *req)
|
|
|
8d3578 |
-{
|
|
|
8d3578 |
- return ad_refresh_recv(req);
|
|
|
8d3578 |
-}
|
|
|
8d3578 |
-
|
|
|
8d3578 |
-static struct tevent_req *
|
|
|
8d3578 |
-ad_refresh_users_send(TALLOC_CTX *mem_ctx,
|
|
|
8d3578 |
- struct tevent_context *ev,
|
|
|
8d3578 |
- struct be_ctx *be_ctx,
|
|
|
8d3578 |
- struct sss_domain_info *domain,
|
|
|
8d3578 |
- char **names,
|
|
|
8d3578 |
- void *pvt)
|
|
|
8d3578 |
-{
|
|
|
8d3578 |
- return ad_refresh_send(mem_ctx, ev, be_ctx, domain,
|
|
|
8d3578 |
- BE_REQ_USER, names, pvt);
|
|
|
8d3578 |
-}
|
|
|
8d3578 |
-
|
|
|
8d3578 |
-static errno_t ad_refresh_users_recv(struct tevent_req *req)
|
|
|
8d3578 |
-{
|
|
|
8d3578 |
- return ad_refresh_recv(req);
|
|
|
8d3578 |
-}
|
|
|
8d3578 |
-
|
|
|
8d3578 |
-static struct tevent_req *
|
|
|
8d3578 |
-ad_refresh_groups_send(TALLOC_CTX *mem_ctx,
|
|
|
8d3578 |
- struct tevent_context *ev,
|
|
|
8d3578 |
- struct be_ctx *be_ctx,
|
|
|
8d3578 |
- struct sss_domain_info *domain,
|
|
|
8d3578 |
- char **names,
|
|
|
8d3578 |
- void *pvt)
|
|
|
8d3578 |
-{
|
|
|
8d3578 |
- return ad_refresh_send(mem_ctx, ev, be_ctx, domain,
|
|
|
8d3578 |
- BE_REQ_GROUP, names, pvt);
|
|
|
8d3578 |
-}
|
|
|
8d3578 |
-
|
|
|
8d3578 |
-static errno_t ad_refresh_groups_recv(struct tevent_req *req)
|
|
|
8d3578 |
-{
|
|
|
8d3578 |
- return ad_refresh_recv(req);
|
|
|
8d3578 |
-}
|
|
|
8d3578 |
-
|
|
|
8d3578 |
-static struct tevent_req *
|
|
|
8d3578 |
-ad_refresh_netgroups_send(TALLOC_CTX *mem_ctx,
|
|
|
8d3578 |
- struct tevent_context *ev,
|
|
|
8d3578 |
- struct be_ctx *be_ctx,
|
|
|
8d3578 |
- struct sss_domain_info *domain,
|
|
|
8d3578 |
- char **names,
|
|
|
8d3578 |
- void *pvt)
|
|
|
8d3578 |
-{
|
|
|
8d3578 |
- return ad_refresh_send(mem_ctx, ev, be_ctx, domain,
|
|
|
8d3578 |
- BE_REQ_NETGROUP, names, pvt);
|
|
|
8d3578 |
-}
|
|
|
8d3578 |
-
|
|
|
8d3578 |
-static errno_t ad_refresh_netgroups_recv(struct tevent_req *req)
|
|
|
8d3578 |
-{
|
|
|
8d3578 |
- return ad_refresh_recv(req);
|
|
|
8d3578 |
-}
|
|
|
8d3578 |
+REFRESH_SEND_RECV_FNS(ad_refresh_initgroups, ad_refresh, BE_REQ_INITGROUPS);
|
|
|
8d3578 |
+REFRESH_SEND_RECV_FNS(ad_refresh_users, ad_refresh, BE_REQ_USER);
|
|
|
8d3578 |
+REFRESH_SEND_RECV_FNS(ad_refresh_groups, ad_refresh, BE_REQ_GROUP);
|
|
|
8d3578 |
+REFRESH_SEND_RECV_FNS(ad_refresh_netgroups, ad_refresh, BE_REQ_NETGROUP);
|
|
|
8d3578 |
|
|
|
8d3578 |
errno_t ad_refresh_init(struct be_ctx *be_ctx,
|
|
|
8d3578 |
struct ad_id_ctx *id_ctx)
|
|
|
8d3578 |
diff --git a/src/providers/be_refresh.h b/src/providers/be_refresh.h
|
|
|
8d3578 |
index 42d73d938..68be40118 100644
|
|
|
8d3578 |
--- a/src/providers/be_refresh.h
|
|
|
8d3578 |
+++ b/src/providers/be_refresh.h
|
|
|
8d3578 |
@@ -29,6 +29,26 @@
|
|
|
8d3578 |
/* solve circular dependency */
|
|
|
8d3578 |
struct be_ctx;
|
|
|
8d3578 |
|
|
|
8d3578 |
+#define REFRESH_SEND_RECV_FNS(outer_base, inner_base, req_type) \
|
|
|
8d3578 |
+ \
|
|
|
8d3578 |
+static struct tevent_req * \
|
|
|
8d3578 |
+outer_base ##_send(TALLOC_CTX *mem_ctx, \
|
|
|
8d3578 |
+ struct tevent_context *ev, \
|
|
|
8d3578 |
+ struct be_ctx *be_ctx, \
|
|
|
8d3578 |
+ struct sss_domain_info *domain, \
|
|
|
8d3578 |
+ char **names, \
|
|
|
8d3578 |
+ void *pvt) \
|
|
|
8d3578 |
+{ \
|
|
|
8d3578 |
+ return inner_base ##_send(mem_ctx, ev, \
|
|
|
8d3578 |
+ be_ctx, domain, \
|
|
|
8d3578 |
+ req_type, names, pvt); \
|
|
|
8d3578 |
+} \
|
|
|
8d3578 |
+ \
|
|
|
8d3578 |
+static errno_t outer_base ##_recv(struct tevent_req *req) \
|
|
|
8d3578 |
+{ \
|
|
|
8d3578 |
+ return inner_base ##_recv(req); \
|
|
|
8d3578 |
+} \
|
|
|
8d3578 |
+
|
|
|
8d3578 |
/**
|
|
|
8d3578 |
* name_list contains SYSDB_NAME of all expired records.
|
|
|
8d3578 |
*/
|
|
|
8d3578 |
diff --git a/src/providers/ipa/ipa_refresh.c b/src/providers/ipa/ipa_refresh.c
|
|
|
8d3578 |
index 7b05cf9e4..13c38dff9 100644
|
|
|
8d3578 |
--- a/src/providers/ipa/ipa_refresh.c
|
|
|
8d3578 |
+++ b/src/providers/ipa/ipa_refresh.c
|
|
|
8d3578 |
@@ -168,73 +168,10 @@ static errno_t ipa_refresh_recv(struct tevent_req *req)
|
|
|
8d3578 |
return EOK;
|
|
|
8d3578 |
}
|
|
|
8d3578 |
|
|
|
8d3578 |
-static struct tevent_req *
|
|
|
8d3578 |
-ipa_refresh_initgroups_send(TALLOC_CTX *mem_ctx,
|
|
|
8d3578 |
- struct tevent_context *ev,
|
|
|
8d3578 |
- struct be_ctx *be_ctx,
|
|
|
8d3578 |
- struct sss_domain_info *domain,
|
|
|
8d3578 |
- char **names,
|
|
|
8d3578 |
- void *pvt)
|
|
|
8d3578 |
-{
|
|
|
8d3578 |
- return ipa_refresh_send(mem_ctx, ev, be_ctx, domain,
|
|
|
8d3578 |
- BE_REQ_INITGROUPS, names, pvt);
|
|
|
8d3578 |
-}
|
|
|
8d3578 |
-
|
|
|
8d3578 |
-static errno_t ipa_refresh_initgroups_recv(struct tevent_req *req)
|
|
|
8d3578 |
-{
|
|
|
8d3578 |
- return ipa_refresh_recv(req);
|
|
|
8d3578 |
-}
|
|
|
8d3578 |
-
|
|
|
8d3578 |
-static struct tevent_req *
|
|
|
8d3578 |
-ipa_refresh_users_send(TALLOC_CTX *mem_ctx,
|
|
|
8d3578 |
- struct tevent_context *ev,
|
|
|
8d3578 |
- struct be_ctx *be_ctx,
|
|
|
8d3578 |
- struct sss_domain_info *domain,
|
|
|
8d3578 |
- char **names,
|
|
|
8d3578 |
- void *pvt)
|
|
|
8d3578 |
-{
|
|
|
8d3578 |
- return ipa_refresh_send(mem_ctx, ev, be_ctx, domain,
|
|
|
8d3578 |
- BE_REQ_USER, names, pvt);
|
|
|
8d3578 |
-}
|
|
|
8d3578 |
-
|
|
|
8d3578 |
-static errno_t ipa_refresh_users_recv(struct tevent_req *req)
|
|
|
8d3578 |
-{
|
|
|
8d3578 |
- return ipa_refresh_recv(req);
|
|
|
8d3578 |
-}
|
|
|
8d3578 |
-
|
|
|
8d3578 |
-static struct tevent_req *
|
|
|
8d3578 |
-ipa_refresh_groups_send(TALLOC_CTX *mem_ctx,
|
|
|
8d3578 |
- struct tevent_context *ev,
|
|
|
8d3578 |
- struct be_ctx *be_ctx,
|
|
|
8d3578 |
- struct sss_domain_info *domain,
|
|
|
8d3578 |
- char **names,
|
|
|
8d3578 |
- void *pvt)
|
|
|
8d3578 |
-{
|
|
|
8d3578 |
- return ipa_refresh_send(mem_ctx, ev, be_ctx, domain,
|
|
|
8d3578 |
- BE_REQ_GROUP, names, pvt);
|
|
|
8d3578 |
-}
|
|
|
8d3578 |
-
|
|
|
8d3578 |
-static errno_t ipa_refresh_groups_recv(struct tevent_req *req)
|
|
|
8d3578 |
-{
|
|
|
8d3578 |
- return ipa_refresh_recv(req);
|
|
|
8d3578 |
-}
|
|
|
8d3578 |
-
|
|
|
8d3578 |
-static struct tevent_req *
|
|
|
8d3578 |
-ipa_refresh_netgroups_send(TALLOC_CTX *mem_ctx,
|
|
|
8d3578 |
- struct tevent_context *ev,
|
|
|
8d3578 |
- struct be_ctx *be_ctx,
|
|
|
8d3578 |
- struct sss_domain_info *domain,
|
|
|
8d3578 |
- char **names,
|
|
|
8d3578 |
- void *pvt)
|
|
|
8d3578 |
-{
|
|
|
8d3578 |
- return ipa_refresh_send(mem_ctx, ev, be_ctx, domain,
|
|
|
8d3578 |
- BE_REQ_NETGROUP, names, pvt);
|
|
|
8d3578 |
-}
|
|
|
8d3578 |
-
|
|
|
8d3578 |
-static errno_t ipa_refresh_netgroups_recv(struct tevent_req *req)
|
|
|
8d3578 |
-{
|
|
|
8d3578 |
- return ipa_refresh_recv(req);
|
|
|
8d3578 |
-}
|
|
|
8d3578 |
+REFRESH_SEND_RECV_FNS(ipa_refresh_initgroups, ipa_refresh, BE_REQ_INITGROUPS);
|
|
|
8d3578 |
+REFRESH_SEND_RECV_FNS(ipa_refresh_users, ipa_refresh, BE_REQ_USER);
|
|
|
8d3578 |
+REFRESH_SEND_RECV_FNS(ipa_refresh_groups, ipa_refresh, BE_REQ_GROUP);
|
|
|
8d3578 |
+REFRESH_SEND_RECV_FNS(ipa_refresh_netgroups, ipa_refresh, BE_REQ_NETGROUP);
|
|
|
8d3578 |
|
|
|
8d3578 |
errno_t ipa_refresh_init(struct be_ctx *be_ctx,
|
|
|
8d3578 |
struct ipa_id_ctx *id_ctx)
|
|
|
8d3578 |
diff --git a/src/providers/ldap/sdap_refresh.c b/src/providers/ldap/sdap_refresh.c
|
|
|
8d3578 |
index ff4d2116d..4e464b2f6 100644
|
|
|
8d3578 |
--- a/src/providers/ldap/sdap_refresh.c
|
|
|
8d3578 |
+++ b/src/providers/ldap/sdap_refresh.c
|
|
|
8d3578 |
@@ -186,73 +186,10 @@ static errno_t sdap_refresh_recv(struct tevent_req *req)
|
|
|
8d3578 |
return EOK;
|
|
|
8d3578 |
}
|
|
|
8d3578 |
|
|
|
8d3578 |
-static struct tevent_req *
|
|
|
8d3578 |
-sdap_refresh_initgroups_send(TALLOC_CTX *mem_ctx,
|
|
|
8d3578 |
- struct tevent_context *ev,
|
|
|
8d3578 |
- struct be_ctx *be_ctx,
|
|
|
8d3578 |
- struct sss_domain_info *domain,
|
|
|
8d3578 |
- char **names,
|
|
|
8d3578 |
- void *pvt)
|
|
|
8d3578 |
-{
|
|
|
8d3578 |
- return sdap_refresh_send(mem_ctx, ev, be_ctx, domain,
|
|
|
8d3578 |
- BE_REQ_INITGROUPS, names, pvt);
|
|
|
8d3578 |
-}
|
|
|
8d3578 |
-
|
|
|
8d3578 |
-static errno_t sdap_refresh_initgroups_recv(struct tevent_req *req)
|
|
|
8d3578 |
-{
|
|
|
8d3578 |
- return sdap_refresh_recv(req);
|
|
|
8d3578 |
-}
|
|
|
8d3578 |
-
|
|
|
8d3578 |
-static struct tevent_req *
|
|
|
8d3578 |
-sdap_refresh_users_send(TALLOC_CTX *mem_ctx,
|
|
|
8d3578 |
- struct tevent_context *ev,
|
|
|
8d3578 |
- struct be_ctx *be_ctx,
|
|
|
8d3578 |
- struct sss_domain_info *domain,
|
|
|
8d3578 |
- char **names,
|
|
|
8d3578 |
- void *pvt)
|
|
|
8d3578 |
-{
|
|
|
8d3578 |
- return sdap_refresh_send(mem_ctx, ev, be_ctx, domain,
|
|
|
8d3578 |
- BE_REQ_USER, names, pvt);
|
|
|
8d3578 |
-}
|
|
|
8d3578 |
-
|
|
|
8d3578 |
-static errno_t sdap_refresh_users_recv(struct tevent_req *req)
|
|
|
8d3578 |
-{
|
|
|
8d3578 |
- return sdap_refresh_recv(req);
|
|
|
8d3578 |
-}
|
|
|
8d3578 |
-
|
|
|
8d3578 |
-static struct tevent_req *
|
|
|
8d3578 |
-sdap_refresh_groups_send(TALLOC_CTX *mem_ctx,
|
|
|
8d3578 |
- struct tevent_context *ev,
|
|
|
8d3578 |
- struct be_ctx *be_ctx,
|
|
|
8d3578 |
- struct sss_domain_info *domain,
|
|
|
8d3578 |
- char **names,
|
|
|
8d3578 |
- void *pvt)
|
|
|
8d3578 |
-{
|
|
|
8d3578 |
- return sdap_refresh_send(mem_ctx, ev, be_ctx, domain,
|
|
|
8d3578 |
- BE_REQ_GROUP, names, pvt);
|
|
|
8d3578 |
-}
|
|
|
8d3578 |
-
|
|
|
8d3578 |
-static errno_t sdap_refresh_groups_recv(struct tevent_req *req)
|
|
|
8d3578 |
-{
|
|
|
8d3578 |
- return sdap_refresh_recv(req);
|
|
|
8d3578 |
-}
|
|
|
8d3578 |
-
|
|
|
8d3578 |
-static struct tevent_req *
|
|
|
8d3578 |
-sdap_refresh_netgroups_send(TALLOC_CTX *mem_ctx,
|
|
|
8d3578 |
- struct tevent_context *ev,
|
|
|
8d3578 |
- struct be_ctx *be_ctx,
|
|
|
8d3578 |
- struct sss_domain_info *domain,
|
|
|
8d3578 |
- char **names,
|
|
|
8d3578 |
- void *pvt)
|
|
|
8d3578 |
-{
|
|
|
8d3578 |
- return sdap_refresh_send(mem_ctx, ev, be_ctx, domain,
|
|
|
8d3578 |
- BE_REQ_NETGROUP, names, pvt);
|
|
|
8d3578 |
-}
|
|
|
8d3578 |
-
|
|
|
8d3578 |
-static errno_t sdap_refresh_netgroups_recv(struct tevent_req *req)
|
|
|
8d3578 |
-{
|
|
|
8d3578 |
- return sdap_refresh_recv(req);
|
|
|
8d3578 |
-}
|
|
|
8d3578 |
+REFRESH_SEND_RECV_FNS(sdap_refresh_initgroups, sdap_refresh, BE_REQ_INITGROUPS);
|
|
|
8d3578 |
+REFRESH_SEND_RECV_FNS(sdap_refresh_users, sdap_refresh, BE_REQ_USER);
|
|
|
8d3578 |
+REFRESH_SEND_RECV_FNS(sdap_refresh_groups, sdap_refresh, BE_REQ_GROUP);
|
|
|
8d3578 |
+REFRESH_SEND_RECV_FNS(sdap_refresh_netgroups, sdap_refresh, BE_REQ_NETGROUP);
|
|
|
8d3578 |
|
|
|
8d3578 |
errno_t sdap_refresh_init(struct be_ctx *be_ctx,
|
|
|
8d3578 |
struct sdap_id_ctx *id_ctx)
|
|
|
8d3578 |
--
|
|
|
8d3578 |
2.20.1
|
|
|
8d3578 |
|