summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSumit Bose <sbose@redhat.com>2013-06-28 10:21:57 +0200
committerJakub Hrozek <jhrozek@redhat.com>2013-06-28 20:20:59 +0200
commit9822d4d468ec74e4e173f5adf0db12d02974cd18 (patch)
tree9b686c8f2ac873fff81593dae7d141ea5607b66f /src
parent09d7c105839bfc7447ea0f766413ed86675ca075 (diff)
downloadsssd-9822d4d468ec74e4e173f5adf0db12d02974cd18.tar.gz
sssd-9822d4d468ec74e4e173f5adf0db12d02974cd18.tar.bz2
sssd-9822d4d468ec74e4e173f5adf0db12d02974cd18.zip
Read mpg state for subdomains from cache
The mpg flag will be read from the cache for subdomains and the domain object will be created accordingly.
Diffstat (limited to 'src')
-rw-r--r--src/db/sysdb_subdomains.c24
-rw-r--r--src/tests/sysdb-tests.c9
-rw-r--r--src/util/domain_info_utils.c5
-rw-r--r--src/util/util.h3
4 files changed, 30 insertions, 11 deletions
diff --git a/src/db/sysdb_subdomains.c b/src/db/sysdb_subdomains.c
index ef248ff2..58df4701 100644
--- a/src/db/sysdb_subdomains.c
+++ b/src/db/sysdb_subdomains.c
@@ -33,9 +33,15 @@ errno_t sysdb_update_subdomains(struct sss_domain_info *domain)
SYSDB_SUBDOMAIN_REALM,
SYSDB_SUBDOMAIN_FLAT,
SYSDB_SUBDOMAIN_ID,
+ SYSDB_SUBDOMAIN_MPG,
NULL};
struct sss_domain_info *dom;
struct ldb_dn *basedn;
+ const char *name;
+ const char *realm;
+ const char *flat;
+ const char *id;
+ bool mpg;
tmp_ctx = talloc_new(NULL);
if (tmp_ctx == NULL) {
@@ -68,10 +74,6 @@ errno_t sysdb_update_subdomains(struct sss_domain_info *domain)
}
for (i = 0; i < res->count; i++) {
- const char *name;
- const char *realm;
- const char *flat;
- const char *id;
name = ldb_msg_find_attr_as_string(res->msgs[i], "cn", NULL);
if (name == NULL) {
@@ -91,6 +93,9 @@ errno_t sysdb_update_subdomains(struct sss_domain_info *domain)
id = ldb_msg_find_attr_as_string(res->msgs[i],
SYSDB_SUBDOMAIN_ID, NULL);
+ mpg = ldb_msg_find_attr_as_bool(res->msgs[i],
+ SYSDB_SUBDOMAIN_MPG, false);
+
/* explicitly use dom->next as we need to check 'disabled' domains */
for (dom = domain->subdomains; dom; dom = dom->next) {
if (strcasecmp(dom->name, name) == 0) {
@@ -129,12 +134,21 @@ errno_t sysdb_update_subdomains(struct sss_domain_info *domain)
goto done;
}
}
+
+ if (dom->mpg != mpg) {
+ DEBUG(SSSDBG_TRACE_INTERNAL,
+ ("MPG state change from [%s] to [%s]!\n",
+ dom->mpg ? "true" : "false",
+ mpg ? "true" : "false"));
+ dom->mpg = mpg;
+ }
+
break;
}
}
/* If not found in loop it is a new subdomain */
if (dom == NULL) {
- dom = new_subdomain(domain, domain, name, realm, flat, id);
+ dom = new_subdomain(domain, domain, name, realm, flat, id, mpg);
if (dom == NULL) {
ret = ENOMEM;
goto done;
diff --git a/src/tests/sysdb-tests.c b/src/tests/sysdb-tests.c
index 12471179..308230f8 100644
--- a/src/tests/sysdb-tests.c
+++ b/src/tests/sysdb-tests.c
@@ -4540,7 +4540,8 @@ START_TEST(test_sysdb_subdomain_store_user)
fail_if(ret != EOK, "Could not set up the test");
subdomain = new_subdomain(test_ctx, test_ctx->domain,
- testdom[0], testdom[1], testdom[2], testdom[3]);
+ testdom[0], testdom[1], testdom[2], testdom[3],
+ false);
fail_unless(subdomain != NULL, "Failed to create new subdomin.");
ret = sysdb_subdomain_store(test_ctx->sysdb,
testdom[0], testdom[1], testdom[2], testdom[3],
@@ -4598,7 +4599,8 @@ START_TEST(test_sysdb_subdomain_user_ops)
fail_if(ret != EOK, "Could not set up the test");
subdomain = new_subdomain(test_ctx, test_ctx->domain,
- testdom[0], testdom[1], testdom[2], testdom[3]);
+ testdom[0], testdom[1], testdom[2], testdom[3],
+ false);
fail_unless(subdomain != NULL, "Failed to create new subdomin.");
ret = sysdb_subdomain_store(test_ctx->sysdb,
testdom[0], testdom[1], testdom[2], testdom[3],
@@ -4652,7 +4654,8 @@ START_TEST(test_sysdb_subdomain_group_ops)
fail_if(ret != EOK, "Could not set up the test");
subdomain = new_subdomain(test_ctx, test_ctx->domain,
- testdom[0], testdom[1], testdom[2], testdom[3]);
+ testdom[0], testdom[1], testdom[2], testdom[3],
+ false);
fail_unless(subdomain != NULL, "Failed to create new subdomin.");
ret = sysdb_subdomain_store(test_ctx->sysdb,
testdom[0], testdom[1], testdom[2], testdom[3],
diff --git a/src/util/domain_info_utils.c b/src/util/domain_info_utils.c
index ff7a7396..6553927c 100644
--- a/src/util/domain_info_utils.c
+++ b/src/util/domain_info_utils.c
@@ -75,7 +75,8 @@ struct sss_domain_info *new_subdomain(TALLOC_CTX *mem_ctx,
const char *name,
const char *realm,
const char *flat_name,
- const char *id)
+ const char *id,
+ bool mpg)
{
struct sss_domain_info *dom;
@@ -133,7 +134,7 @@ struct sss_domain_info *new_subdomain(TALLOC_CTX *mem_ctx,
dom->enumerate = false;
dom->fqnames = true;
- dom->mpg = true;
+ dom->mpg = mpg;
/* FIXME: get ranges from the server */
dom->id_min = 0;
dom->id_max = 0xffffffff;
diff --git a/src/util/util.h b/src/util/util.h
index f66f57b8..5acc67be 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -562,7 +562,8 @@ struct sss_domain_info *new_subdomain(TALLOC_CTX *mem_ctx,
const char *name,
const char *realm,
const char *flat_name,
- const char *id);
+ const char *id,
+ bool mpg);
errno_t sssd_domain_init(TALLOC_CTX *mem_ctx,
struct confdb_ctx *cdb,