From 9ec215c6a84e7fdc2e3df4c92e7b6ed7db118742 Mon Sep 17 00:00:00 2001 From: Sumit Bose Date: Mon, 25 Nov 2013 17:54:06 +0100 Subject: [PATCH 1/5] sss_cache: initialize names member of sss_domain_info sss_tc_fqname() called by sss_get_domain_name() requires that the names member of the sss_domain_info struct is set to work properly. If the names struct is properly initialized in sss_domain_info the separate one in the tool context is not needed anymore. Related to https://fedorahosted.org/sssd/ticket/1741 --- src/tools/sss_cache.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/tools/sss_cache.c b/src/tools/sss_cache.c index fa2e29d..3b6e623 100644 --- a/src/tools/sss_cache.c +++ b/src/tools/sss_cache.c @@ -63,7 +63,6 @@ static errno_t search_autofsmaps(TALLOC_CTX *mem_ctx, struct sysdb_ctx *sysdb, struct cache_tool_ctx { struct confdb_ctx *confdb; struct sss_domain_info *domains; - struct sss_names_ctx *nctx; char *user_filter; char *group_filter; @@ -209,7 +208,7 @@ static errno_t update_filter(struct cache_tool_ctx *tctx, return ENOMEM; } - ret = sss_parse_name(tmp_ctx, tctx->nctx, name, + ret = sss_parse_name(tmp_ctx, dinfo->names, name, &parsed_domain, &parsed_name); if (ret != EOK) { DEBUG(SSSDBG_CRIT_FAILURE, ("sss_parse_name failed\n")); @@ -280,17 +279,6 @@ static errno_t update_all_filters(struct cache_tool_ctx *tctx, { errno_t ret; - if (IS_SUBDOMAIN(dinfo)) { - ret = sss_names_init(tctx, tctx->confdb, dinfo->parent->name, - &tctx->nctx); - } else { - ret = sss_names_init(tctx, tctx->confdb, dinfo->name, &tctx->nctx); - } - if (ret != EOK) { - DEBUG(SSSDBG_CRIT_FAILURE, ("sss_names_init() failed\n")); - return ret; - } - /* Update user filter */ ret = update_filter(tctx, dinfo, tctx->user_name, tctx->update_user_filter, "(%s=%s)", false, @@ -467,6 +455,7 @@ errno_t init_domains(struct cache_tool_ctx *ctx, const char *domain) { char *confdb_path; int ret; + struct sss_domain_info *dinfo; confdb_path = talloc_asprintf(ctx, "%s/%s", DB_PATH, CONFDB_FILE); if (confdb_path == NULL) { @@ -505,6 +494,14 @@ errno_t init_domains(struct cache_tool_ctx *ctx, const char *domain) } } + for (dinfo = ctx->domains; dinfo; dinfo = get_next_domain(dinfo, false)) { + ret = sss_names_init(ctx, ctx->confdb, dinfo->name, &dinfo->names); + if (ret != EOK) { + DEBUG(SSSDBG_CRIT_FAILURE, ("sss_names_init() failed\n")); + return ret; + } + } + return EOK; } -- 1.8.3.1