This patch resolves https://fedorahosted.org/sssd/ticket/97

-- 
Stephen Gallagher
RHCE 804006346421761

Looking to carve out IT costs?
www.redhat.com/carveoutcosts/
From 74fea355d8def195385e79fa6f97fe53e60a5281 Mon Sep 17 00:00:00 2001
From: Stephen Gallagher <sgall...@redhat.com>
Date: Mon, 17 Aug 2009 13:56:36 -0400
Subject: [PATCH 1/2] Ensure that only one local domain is configured

---
 server/monitor/monitor.c |   33 ++++++++++++++++++++++++++++++++-
 1 files changed, 32 insertions(+), 1 deletions(-)

diff --git a/server/monitor/monitor.c b/server/monitor/monitor.c
index ba92a90..67e5b6e 100644
--- a/server/monitor/monitor.c
+++ b/server/monitor/monitor.c
@@ -806,6 +806,31 @@ static int append_data_provider(struct mt_ctx *ctx)
     return EOK;
 }
 
+static int check_local_domain_unique(struct sss_domain_info *domains)
+{
+    uint8_t count = 0;
+
+    struct sss_domain_info *dom = domains;
+
+    while (dom) {
+        if (strcasecmp(dom->provider, "local") == 0) {
+            count++;
+        }
+
+        if (count > 1) {
+            break;
+        }
+
+        dom = dom->next;
+    }
+
+    if (count > 1) {
+        return EINVAL;
+    }
+
+    return EOK;
+}
+
 int get_monitor_config(struct mt_ctx *ctx)
 {
     int ret;
@@ -843,7 +868,13 @@ int get_monitor_config(struct mt_ctx *ctx)
     }
     ret = confdb_get_domains(ctx->cdb, ctx->domain_ctx, &ctx->domains);
     if (ret != EOK) {
-        DEBUG(2, ("No domains configured. LOCAL should always exist!\n"));
+        DEBUG(0, ("No domains configured.\n"));
+        return ret;
+    }
+
+    ret = check_local_domain_unique(ctx->domains);
+    if (ret != EOK) {
+        DEBUG(0, ("More than one local domain configured.\n"));
         return ret;
     }
 
-- 
1.6.2.5

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
sssd-devel mailing list
sssd-devel@lists.fedorahosted.org
https://fedorahosted.org/mailman/listinfo/sssd-devel

Reply via email to