On Thu, 2014-02-06 at 17:08 +0100, Stephen Gallagher wrote: > On 02/06/2014 04:50 PM, Pavel Reichl wrote: > > Hello, > > > > in another thread Stephen Gallagher asked me to use static string > > to avoid code duplication. I've considered same thing for this > > patch in previous mail but probably nobody noticed. > > > > So I did it now. Please see new patch. > > > > Looks just about right. One minor grammar change: > > "Domain '%s' is the same *as* or differs..." > > > _______________________________________________ > sssd-devel mailing list > sssd-devel@lists.fedorahosted.org > https://lists.fedorahosted.org/mailman/listinfo/sssd-devel
Hello, thank for quick review. Fixed patch is attached. PR
>From 531e051659b610b6a14d322b7b18bdedb6ff5123 Mon Sep 17 00:00:00 2001 From: Pavel Reichl <prei...@redhat.com> Date: Thu, 16 Jan 2014 16:43:19 +0000 Subject: [PATCH] CONFDB: fail if there are domains with same name Fail to start sssd if the domains given in the domains option are the same as or only differ in case. Resolves: https://fedorahosted.org/sssd/ticket/2171 --- src/confdb/confdb.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/confdb/confdb.c b/src/confdb/confdb.c index c5cb0c8643bbdb036bc9ecccd74f6e3fd71e38e9..f0b8bf3d498090e4c2bfae27d43e924720e28e41 100644 --- a/src/confdb/confdb.c +++ b/src/confdb/confdb.c @@ -35,6 +35,10 @@ } \ } while(0) +/* Warning messages */ +#define SAME_DOMAINS_ERROR_MSG "Domain '%s' is the same as or differs only "\ + "in case from domain '%s'.\n" + static char *prepend_cn(char *str, int *slen, const char *comp, int clen) { char *ret; @@ -1187,6 +1191,20 @@ int confdb_get_domains(struct confdb_ctx *cdb, } for (i = 0; domlist[i]; i++) { + /* check if domain name is really unique */ + DLIST_FOR_EACH(domain, cdb->doms) { + if (strcasecmp(domain->name, domlist[i]) == 0) { + DEBUG(SSSDBG_FATAL_FAILURE, + (SAME_DOMAINS_ERROR_MSG, domlist[i], domain->name)); + sss_log(SSS_LOG_CRIT, + SAME_DOMAINS_ERROR_MSG, domlist[i], domain->name); + + ret = EINVAL; + goto done; + } + } + + domain = NULL; ret = confdb_get_domain_internal(cdb, cdb, domlist[i], &domain); if (ret) { DEBUG(0, ("Error (%d [%s]) retrieving domain [%s], skipping!\n", -- 1.8.4.2
_______________________________________________ sssd-devel mailing list sssd-devel@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/sssd-devel