diff options
author | Stephen Gallagher <sgallagh@redhat.com> | 2009-08-17 13:56:36 -0400 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2009-08-18 07:55:50 -0400 |
commit | 67cda7b46dfb6c92a2b39a2d400356e628d16876 (patch) | |
tree | 07f0d12c523fbc648f26dc10a84209f3539b4571 /server/monitor | |
parent | b75a3f0a47e474d72d51ccb75d2691a573401cc2 (diff) | |
download | sssd-67cda7b46dfb6c92a2b39a2d400356e628d16876.tar.gz sssd-67cda7b46dfb6c92a2b39a2d400356e628d16876.tar.bz2 sssd-67cda7b46dfb6c92a2b39a2d400356e628d16876.zip |
Ensure that only one local domain is configured
Diffstat (limited to 'server/monitor')
-rw-r--r-- | 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 ba92a906..67e5b6e3 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; } |