summaryrefslogtreecommitdiffstats
path: root/src/db/sysdb_subdomains.c
diff options
context:
space:
mode:
authorSumit Bose <sbose@redhat.com>2013-06-27 21:49:26 +0200
committerJakub Hrozek <jhrozek@redhat.com>2013-06-28 20:20:59 +0200
commit09d7c105839bfc7447ea0f766413ed86675ca075 (patch)
tree382c007bb5182e17af6243f67fd06e08627aad82 /src/db/sysdb_subdomains.c
parent20ccfd63a17dc15dd24e6543424d86913d511c4b (diff)
downloadsssd-09d7c105839bfc7447ea0f766413ed86675ca075.tar.gz
sssd-09d7c105839bfc7447ea0f766413ed86675ca075.tar.xz
sssd-09d7c105839bfc7447ea0f766413ed86675ca075.zip
Save mpg state for subdomains
The information of a subdomain will use magic private groups (mpg) or not will be stored together with other information about the domain in the cache.
Diffstat (limited to 'src/db/sysdb_subdomains.c')
-rw-r--r--src/db/sysdb_subdomains.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/src/db/sysdb_subdomains.c b/src/db/sysdb_subdomains.c
index 3e0d7b40a..ef248ff24 100644
--- a/src/db/sysdb_subdomains.c
+++ b/src/db/sysdb_subdomains.c
@@ -346,7 +346,8 @@ done:
errno_t sysdb_subdomain_store(struct sysdb_ctx *sysdb,
const char *name, const char *realm,
- const char *flat_name, const char *domain_id)
+ const char *flat_name, const char *domain_id,
+ bool mpg)
{
TALLOC_CTX *tmp_ctx;
struct ldb_message *msg;
@@ -356,12 +357,15 @@ errno_t sysdb_subdomain_store(struct sysdb_ctx *sysdb,
SYSDB_SUBDOMAIN_REALM,
SYSDB_SUBDOMAIN_FLAT,
SYSDB_SUBDOMAIN_ID,
+ SYSDB_SUBDOMAIN_MPG,
NULL};
const char *tmp_str;
+ bool tmp_bool;
bool store = false;
int realm_flags = 0;
int flat_flags = 0;
int id_flags = 0;
+ int mpg_flags = 0;
int ret;
tmp_ctx = talloc_new(NULL);
@@ -390,6 +394,7 @@ errno_t sysdb_subdomain_store(struct sysdb_ctx *sysdb,
if (realm) realm_flags = LDB_FLAG_MOD_ADD;
if (flat_name) flat_flags = LDB_FLAG_MOD_ADD;
if (domain_id) id_flags = LDB_FLAG_MOD_ADD;
+ mpg_flags = LDB_FLAG_MOD_ADD;
} else if (res->count != 1) {
ret = EINVAL;
goto done;
@@ -415,9 +420,16 @@ errno_t sysdb_subdomain_store(struct sysdb_ctx *sysdb,
id_flags = LDB_FLAG_MOD_REPLACE;
}
}
+
+ tmp_bool = ldb_msg_find_attr_as_bool(res->msgs[0], SYSDB_SUBDOMAIN_MPG,
+ !mpg);
+ if (tmp_bool != mpg) {
+ mpg_flags = LDB_FLAG_MOD_REPLACE;
+ }
}
- if (!store && realm_flags == 0 && flat_flags == 0 && id_flags == 0) {
+ if (!store && realm_flags == 0 && flat_flags == 0 && id_flags == 0
+ && mpg_flags == 0) {
ret = EOK;
goto done;
}
@@ -429,7 +441,7 @@ errno_t sysdb_subdomain_store(struct sysdb_ctx *sysdb,
}
msg->dn = dn;
- if (store) {
+ if (store) {
ret = ldb_msg_add_empty(msg, SYSDB_OBJECTCLASS, LDB_FLAG_MOD_ADD, NULL);
if (ret != LDB_SUCCESS) {
ret = sysdb_error_to_errno(ret);
@@ -485,6 +497,21 @@ errno_t sysdb_subdomain_store(struct sysdb_ctx *sysdb,
}
}
+ if (mpg_flags) {
+ ret = ldb_msg_add_empty(msg, SYSDB_SUBDOMAIN_MPG, mpg_flags, NULL);
+ if (ret != LDB_SUCCESS) {
+ ret = sysdb_error_to_errno(ret);
+ goto done;
+ }
+
+ ret = ldb_msg_add_string(msg, SYSDB_SUBDOMAIN_MPG,
+ mpg ? "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 "