summaryrefslogtreecommitdiffstats
path: root/src/db
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2012-07-19 19:15:57 -0400
committerJakub Hrozek <jhrozek@redhat.com>2012-08-01 22:24:44 +0200
commit204cfc89a076fd32bf34f2abb3f809304aaa88ab (patch)
tree908b05e88f0648b5e22b334f6ea3de53eb139bc0 /src/db
parent067bfcaad9baae2d962528839fde30ebd1a5ba2b (diff)
downloadsssd-204cfc89a076fd32bf34f2abb3f809304aaa88ab.tar.gz
sssd-204cfc89a076fd32bf34f2abb3f809304aaa88ab.tar.xz
sssd-204cfc89a076fd32bf34f2abb3f809304aaa88ab.zip
Add realm paramter to subdomain list
This will be used later for setting domain_realm mappings in krb5.conf
Diffstat (limited to 'src/db')
-rw-r--r--src/db/sysdb.h8
-rw-r--r--src/db/sysdb_subdomains.c58
2 files changed, 63 insertions, 3 deletions
diff --git a/src/db/sysdb.h b/src/db/sysdb.h
index 20641a753..0e2404c70 100644
--- a/src/db/sysdb.h
+++ b/src/db/sysdb.h
@@ -142,6 +142,7 @@
#define SYSDB_SSH_PUBKEY "sshPublicKey"
+#define SYSDB_SUBDOMAIN_REALM "realmName"
#define SYSDB_SUBDOMAIN_FLAT "flatName"
#define SYSDB_SUBDOMAIN_ID "domainID"
@@ -241,9 +242,10 @@ struct sysdb_attrs {
struct sysdb_attrs *sysdb_new_attrs(TALLOC_CTX *mem_ctx);
struct sysdb_subdom {
- char *name;
- char *flat_name;
- char *id;
+ const char *realm;
+ const char *name;
+ const char *flat_name;
+ const char *id;
};
struct range_info {
diff --git a/src/db/sysdb_subdomains.c b/src/db/sysdb_subdomains.c
index 533874f66..8f1df88be 100644
--- a/src/db/sysdb_subdomains.c
+++ b/src/db/sysdb_subdomains.c
@@ -32,6 +32,7 @@ errno_t sysdb_get_subdomains(TALLOC_CTX *mem_ctx, struct sysdb_ctx *sysdb,
TALLOC_CTX *tmp_ctx;
struct ldb_result *res;
const char *attrs[] = {"cn",
+ SYSDB_SUBDOMAIN_REALM,
SYSDB_SUBDOMAIN_FLAT,
SYSDB_SUBDOMAIN_ID,
NULL};
@@ -86,6 +87,16 @@ errno_t sysdb_get_subdomains(TALLOC_CTX *mem_ctx, struct sysdb_ctx *sysdb,
}
tmp_str = ldb_msg_find_attr_as_string(res->msgs[i],
+ SYSDB_SUBDOMAIN_REALM, NULL);
+ if (tmp_str != NULL) {
+ list[i]->realm = talloc_strdup(list, tmp_str);
+ if (list[i]->realm == NULL) {
+ ret = ENOMEM;
+ goto done;
+ }
+ }
+
+ tmp_str = ldb_msg_find_attr_as_string(res->msgs[i],
SYSDB_SUBDOMAIN_FLAT, NULL);
if (tmp_str != NULL) {
list[i]->flat_name = talloc_strdup(list, tmp_str);
@@ -126,6 +137,7 @@ errno_t sysdb_master_domain_get_info(TALLOC_CTX *mem_ctx,
struct sysdb_subdom *info;
struct ldb_result *res;
const char *attrs[] = {"cn",
+ SYSDB_SUBDOMAIN_REALM,
SYSDB_SUBDOMAIN_FLAT,
SYSDB_SUBDOMAIN_ID,
NULL};
@@ -166,6 +178,16 @@ errno_t sysdb_master_domain_get_info(TALLOC_CTX *mem_ctx,
goto done;
}
+ tmp_str = ldb_msg_find_attr_as_string(res->msgs[0], SYSDB_SUBDOMAIN_REALM,
+ NULL);
+ if (tmp_str != NULL) {
+ info->realm = talloc_strdup(info, tmp_str);
+ if (info->realm == NULL) {
+ ret = ENOMEM;
+ goto done;
+ }
+ }
+
tmp_str = ldb_msg_find_attr_as_string(res->msgs[0], SYSDB_SUBDOMAIN_FLAT,
NULL);
if (tmp_str != NULL) {
@@ -224,6 +246,26 @@ errno_t sysdb_master_domain_add_info(struct sysdb_ctx *sysdb,
goto done;
}
+ if (domain_info->realm != NULL &&
+ (current_info->realm == NULL ||
+ strcmp(current_info->realm, domain_info->realm) != 0) ) {
+ ret = ldb_msg_add_empty(msg, SYSDB_SUBDOMAIN_REALM,
+ 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_REALM,
+ domain_info->realm);
+ if (ret != LDB_SUCCESS) {
+ ret = sysdb_error_to_errno(ret);
+ goto done;
+ }
+
+ do_update = true;
+ }
+
if (domain_info->flat_name != NULL &&
(current_info->flat_name == NULL ||
strcmp(current_info->flat_name, domain_info->flat_name) != 0) ) {
@@ -322,6 +364,22 @@ static errno_t sysdb_add_subdomain_attributes(struct sysdb_ctx *sysdb,
goto done;
}
+ if (domain_info->realm != NULL) {
+ ret = ldb_msg_add_empty(msg, SYSDB_SUBDOMAIN_REALM, LDB_FLAG_MOD_ADD,
+ NULL);
+ if (ret != LDB_SUCCESS) {
+ ret = sysdb_error_to_errno(ret);
+ goto done;
+ }
+
+ ret = ldb_msg_add_string(msg, SYSDB_SUBDOMAIN_REALM,
+ domain_info->realm);
+ if (ret != LDB_SUCCESS) {
+ ret = sysdb_error_to_errno(ret);
+ goto done;
+ }
+ }
+
if (domain_info->flat_name != NULL) {
ret = ldb_msg_add_empty(msg, SYSDB_SUBDOMAIN_FLAT, LDB_FLAG_MOD_ADD,
NULL);