dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone
Blob Blame History Raw
From c9c4b9cbe87e39d3305be2217535d25d1b272af6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
Date: Fri, 14 Sep 2018 12:30:57 +0200
Subject: [PATCH] be: use be_is_offline for the main domain when asking for
 domain status
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The DOM_ACTIVE/INACTIVE flag is not used with the main domain as it
is used only for subdomains.

Resolves:
https://pagure.io/SSSD/sssd/issue/3830

Reviewed-by: Michal Židek <mzidek@redhat.com>
(cherry picked from commit dfa7bf1133f002a9fbbd3495a70909913db25b16)
---
 src/providers/data_provider/dp_iface_backend.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/src/providers/data_provider/dp_iface_backend.c b/src/providers/data_provider/dp_iface_backend.c
index 25a00f327116bdf513a939c3b68dae375a1d0538..85159a71be603ffadaa7bd2bd5f3bcf03c0a3eca 100644
--- a/src/providers/data_provider/dp_iface_backend.c
+++ b/src/providers/data_provider/dp_iface_backend.c
@@ -37,15 +37,23 @@ dp_backend_is_online(TALLOC_CTX *mem_ctx,
     struct sss_domain_info *domain;
 
     if (SBUS_REQ_STRING_IS_EMPTY(domname)) {
-        *_is_online = be_is_offline(be_ctx);
-        return EOK;
+        domain = be_ctx->domain;
+    } else {
+        domain = find_domain_by_name(be_ctx->domain, domname, false);
+        if (domain == NULL) {
+            return ERR_DOMAIN_NOT_FOUND;
+        }
     }
 
-    domain = find_domain_by_name(be_ctx->domain, domname, false);
-    if (domain == NULL) {
-        return ERR_DOMAIN_NOT_FOUND;
+    /**
+     * FIXME: https://pagure.io/SSSD/sssd/issue/3831
+     * domain->state is set only for subdomains not for the main domain
+     */
+    if (be_ctx->domain == domain) {
+        *_is_online = be_is_offline(be_ctx) == false;
+    } else {
+        *_is_online = domain->state == DOM_ACTIVE;
     }
 
-    *_is_online = domain->state == DOM_ACTIVE;
     return EOK;
 }
-- 
2.14.4