dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone
Blob Blame History Raw
From 178e61b6dc5b547bd77998f586f118bfa9b06d30 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
Date: Fri, 5 Aug 2016 11:32:43 +0200
Subject: [PATCH 77/82] DP: Initialize D-Bus as soon as possible

Resolves:
https://fedorahosted.org/sssd/ticket/3111

Reviewed-by: Petr Cech <pcech@redhat.com>
---
 src/providers/data_provider/dp.c         | 34 +++++++++++++++++++-------------
 src/providers/data_provider/dp_methods.c |  6 ++++++
 2 files changed, 26 insertions(+), 14 deletions(-)

diff --git a/src/providers/data_provider/dp.c b/src/providers/data_provider/dp.c
index c4590e3152126fe166d0bc9e3be2a14978f90168..b672370aa153c9cd2031399a8d61c95fb16cd641 100644
--- a/src/providers/data_provider/dp.c
+++ b/src/providers/data_provider/dp.c
@@ -86,6 +86,7 @@ errno_t dp_init(struct tevent_context *ev,
     provider->gid = gid;
     provider->be_ctx = be_ctx;
 
+    /* Initialize request table. */
     ret = dp_req_table_init(provider, &provider->requests.reply_table);
     if (ret != EOK) {
         DEBUG(SSSDBG_CRIT_FAILURE, "Unable to initialize request table "
@@ -93,20 +94,11 @@ errno_t dp_init(struct tevent_context *ev,
         goto done;
     }
 
-    ret = dp_init_modules(provider, &provider->modules);
-    if (ret != EOK) {
-        DEBUG(SSSDBG_CRIT_FAILURE, "Unable to initialize DP modules "
-              "[%d]: %s\n", ret, sss_strerror(ret));
-        goto done;
-    }
-
-    ret = dp_init_targets(provider, be_ctx, provider, provider->modules);
-    if (ret != EOK) {
-        DEBUG(SSSDBG_CRIT_FAILURE, "Unable to initialize DP targets "
-              "[%d]: %s\n", ret, sss_strerror(ret));
-        goto done;
-    }
-
+    /* Initialize data provider bus. Data provider can receive client
+     * registration and other D-Bus methods. However no data provider
+     * request will be executed as long as the modules and targets
+     * are not initialized.
+     */
     talloc_set_destructor(provider, dp_destructor);
 
     ret = dp_init_dbus_server(provider);
@@ -118,6 +110,20 @@ errno_t dp_init(struct tevent_context *ev,
 
     be_ctx->provider = provider;
 
+    ret = dp_init_modules(provider, &provider->modules);
+    if (ret != EOK) {
+        DEBUG(SSSDBG_CRIT_FAILURE, "Unable to initialize DP modules "
+              "[%d]: %s\n", ret, sss_strerror(ret));
+        goto done;
+    }
+
+    ret = dp_init_targets(provider, be_ctx, provider, provider->modules);
+    if (ret != EOK) {
+        DEBUG(SSSDBG_CRIT_FAILURE, "Unable to initialize DP targets "
+              "[%d]: %s\n", ret, sss_strerror(ret));
+        goto done;
+    }
+
     ret = EOK;
 
 done:
diff --git a/src/providers/data_provider/dp_methods.c b/src/providers/data_provider/dp_methods.c
index e4290beeeef3c0c4d156271ad88f891d3245af08..498676d1bec2da300ca4b33f7110debcbf0aac00 100644
--- a/src/providers/data_provider/dp_methods.c
+++ b/src/providers/data_provider/dp_methods.c
@@ -76,6 +76,12 @@ bool dp_method_enabled(struct data_provider *provider,
         return false;
     }
 
+    if (provider == NULL || provider->targets == NULL) {
+        DEBUG(SSSDBG_TRACE_FUNC, "Target %s is not yet initialized\n",
+              dp_target_to_string(target));
+        return false;
+    }
+
     dp_target = provider->targets[target];
     if (dp_target == NULL || dp_target->initialized == false) {
         DEBUG(SSSDBG_TRACE_FUNC, "Target %s is not configured\n",
-- 
2.4.11