[SSSD] [PATCH] LDAP: Setup periodic task only once.

Lukas Slebodnik lslebodn at redhat.com
Tue Feb 25 21:03:23 UTC 2014


On (25/02/14 21:05), Jakub Hrozek wrote:
>On Tue, Feb 25, 2014 at 08:05:45PM +0100, Lukas Slebodnik wrote:
>> updated patch is attached.
>> 
>> LS
>
>I think you sent the original patch by accident.

Once again.

LS
-------------- next part --------------
>From d0ca74fd94fd581940b684e3434b571ca327bd5f Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Wed, 12 Feb 2014 14:33:49 +0100
Subject: [PATCH] LDAP: Setup periodic task only once.

If id provider is {ipa, ad} periodic task will be stared in sssm_{ipa,ad}_init
If you enable enumeration and use different providers for id and sudo(autofs)
then another periodic task will be scheduled.
This can cause weird behaviour (e.g. missing members of group)

Perodic tasks will be started only by id_provider.

Resolves:
https://fedorahosted.org/sssd/ticket/2153
---
 src/providers/ldap/ldap_init.c | 54 ++++++++++++++++++++++++++++++++----------
 1 file changed, 41 insertions(+), 13 deletions(-)

diff --git a/src/providers/ldap/ldap_init.c b/src/providers/ldap/ldap_init.c
index a14e6ceaecdd5a72e1d28c8cb14782cdc6c2d54a..9960fd3ab7a6e446e5cdc1e8fa4984aab812d980 100644
--- a/src/providers/ldap/ldap_init.c
+++ b/src/providers/ldap/ldap_init.c
@@ -85,9 +85,9 @@ errno_t check_order_list_for_duplicates(char **list,
     return EOK;
 }
 
-int sssm_ldap_id_init(struct be_ctx *bectx,
-                      struct bet_ops **ops,
-                      void **pvt_data)
+static int ldap_id_init_internal(struct be_ctx *bectx,
+                                 struct bet_ops **ops,
+                                 void **pvt_data)
 {
     struct sdap_id_ctx *ctx = NULL;
     const char *urls;
@@ -163,11 +163,6 @@ int sssm_ldap_id_init(struct be_ctx *bectx,
     ret = sdap_idmap_init(ctx, ctx, &ctx->opts->idmap_ctx);
     if (ret != EOK) goto done;
 
-    ret = ldap_id_setup_tasks(ctx);
-    if (ret != EOK) {
-        goto done;
-    }
-
     ret = sdap_setup_child();
     if (ret != EOK) {
         DEBUG(SSSDBG_CRIT_FAILURE, "setup_child failed [%d][%s].\n",
@@ -205,6 +200,39 @@ done:
     return ret;
 }
 
+int sssm_ldap_id_init(struct be_ctx *bectx,
+                      struct bet_ops **ops,
+                      void **pvt_data)
+{
+    int ret;
+    struct sdap_id_ctx *ctx = NULL;
+
+    ret = ldap_id_init_internal(bectx, ops, (void **) &ctx);
+    if (ret != EOK) {
+        DEBUG(SSSDBG_MINOR_FAILURE,
+              "ldap_id_init_internal failed [%d][%s].\n",
+              ret, strerror(ret));
+        goto done;
+    }
+
+    ret = ldap_id_setup_tasks(ctx);
+    if (ret != EOK) {
+        DEBUG(SSSDBG_MINOR_FAILURE,
+              "sdap_id_setup_tasks failed [%d][%s].\n",
+              ret, strerror(ret));
+        goto done;
+    }
+
+    *pvt_data = ctx;
+    ret = EOK;
+
+done:
+    if (ret != EOK) {
+        talloc_free(ctx);
+    }
+    return ret;
+}
+
 int sssm_ldap_auth_init(struct be_ctx *bectx,
                         struct bet_ops **ops,
                         void **pvt_data)
@@ -214,7 +242,7 @@ int sssm_ldap_auth_init(struct be_ctx *bectx,
     struct sdap_auth_ctx *ctx;
     int ret;
 
-    ret = sssm_ldap_id_init(bectx, ops, &data);
+    ret = ldap_id_init_internal(bectx, ops, &data);
     if (ret == EOK) {
         id_ctx = talloc_get_type(data, struct sdap_id_ctx);
 
@@ -308,9 +336,9 @@ int sssm_ldap_access_init(struct be_ctx *bectx,
         goto done;
     }
 
-    ret = sssm_ldap_id_init(bectx, ops, (void **)&access_ctx->id_ctx);
+    ret = ldap_id_init_internal(bectx, ops, (void **)&access_ctx->id_ctx);
     if (ret != EOK) {
-        DEBUG(SSSDBG_CRIT_FAILURE, "sssm_ldap_id_init failed.\n");
+        DEBUG(SSSDBG_CRIT_FAILURE, "ldap_id_init_internal failed.\n");
         goto done;
     }
 
@@ -428,7 +456,7 @@ int sssm_ldap_sudo_init(struct be_ctx *be_ctx,
     void *data;
     int ret;
 
-    ret = sssm_ldap_id_init(be_ctx, ops, &data);
+    ret = ldap_id_init_internal(be_ctx, ops, &data);
     if (ret != EOK) {
         DEBUG(SSSDBG_CRIT_FAILURE, "Cannot init LDAP ID provider [%d]: %s\n",
                                     ret, strerror(ret));
@@ -458,7 +486,7 @@ int sssm_ldap_autofs_init(struct be_ctx *be_ctx,
     void *data;
     int ret;
 
-    ret = sssm_ldap_id_init(be_ctx, ops, &data);
+    ret = ldap_id_init_internal(be_ctx, ops, &data);
     if (ret != EOK) {
         DEBUG(SSSDBG_CRIT_FAILURE, "Cannot init LDAP ID provider [%d]: %s\n",
                                     ret, strerror(ret));
-- 
1.8.5.3



More information about the sssd-devel mailing list