>From e8622316668d956c749e1bbca97c9c7140eacb06 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Tue, 12 May 2015 14:27:35 +0200 Subject: [PATCH 08/29] IPA: Fold ipa_subdom_enumerates into ipa_subdom_store Reduced code duplication --- src/providers/ipa/ipa_subdomains.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/src/providers/ipa/ipa_subdomains.c b/src/providers/ipa/ipa_subdomains.c index 6d69bf82cdc5569d68db929b2e307e0dd19458f8..ce597502329172b3ec48cfe98166b465670a459d 100644 --- a/src/providers/ipa/ipa_subdomains.c +++ b/src/providers/ipa/ipa_subdomains.c @@ -643,8 +643,7 @@ done: static errno_t ipa_subdom_store(struct sss_domain_info *parent, struct sdap_idmap_ctx *sdap_idmap_ctx, - struct sysdb_attrs *attrs, - bool enumerate) + struct sysdb_attrs *attrs) { TALLOC_CTX *tmp_ctx; const char *name; @@ -654,6 +653,7 @@ static errno_t ipa_subdom_store(struct sss_domain_info *parent, char *forest = NULL; int ret; bool mpg; + bool enumerate; tmp_ctx = talloc_new(parent); if (tmp_ctx == NULL) { @@ -692,6 +692,11 @@ static errno_t ipa_subdom_store(struct sss_domain_info *parent, goto done; } + ret = ipa_subdom_enumerates(parent, attrs, &enumerate); + if (ret != EOK) { + goto done; + } + ret = sysdb_subdomain_store(parent->sysdb, name, realm, flat, id, mpg, enumerate, forest, SD_TRUST_DIRECTION_NOT_SET); @@ -715,7 +720,6 @@ static errno_t ipa_subdomains_refresh(struct ipa_subdomains_ctx *ctx, const char *value; int c, h; int ret; - bool enumerate; parent = ctx->be_ctx->domain; memset(handled, 0, sizeof(bool) * count); @@ -751,13 +755,8 @@ static errno_t ipa_subdomains_refresh(struct ipa_subdomains_ctx *ctx, ipa_ad_subdom_remove(ctx, dom); } else { /* ok let's try to update it */ - ret = ipa_subdom_enumerates(parent, reply[c], &enumerate); - if (ret != EOK) { - goto done; - } - ret = ipa_subdom_store(parent, ctx->sdap_id_ctx->opts->idmap_ctx, - reply[c], enumerate); + reply[c]); if (ret) { /* Nothing we can do about the errorr. Let's at least try * to reuse the existing domain @@ -783,16 +782,12 @@ static errno_t ipa_subdomains_refresh(struct ipa_subdomains_ctx *ctx, if (handled[c]) { continue; } + /* Nothing we can do about the errorr. Let's at least try * to reuse the existing domain. */ - ret = ipa_subdom_enumerates(parent, reply[c], &enumerate); - if (ret != EOK) { - goto done; - } - ret = ipa_subdom_store(parent, ctx->sdap_id_ctx->opts->idmap_ctx, - reply[c], enumerate); + reply[c]); if (ret) { DEBUG(SSSDBG_MINOR_FAILURE, "Failed to parse subdom data, " "will try to use cached subdomain\n"); -- 2.1.0