summaryrefslogtreecommitdiffstats
path: root/src/util/usertools.c
diff options
context:
space:
mode:
authorSumit Bose <sbose@redhat.com>2013-11-07 17:38:54 +0100
committerJakub Hrozek <jhrozek@redhat.com>2013-11-15 20:38:08 +0100
commit45ba1e10beddf082c061e0a2950340596817861a (patch)
treec45d0ff2bcf4b812d9a7ee685930cf50fd1cdee5 /src/util/usertools.c
parent4ecd8a3173b3564be0c5f762de0b07e2f189ad59 (diff)
downloadsssd-45ba1e10beddf082c061e0a2950340596817861a.tar.gz
sssd-45ba1e10beddf082c061e0a2950340596817861a.tar.xz
sssd-45ba1e10beddf082c061e0a2950340596817861a.zip
sss_names_init: allow empty domain name
If no domain name is specified the global name pattern and regular expression will be returned.
Diffstat (limited to 'src/util/usertools.c')
-rw-r--r--src/util/usertools.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/src/util/usertools.c b/src/util/usertools.c
index 88f648079..e8e4dce96 100644
--- a/src/util/usertools.c
+++ b/src/util/usertools.c
@@ -241,9 +241,9 @@ int sss_names_init(TALLOC_CTX *mem_ctx, struct confdb_ctx *cdb,
const char *domain, struct sss_names_ctx **out)
{
TALLOC_CTX *tmpctx = NULL;
- char *conf_path;
- char *re_pattern;
- char *fq_fmt;
+ char *conf_path = NULL;
+ char *re_pattern = NULL;;
+ char *fq_fmt = NULL;
int ret;
tmpctx = talloc_new(NULL);
@@ -252,15 +252,17 @@ int sss_names_init(TALLOC_CTX *mem_ctx, struct confdb_ctx *cdb,
goto done;
}
- conf_path = talloc_asprintf(tmpctx, CONFDB_DOMAIN_PATH_TMPL, domain);
- if (conf_path == NULL) {
- ret = ENOMEM;
- goto done;
- }
+ if (domain != NULL) {
+ conf_path = talloc_asprintf(tmpctx, CONFDB_DOMAIN_PATH_TMPL, domain);
+ if (conf_path == NULL) {
+ ret = ENOMEM;
+ goto done;
+ }
- ret = confdb_get_string(cdb, tmpctx, conf_path,
- CONFDB_NAME_REGEX, NULL, &re_pattern);
- if (ret != EOK) goto done;
+ ret = confdb_get_string(cdb, tmpctx, conf_path,
+ CONFDB_NAME_REGEX, NULL, &re_pattern);
+ if (ret != EOK) goto done;
+ }
/* If not found in the domain, look in globals */
if (re_pattern == NULL) {
@@ -269,7 +271,7 @@ int sss_names_init(TALLOC_CTX *mem_ctx, struct confdb_ctx *cdb,
if (ret != EOK) goto done;
}
- if (re_pattern == NULL) {
+ if (re_pattern == NULL && conf_path != NULL) {
ret = get_id_provider_default_re(tmpctx, cdb, conf_path, &re_pattern);
if (ret != EOK) {
DEBUG(SSSDBG_OP_FAILURE, ("Failed to get provider default regular " \
@@ -295,9 +297,11 @@ int sss_names_init(TALLOC_CTX *mem_ctx, struct confdb_ctx *cdb,
#endif
}
- ret = confdb_get_string(cdb, tmpctx, conf_path,
- CONFDB_FULL_NAME_FORMAT, NULL, &fq_fmt);
- if (ret != EOK) goto done;
+ if (conf_path != NULL) {
+ ret = confdb_get_string(cdb, tmpctx, conf_path,
+ CONFDB_FULL_NAME_FORMAT, NULL, &fq_fmt);
+ if (ret != EOK) goto done;
+ }
/* If not found in the domain, look in globals */
if (fq_fmt == NULL) {