dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone

Blame SOURCES/0042-IPA-AD-SDAP-BE-Generate-refresh-callbacks-with-a-mac.patch

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