>From ae3cee52a7ce062bd7c4b104f1b94bfa79ac7e24 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Wed, 21 Aug 2013 17:22:59 +0200 Subject: [PATCH 08/12] SYSDB: Store enumerate flag for subdomain --- src/db/sysdb.h | 3 ++- src/db/sysdb_subdomains.c | 27 +++++++++++++++++++++++++-- src/providers/ad/ad_subdomains.c | 4 ++-- src/providers/ipa/ipa_subdomains.c | 3 ++- src/tests/sysdb-tests.c | 12 +++++++----- 5 files changed, 38 insertions(+), 11 deletions(-) diff --git a/src/db/sysdb.h b/src/db/sysdb.h index 953b15d2309e1a57a0938c475f22e45111796046..b6d5abb10d08518b495f8a0b062cc188e3593fd8 100644 --- a/src/db/sysdb.h +++ b/src/db/sysdb.h @@ -126,6 +126,7 @@ #define SYSDB_SUBDOMAIN_FLAT "flatName" #define SYSDB_SUBDOMAIN_ID "domainID" #define SYSDB_SUBDOMAIN_MPG "mpg" +#define SYSDB_SUBDOMAIN_ENUM "enumerate" #define SYSDB_BASE_ID "baseID" #define SYSDB_ID_RANGE_SIZE "idRangeSize" @@ -370,7 +371,7 @@ errno_t sysdb_domain_create(struct sysdb_ctx *sysdb, const char *domain_name); errno_t sysdb_subdomain_store(struct sysdb_ctx *sysdb, const char *name, const char *realm, const char *flat_name, const char *domain_id, - bool mpg); + bool mpg, bool enumerate); errno_t sysdb_update_subdomains(struct sss_domain_info *domain); diff --git a/src/db/sysdb_subdomains.c b/src/db/sysdb_subdomains.c index 0e7514baa993a4d02402695bf51992488fc0ed1e..2b80b5b9e79a101ab030b4af1dfc5497e9b35bf6 100644 --- a/src/db/sysdb_subdomains.c +++ b/src/db/sysdb_subdomains.c @@ -342,7 +342,7 @@ done: errno_t sysdb_subdomain_store(struct sysdb_ctx *sysdb, const char *name, const char *realm, const char *flat_name, const char *domain_id, - bool mpg) + bool mpg, bool enumerate) { TALLOC_CTX *tmp_ctx; struct ldb_message *msg; @@ -353,6 +353,7 @@ errno_t sysdb_subdomain_store(struct sysdb_ctx *sysdb, SYSDB_SUBDOMAIN_FLAT, SYSDB_SUBDOMAIN_ID, SYSDB_SUBDOMAIN_MPG, + SYSDB_SUBDOMAIN_ENUM, NULL}; const char *tmp_str; bool tmp_bool; @@ -361,6 +362,7 @@ errno_t sysdb_subdomain_store(struct sysdb_ctx *sysdb, int flat_flags = 0; int id_flags = 0; int mpg_flags = 0; + int enum_flags = 0; int ret; tmp_ctx = talloc_new(NULL); @@ -390,6 +392,7 @@ errno_t sysdb_subdomain_store(struct sysdb_ctx *sysdb, if (flat_name) flat_flags = LDB_FLAG_MOD_ADD; if (domain_id) id_flags = LDB_FLAG_MOD_ADD; mpg_flags = LDB_FLAG_MOD_ADD; + enum_flags = LDB_FLAG_MOD_ADD; } else if (res->count != 1) { ret = EINVAL; goto done; @@ -421,10 +424,15 @@ errno_t sysdb_subdomain_store(struct sysdb_ctx *sysdb, if (tmp_bool != mpg) { mpg_flags = LDB_FLAG_MOD_REPLACE; } + tmp_bool = ldb_msg_find_attr_as_bool(res->msgs[0], SYSDB_SUBDOMAIN_ENUM, + !enumerate); + if (tmp_bool != enumerate) { + enum_flags = LDB_FLAG_MOD_REPLACE; + } } if (!store && realm_flags == 0 && flat_flags == 0 && id_flags == 0 - && mpg_flags == 0) { + && mpg_flags == 0 && enum_flags == 0) { ret = EOK; goto done; } @@ -507,6 +515,21 @@ errno_t sysdb_subdomain_store(struct sysdb_ctx *sysdb, } } + if (enum_flags) { + ret = ldb_msg_add_empty(msg, SYSDB_SUBDOMAIN_ENUM, enum_flags, NULL); + if (ret != LDB_SUCCESS) { + ret = sysdb_error_to_errno(ret); + goto done; + } + + ret = ldb_msg_add_string(msg, SYSDB_SUBDOMAIN_ENUM, + enumerate ? "TRUE" : "FALSE"); + if (ret != LDB_SUCCESS) { + ret = sysdb_error_to_errno(ret); + goto done; + } + } + ret = ldb_modify(sysdb->ldb, msg); if (ret != LDB_SUCCESS) { DEBUG(SSSDBG_FATAL_FAILURE, ("Failed to add subdomain attributes to " diff --git a/src/providers/ad/ad_subdomains.c b/src/providers/ad/ad_subdomains.c index 0eebd4d98bb59ab1bdc65fabc2edef821b4d3b73..afd2031fe6be557f43555b6dd8b47731d9833585 100644 --- a/src/providers/ad/ad_subdomains.c +++ b/src/providers/ad/ad_subdomains.c @@ -156,9 +156,9 @@ ad_subdom_store(struct ad_subdomains_ctx *ctx, goto done; } - /* AD subdomains are currently all mpg */ + /* AD subdomains are currently all mpg and do not enumerate */ ret = sysdb_subdomain_store(domain->sysdb, name, realm, flat, sid_str, - true); + true, false); if (ret != EOK) { DEBUG(SSSDBG_OP_FAILURE, ("sysdb_subdomain_store failed.\n")); goto done; diff --git a/src/providers/ipa/ipa_subdomains.c b/src/providers/ipa/ipa_subdomains.c index 1a0c1c1bbf5f4e6fa44b352af4883f8624074ad5..6064f0407b0a98f795db52f216adb4d1ff539435 100644 --- a/src/providers/ipa/ipa_subdomains.c +++ b/src/providers/ipa/ipa_subdomains.c @@ -445,7 +445,8 @@ static errno_t ipa_subdom_store(struct sss_domain_info *domain, mpg = sdap_idmap_domain_has_algorithmic_mapping(sdap_idmap_ctx, id); - ret = sysdb_subdomain_store(domain->sysdb, name, realm, flat, id, mpg); + ret = sysdb_subdomain_store(domain->sysdb, name, realm, flat, + id, mpg, false); if (ret) { DEBUG(SSSDBG_OP_FAILURE, ("sysdb_subdomain_store failed.\n")); goto done; diff --git a/src/tests/sysdb-tests.c b/src/tests/sysdb-tests.c index 60a20c8b4d1dcb8701286b1589bdcf351d2ccd95..31d2dd3dea7aaef94aad88e398fa779b8c85fce3 100644 --- a/src/tests/sysdb-tests.c +++ b/src/tests/sysdb-tests.c @@ -4524,7 +4524,8 @@ START_TEST(test_sysdb_subdomain_create) fail_if(ret != EOK, "Could not set up the test"); ret = sysdb_subdomain_store(test_ctx->sysdb, - dom1[0], dom1[1], dom1[2], dom1[3], false); + dom1[0], dom1[1], dom1[2], dom1[3], + false, false); fail_if(ret != EOK, "Could not set up the test (dom1)"); ret = sysdb_update_subdomains(test_ctx->domain); @@ -4537,7 +4538,8 @@ START_TEST(test_sysdb_subdomain_create) dom1[0], test_ctx->domain->subdomains->name); ret = sysdb_subdomain_store(test_ctx->sysdb, - dom2[0], dom2[1], dom2[2], dom2[3], false); + dom2[0], dom2[1], dom2[2], dom2[3], + false, false); fail_if(ret != EOK, "Could not set up the test (dom2)"); ret = sysdb_update_subdomains(test_ctx->domain); @@ -4586,7 +4588,7 @@ START_TEST(test_sysdb_subdomain_store_user) fail_unless(subdomain != NULL, "Failed to create new subdomin."); ret = sysdb_subdomain_store(test_ctx->sysdb, testdom[0], testdom[1], testdom[2], testdom[3], - false); + false, false); fail_if(ret != EOK, "Could not set up the test (test subdom)"); ret = sysdb_update_subdomains(test_ctx->domain); @@ -4657,7 +4659,7 @@ START_TEST(test_sysdb_subdomain_user_ops) fail_unless(subdomain != NULL, "Failed to create new subdomin."); ret = sysdb_subdomain_store(test_ctx->sysdb, testdom[0], testdom[1], testdom[2], testdom[3], - false); + false, false); fail_if(ret != EOK, "Could not set up the test (test subdom)"); ret = sysdb_update_subdomains(test_ctx->domain); @@ -4712,7 +4714,7 @@ START_TEST(test_sysdb_subdomain_group_ops) fail_unless(subdomain != NULL, "Failed to create new subdomin."); ret = sysdb_subdomain_store(test_ctx->sysdb, testdom[0], testdom[1], testdom[2], testdom[3], - false); + false, false); fail_if(ret != EOK, "Could not set up the test (test subdom)"); ret = sysdb_update_subdomains(test_ctx->domain); -- 1.8.3.1