summaryrefslogtreecommitdiff
path: root/src/db
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2013-01-14 13:43:52 -0500
committerJakub Hrozek <jhrozek@redhat.com>2013-02-10 22:08:46 +0100
commit3912262270a6449ebe1d3e92c27c217b4044f894 (patch)
tree5999eab4674cd655112922e5b59acff39684b3cb /src/db
parent65393a294e635822c1d7a15fe5853dc457ad8a2a (diff)
downloadsssd-3912262270a6449ebe1d3e92c27c217b4044f894.tar.gz
sssd-3912262270a6449ebe1d3e92c27c217b4044f894.tar.bz2
sssd-3912262270a6449ebe1d3e92c27c217b4044f894.zip
Refactor sysdb_master_domain_add_info()
Diffstat (limited to 'src/db')
-rw-r--r--src/db/sysdb.h6
-rw-r--r--src/db/sysdb_subdomains.c43
2 files changed, 22 insertions, 27 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)
{