dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone

Blame SOURCES/0030-BE-LDAP-Call-be_refresh_ctx_init-in-the-provider-lib.patch

d6181b
From 4f32364e1a516cdcd311d369142e93d90a48e11c Mon Sep 17 00:00:00 2001
d6181b
From: Jakub Hrozek <jhrozek@redhat.com>
d6181b
Date: Mon, 20 May 2019 22:42:47 +0200
d6181b
Subject: [PATCH 30/48] BE/LDAP: Call be_refresh_ctx_init() in the provider
d6181b
 libraries, not in back end
d6181b
d6181b
Since later patches will pass different parameters to
d6181b
be_refresh_ctx_init(), let's call the init function in the provider
d6181b
libraries not directly in the back end.
d6181b
d6181b
Related:
d6181b
https://pagure.io/SSSD/sssd/issue/4012
d6181b
d6181b
Reviewed-by: Sumit Bose <sbose@redhat.com>
d6181b
---
d6181b
 src/providers/ad/ad_init.c        |  2 +-
d6181b
 src/providers/data_provider_be.c  |  8 --------
d6181b
 src/providers/ipa/ipa_init.c      |  2 +-
d6181b
 src/providers/ldap/ldap_common.h  |  2 +-
d6181b
 src/providers/ldap/ldap_init.c    |  2 +-
d6181b
 src/providers/ldap/sdap_refresh.c | 17 +++++++++++++----
d6181b
 6 files changed, 17 insertions(+), 16 deletions(-)
d6181b
d6181b
diff --git a/src/providers/ad/ad_init.c b/src/providers/ad/ad_init.c
d6181b
index 423071dcd..b8ebaea2f 100644
d6181b
--- a/src/providers/ad/ad_init.c
d6181b
+++ b/src/providers/ad/ad_init.c
d6181b
@@ -408,7 +408,7 @@ static errno_t ad_init_misc(struct be_ctx *be_ctx,
d6181b
         return ret;
d6181b
     }
d6181b
 
d6181b
-    ret = sdap_refresh_init(be_ctx->refresh_ctx, sdap_id_ctx);
d6181b
+    ret = sdap_refresh_init(be_ctx, sdap_id_ctx);
d6181b
     if (ret != EOK && ret != EEXIST) {
d6181b
         DEBUG(SSSDBG_MINOR_FAILURE, "Periodical refresh "
d6181b
               "will not work [%d]: %s\n", ret, sss_strerror(ret));
d6181b
diff --git a/src/providers/data_provider_be.c b/src/providers/data_provider_be.c
d6181b
index a1e7999c7..877841055 100644
d6181b
--- a/src/providers/data_provider_be.c
d6181b
+++ b/src/providers/data_provider_be.c
d6181b
@@ -536,14 +536,6 @@ errno_t be_process_init(TALLOC_CTX *mem_ctx,
d6181b
         goto done;
d6181b
     }
d6181b
 
d6181b
-    /* Initialize be_refresh periodic task. */
d6181b
-    be_ctx->refresh_ctx = be_refresh_ctx_init(be_ctx);
d6181b
-    if (be_ctx->refresh_ctx == NULL) {
d6181b
-        DEBUG(SSSDBG_FATAL_FAILURE, "Unable to initialize refresh_ctx\n");
d6181b
-        ret = ENOMEM;
d6181b
-        goto done;
d6181b
-    }
d6181b
-
d6181b
     req = dp_init_send(be_ctx, be_ctx->ev, be_ctx, be_ctx->uid, be_ctx->gid);
d6181b
     if (req == NULL) {
d6181b
         ret = ENOMEM;
d6181b
diff --git a/src/providers/ipa/ipa_init.c b/src/providers/ipa/ipa_init.c
d6181b
index 6818e2171..b3060e228 100644
d6181b
--- a/src/providers/ipa/ipa_init.c
d6181b
+++ b/src/providers/ipa/ipa_init.c
d6181b
@@ -594,7 +594,7 @@ static errno_t ipa_init_misc(struct be_ctx *be_ctx,
d6181b
         }
d6181b
     }
d6181b
 
d6181b
-    ret = sdap_refresh_init(be_ctx->refresh_ctx, sdap_id_ctx);
d6181b
+    ret = sdap_refresh_init(be_ctx, sdap_id_ctx);
d6181b
     if (ret != EOK && ret != EEXIST) {
d6181b
         DEBUG(SSSDBG_MINOR_FAILURE, "Periodical refresh "
d6181b
               "will not work [%d]: %s\n", ret, sss_strerror(ret));
d6181b
diff --git a/src/providers/ldap/ldap_common.h b/src/providers/ldap/ldap_common.h
d6181b
index 5d6302dcd..60e3ef297 100644
d6181b
--- a/src/providers/ldap/ldap_common.h
d6181b
+++ b/src/providers/ldap/ldap_common.h
d6181b
@@ -365,7 +365,7 @@ struct sdap_id_ctx *
d6181b
 sdap_id_ctx_new(TALLOC_CTX *mem_ctx, struct be_ctx *bectx,
d6181b
                 struct sdap_service *sdap_service);
d6181b
 
d6181b
-errno_t sdap_refresh_init(struct be_refresh_ctx *refresh_ctx,
d6181b
+errno_t sdap_refresh_init(struct be_ctx *be_ctx,
d6181b
                           struct sdap_id_ctx *id_ctx);
d6181b
 
d6181b
 errno_t sdap_init_certmap(TALLOC_CTX *mem_ctx, struct sdap_id_ctx *id_ctx);
d6181b
diff --git a/src/providers/ldap/ldap_init.c b/src/providers/ldap/ldap_init.c
d6181b
index 057e173ad..3ce574e28 100644
d6181b
--- a/src/providers/ldap/ldap_init.c
d6181b
+++ b/src/providers/ldap/ldap_init.c
d6181b
@@ -432,7 +432,7 @@ static errno_t ldap_init_misc(struct be_ctx *be_ctx,
d6181b
     }
d6181b
 
d6181b
     /* Setup periodical refresh of expired records */
d6181b
-    ret = sdap_refresh_init(be_ctx->refresh_ctx, id_ctx);
d6181b
+    ret = sdap_refresh_init(be_ctx, id_ctx);
d6181b
     if (ret != EOK && ret != EEXIST) {
d6181b
         DEBUG(SSSDBG_MINOR_FAILURE, "Periodical refresh will not work "
d6181b
               "[%d]: %s\n", ret, sss_strerror(ret));
d6181b
diff --git a/src/providers/ldap/sdap_refresh.c b/src/providers/ldap/sdap_refresh.c
d6181b
index 6d6c43e20..457df8be2 100644
d6181b
--- a/src/providers/ldap/sdap_refresh.c
d6181b
+++ b/src/providers/ldap/sdap_refresh.c
d6181b
@@ -255,12 +255,19 @@ static errno_t sdap_refresh_netgroups_recv(struct tevent_req *req)
d6181b
     return sdap_refresh_recv(req);
d6181b
 }
d6181b
 
d6181b
-errno_t sdap_refresh_init(struct be_refresh_ctx *refresh_ctx,
d6181b
+errno_t sdap_refresh_init(struct be_ctx *be_ctx,
d6181b
                           struct sdap_id_ctx *id_ctx)
d6181b
 {
d6181b
     errno_t ret;
d6181b
 
d6181b
-    ret = be_refresh_add_cb(refresh_ctx, BE_REFRESH_TYPE_USERS,
d6181b
+    be_ctx->refresh_ctx = be_refresh_ctx_init(be_ctx);
d6181b
+    if (be_ctx->refresh_ctx == NULL) {
d6181b
+        DEBUG(SSSDBG_FATAL_FAILURE, "Unable to initialize refresh_ctx\n");
d6181b
+        return ENOMEM;
d6181b
+    }
d6181b
+
d6181b
+    ret = be_refresh_add_cb(be_ctx->refresh_ctx,
d6181b
+                            BE_REFRESH_TYPE_USERS,
d6181b
                             sdap_refresh_users_send,
d6181b
                             sdap_refresh_users_recv,
d6181b
                             id_ctx);
d6181b
@@ -269,7 +276,8 @@ errno_t sdap_refresh_init(struct be_refresh_ctx *refresh_ctx,
d6181b
               "will not work [%d]: %s\n", ret, strerror(ret));
d6181b
     }
d6181b
 
d6181b
-    ret = be_refresh_add_cb(refresh_ctx, BE_REFRESH_TYPE_GROUPS,
d6181b
+    ret = be_refresh_add_cb(be_ctx->refresh_ctx,
d6181b
+                            BE_REFRESH_TYPE_USERS,
d6181b
                             sdap_refresh_groups_send,
d6181b
                             sdap_refresh_groups_recv,
d6181b
                             id_ctx);
d6181b
@@ -278,7 +286,8 @@ errno_t sdap_refresh_init(struct be_refresh_ctx *refresh_ctx,
d6181b
               "will not work [%d]: %s\n", ret, strerror(ret));
d6181b
     }
d6181b
 
d6181b
-    ret = be_refresh_add_cb(refresh_ctx, BE_REFRESH_TYPE_NETGROUPS,
d6181b
+    ret = be_refresh_add_cb(be_ctx->refresh_ctx,
d6181b
+                            BE_REFRESH_TYPE_USERS,
d6181b
                             sdap_refresh_netgroups_send,
d6181b
                             sdap_refresh_netgroups_recv,
d6181b
                             id_ctx);
d6181b
-- 
d6181b
2.20.1
d6181b