diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/db/sysdb.h | 6 | ||||
-rw-r--r-- | src/db/sysdb_subdomains.c | 43 | ||||
-rw-r--r-- | src/providers/ipa/ipa_subdomains.c | 30 |
3 files changed, 28 insertions, 51 deletions
diff --git a/src/db/sysdb.h b/src/db/sysdb.h index 6753f437..c6a70483 100644 --- a/src/db/sysdb.h +++ b/src/db/sysdb.h @@ -375,9 +375,9 @@ errno_t sysdb_update_subdomains(struct sss_domain_info *domain, errno_t sysdb_master_domain_update(struct sss_domain_info *domain); -errno_t sysdb_master_domain_add_info(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, - struct sysdb_subdom *domain_info); +errno_t sysdb_master_domain_add_info(struct sss_domain_info *domain, + const char *realm, const char *flat, + const char *id); errno_t sysdb_get_ranges(TALLOC_CTX *mem_ctx, struct sysdb_ctx *sysdb, size_t *range_count, diff --git a/src/db/sysdb_subdomains.c b/src/db/sysdb_subdomains.c index 5ee4df06..2b1de126 100644 --- a/src/db/sysdb_subdomains.c +++ b/src/db/sysdb_subdomains.c @@ -194,9 +194,9 @@ done: return ret; } -errno_t sysdb_master_domain_add_info(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, - struct sysdb_subdom *domain_info) +errno_t sysdb_master_domain_add_info(struct sss_domain_info *domain, + const char *realm, const char *flat, + const char *id) { TALLOC_CTX *tmp_ctx; struct ldb_message *msg; @@ -219,16 +219,15 @@ errno_t sysdb_master_domain_add_info(struct sysdb_ctx *sysdb, goto done; } - msg->dn = ldb_dn_new_fmt(tmp_ctx, sysdb->ldb, + msg->dn = ldb_dn_new_fmt(tmp_ctx, domain->sysdb->ldb, SYSDB_DOM_BASE, domain->name); if (msg->dn == NULL) { ret = EIO; goto done; } - if (domain_info->realm != NULL && - (domain->realm == NULL || - strcmp(domain->realm, domain_info->realm) != 0) ) { + if (realm != NULL && (domain->realm == NULL || + strcmp(domain->realm, realm) != 0)) { ret = ldb_msg_add_empty(msg, SYSDB_SUBDOMAIN_REALM, LDB_FLAG_MOD_REPLACE, NULL); if (ret != LDB_SUCCESS) { @@ -236,8 +235,7 @@ errno_t sysdb_master_domain_add_info(struct sysdb_ctx *sysdb, goto done; } - ret = ldb_msg_add_string(msg, SYSDB_SUBDOMAIN_REALM, - domain_info->realm); + ret = ldb_msg_add_string(msg, SYSDB_SUBDOMAIN_REALM, realm); if (ret != LDB_SUCCESS) { ret = sysdb_error_to_errno(ret); goto done; @@ -246,9 +244,8 @@ errno_t sysdb_master_domain_add_info(struct sysdb_ctx *sysdb, do_update = true; } - if (domain_info->flat_name != NULL && - (domain->flat_name == NULL || - strcmp(domain->flat_name, domain_info->flat_name) != 0) ) { + if (flat != NULL && (domain->flat_name == NULL || + strcmp(domain->flat_name, flat) != 0)) { ret = ldb_msg_add_empty(msg, SYSDB_SUBDOMAIN_FLAT, LDB_FLAG_MOD_REPLACE, NULL); if (ret != LDB_SUCCESS) { @@ -256,8 +253,7 @@ errno_t sysdb_master_domain_add_info(struct sysdb_ctx *sysdb, goto done; } - ret = ldb_msg_add_string(msg, SYSDB_SUBDOMAIN_FLAT, - domain_info->flat_name); + ret = ldb_msg_add_string(msg, SYSDB_SUBDOMAIN_FLAT, flat); if (ret != LDB_SUCCESS) { ret = sysdb_error_to_errno(ret); goto done; @@ -266,17 +262,16 @@ errno_t sysdb_master_domain_add_info(struct sysdb_ctx *sysdb, do_update = true; } - if (domain_info->id != NULL && - (domain->domain_id == NULL || - strcmp(domain->domain_id, domain_info->id) != 0) ) { - ret = ldb_msg_add_empty(msg, SYSDB_SUBDOMAIN_ID, LDB_FLAG_MOD_REPLACE, - NULL); + if (id != NULL && (domain->domain_id == NULL || + strcmp(domain->domain_id, id) != 0)) { + ret = ldb_msg_add_empty(msg, SYSDB_SUBDOMAIN_ID, + LDB_FLAG_MOD_REPLACE, NULL); if (ret != LDB_SUCCESS) { ret = sysdb_error_to_errno(ret); goto done; } - ret = ldb_msg_add_string(msg, SYSDB_SUBDOMAIN_ID, domain_info->id); + ret = ldb_msg_add_string(msg, SYSDB_SUBDOMAIN_ID, id); if (ret != LDB_SUCCESS) { ret = sysdb_error_to_errno(ret); goto done; @@ -290,12 +285,11 @@ errno_t sysdb_master_domain_add_info(struct sysdb_ctx *sysdb, goto done; } - ret = ldb_modify(sysdb->ldb, msg); + ret = ldb_modify(domain->sysdb->ldb, msg); if (ret != LDB_SUCCESS) { DEBUG(SSSDBG_FATAL_FAILURE, ("Failed to add subdomain attributes to " - "[%s]: [%d][%s]!\n", - domain_info->name, ret, - ldb_errstring(sysdb->ldb))); + "[%s]: [%d][%s]!\n", domain->name, ret, + ldb_errstring(domain->sysdb->ldb))); ret = sysdb_error_to_errno(ret); goto done; } @@ -307,6 +301,7 @@ done: return ret; } + static errno_t sysdb_add_subdomain_attributes(struct sysdb_ctx *sysdb, struct sysdb_subdom *domain_info) { diff --git a/src/providers/ipa/ipa_subdomains.c b/src/providers/ipa/ipa_subdomains.c index 385be1c3..6c441b47 100644 --- a/src/providers/ipa/ipa_subdomains.c +++ b/src/providers/ipa/ipa_subdomains.c @@ -821,8 +821,6 @@ static void ipa_subdomains_handler_master_done(struct tevent_req *req) size_t reply_count; struct sysdb_attrs **reply = NULL; struct ipa_subdomains_req_ctx *ctx; - struct sysdb_subdom *domain_info; - const char *tmp_str; ctx = tevent_req_callback_data(req, struct ipa_subdomains_req_ctx); @@ -834,36 +832,21 @@ static void ipa_subdomains_handler_master_done(struct tevent_req *req) } if (reply_count) { - domain_info = talloc_zero(ctx, struct sysdb_subdom); - if (domain_info == NULL) { - ret = ENOMEM; - goto done; - } + const char *flat = NULL; + const char *id = NULL; - ret = sysdb_attrs_get_string(reply[0], IPA_FLATNAME, &tmp_str); + ret = sysdb_attrs_get_string(reply[0], IPA_FLATNAME, &flat); if (ret != EOK) { goto done; } - domain_info->flat_name = talloc_strdup(domain_info, tmp_str); - if (domain_info->flat_name == NULL) { - ret = ENOMEM; - goto done; - } - ret = sysdb_attrs_get_string(reply[0], IPA_SID, &tmp_str); + ret = sysdb_attrs_get_string(reply[0], IPA_SID, &id); if (ret != EOK) { goto done; } - domain_info->id = talloc_strdup(domain_info, tmp_str); - if (domain_info->id == NULL) { - ret = ENOMEM; - goto done; - } - ret = sysdb_master_domain_add_info(ctx->sd_ctx->be_ctx->domain->sysdb, - ctx->sd_ctx->be_ctx->domain, - domain_info); - goto done; + ret = sysdb_master_domain_add_info(ctx->sd_ctx->be_ctx->domain, + NULL, flat, id); } else { ctx->search_base_iter++; ret = ipa_subdomains_handler_get(ctx, IPA_SUBDOMAINS_MASTER); @@ -884,7 +867,6 @@ static void ipa_subdomains_handler_master_done(struct tevent_req *req) } ret = EIO; - goto done; } done: |