summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2013-01-06 03:58:58 -0500
committerJakub Hrozek <jhrozek@redhat.com>2013-01-15 10:49:20 +0100
commit234958be042980242fff6da936af674da877c5ef (patch)
treea2f96f1cf185f950629f0718e9ce69e314c5fada /src/util
parent72aa8e7b1d234b6b68446d42efa1cff22b70c81b (diff)
downloadsssd-234958be042980242fff6da936af674da877c5ef.tar.gz
sssd-234958be042980242fff6da936af674da877c5ef.tar.bz2
sssd-234958be042980242fff6da936af674da877c5ef.zip
Refactor single domain initialization
Bring it out of sysdb, which will slowly remove internal dependencies on domains and instead will always require them to be passed by callers.
Diffstat (limited to 'src/util')
-rw-r--r--src/util/domain_info_utils.c34
-rw-r--r--src/util/util.h6
2 files changed, 40 insertions, 0 deletions
diff --git a/src/util/domain_info_utils.c b/src/util/domain_info_utils.c
index a6aa5c73..cee11eb5 100644
--- a/src/util/domain_info_utils.c
+++ b/src/util/domain_info_utils.c
@@ -112,3 +112,37 @@ struct sss_domain_info *copy_subdomain(TALLOC_CTX *mem_ctx,
return new_subdomain(mem_ctx, subdomain->parent, subdomain->name,
subdomain->flat_name, subdomain->domain_id);
}
+
+errno_t sssd_domain_init(TALLOC_CTX *mem_ctx,
+ struct confdb_ctx *cdb,
+ const char *domain_name,
+ const char *db_path,
+ struct sss_domain_info **_domain)
+{
+ int ret;
+ struct sss_domain_info *dom;
+ struct sysdb_ctx *sysdb;
+
+ ret = confdb_get_domain(cdb, domain_name, &dom);
+ if (ret != EOK) {
+ DEBUG(SSSDBG_OP_FAILURE, ("Error retrieving domain configuration.\n"));
+ return ret;
+ }
+
+ if (dom->sysdb != NULL) {
+ DEBUG(SSSDBG_OP_FAILURE, ("Sysdb context already initialized.\n"));
+ return EEXIST;
+ }
+
+ ret = sysdb_domain_init(mem_ctx, dom, db_path, &sysdb);
+ if (ret != EOK) {
+ DEBUG(SSSDBG_OP_FAILURE, ("Error opening cache database.\n"));
+ return ret;
+ }
+
+ dom->sysdb = talloc_steal(dom, sysdb);
+
+ *_domain = dom;
+
+ return EOK;
+}
diff --git a/src/util/util.h b/src/util/util.h
index cc5a2baf..df1ee3b0 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -574,6 +574,12 @@ struct sss_domain_info *new_subdomain(TALLOC_CTX *mem_ctx,
struct sss_domain_info *copy_subdomain(TALLOC_CTX *mem_ctx,
struct sss_domain_info *subdomain);
+errno_t sssd_domain_init(TALLOC_CTX *mem_ctx,
+ struct confdb_ctx *cdb,
+ const char *domain_name,
+ const char *db_path,
+ struct sss_domain_info **_domain);
+
/* from util_lock.c */
errno_t sss_br_lock_file(int fd, size_t start, size_t len,
int num_tries, useconds_t wait);