Hi,

this patch might be a fix for some tickets where sssd doesn't immediately
goes to offline after a request failed with an error indication an
offline status, e.g. #743.

bye,
Sumit
From c6162abe078a6b53b66805dd5fb487c73ccb51a2 Mon Sep 17 00:00:00 2001
From: Sumit Bose <[email protected]>
Date: Mon, 20 Dec 2010 13:02:05 +0100
Subject: [PATCH] Avoid multiple initializations in LDAP provider

Currently in a domain where LDAP was used for id and auth the LDAP UIR
was added multiple times to the failover code which may cause unwanted
delays.
---
 src/providers/ldap/ldap_init.c |   69 +++++++++++++++++----------------------
 1 files changed, 30 insertions(+), 39 deletions(-)

diff --git a/src/providers/ldap/ldap_init.c b/src/providers/ldap/ldap_init.c
index 9b96d87..a1d8f05 100644
--- a/src/providers/ldap/ldap_init.c
+++ b/src/providers/ldap/ldap_init.c
@@ -178,38 +178,48 @@ int sssm_ldap_auth_init(struct be_ctx *bectx,
                         struct bet_ops **ops,
                         void **pvt_data)
 {
+    void *data;
+    struct sdap_id_ctx *id_ctx;
     struct sdap_auth_ctx *ctx;
-    const char *urls;
-    const char *dns_service_name;
     int ret;
 
-    ctx = talloc(bectx, struct sdap_auth_ctx);
-    if (!ctx) return ENOMEM;
+    ret = sssm_ldap_id_init(bectx, ops, &data);
+    if (ret == EOK) {
+        id_ctx = talloc_get_type(data, struct sdap_id_ctx);
 
-    ctx->be = bectx;
+        ctx = talloc(bectx, struct sdap_auth_ctx);
+        if (!ctx) return ENOMEM;
 
-    ret = ldap_get_options(ctx, bectx->cdb,
-                           bectx->conf_path, &ctx->opts);
-    if (ret != EOK) {
-        goto done;
+        ctx->be = bectx;
+        ctx->opts = id_ctx->opts;
+        ctx->service = id_ctx->service;
+        ctx->chpass_service = NULL;
+
+        *ops = &sdap_auth_ops;
+        *pvt_data = ctx;
     }
 
-    dns_service_name = dp_opt_get_string(ctx->opts->basic,
-                                         SDAP_DNS_SERVICE_NAME);
-    DEBUG(7, ("Service name for discovery set to %s\n", dns_service_name));
+    return ret;
+}
 
-    urls = dp_opt_get_string(ctx->opts->basic, SDAP_URI);
-    if (!urls) {
-        DEBUG(1, ("Missing ldap_uri, will use service discovery\n"));
-    }
+int sssm_ldap_chpass_init(struct be_ctx *bectx,
+                          struct bet_ops **ops,
+                          void **pvt_data)
+{
+    int ret;
+    void *data;
+    struct sdap_auth_ctx *ctx = NULL;
+    const char *urls;
+    const char *dns_service_name;
 
-    ret = sdap_service_init(ctx, ctx->be, "LDAP", dns_service_name,
-                            urls, &ctx->service);
+    ret = sssm_ldap_auth_init(bectx, ops, &data);
     if (ret != EOK) {
-        DEBUG(1, ("Failed to initialize failover service!\n"));
+        DEBUG(1, ("sssm_ldap_auth_init failed.\n"));
         goto done;
     }
 
+    ctx = talloc_get_type(data, struct sdap_auth_ctx);
+
     dns_service_name = dp_opt_get_string(ctx->opts->basic,
                                          SDAP_CHPASS_DNS_SERVICE_NAME);
     if (dns_service_name) {
@@ -231,14 +241,8 @@ int sssm_ldap_auth_init(struct be_ctx *bectx,
         }
     }
 
-    ret = setup_tls_config(ctx->opts->basic);
-    if (ret != EOK) {
-        DEBUG(1, ("setup_tls_config failed [%d][%s].\n",
-                  ret, strerror(ret)));
-        goto done;
-    }
 
-    *ops = &sdap_auth_ops;
+    *ops = &sdap_chpass_ops;
     *pvt_data = ctx;
     ret = EOK;
 
@@ -249,19 +253,6 @@ done:
     return ret;
 }
 
-int sssm_ldap_chpass_init(struct be_ctx *bectx,
-                          struct bet_ops **ops,
-                          void **pvt_data)
-{
-    int ret;
-
-    ret = sssm_ldap_auth_init(bectx, ops, pvt_data);
-
-    *ops = &sdap_chpass_ops;
-
-    return ret;
-}
-
 int sssm_ldap_access_init(struct be_ctx *bectx,
                           struct bet_ops **ops,
                           void **pvt_data)
-- 
1.7.3.2

_______________________________________________
sssd-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/sssd-devel

Reply via email to