summaryrefslogtreecommitdiffstats
path: root/server/confdb
diff options
context:
space:
mode:
authorSimo Sorce <ssorce@redhat.com>2009-09-03 19:29:41 -0400
committerStephen Gallagher <sgallagh@redhat.com>2009-09-08 15:10:50 -0400
commit28d9dcbeabdf919506fe59e9d1cbed84fbd6e649 (patch)
tree3d5d878b1adc0ec8af94a52359d219689c763bd8 /server/confdb
parentaef967dc115c64f0288b8ecc3ff1d927aa42af70 (diff)
downloadsssd-28d9dcbeabdf919506fe59e9d1cbed84fbd6e649.tar.gz
sssd-28d9dcbeabdf919506fe59e9d1cbed84fbd6e649.tar.xz
sssd-28d9dcbeabdf919506fe59e9d1cbed84fbd6e649.zip
Split database in multiple files
The special persistent local database retains the original name. All other backends now have their own cache-NAME.ldb file.
Diffstat (limited to 'server/confdb')
-rw-r--r--server/confdb/confdb.c52
-rw-r--r--server/confdb/confdb.h2
-rw-r--r--server/confdb/confdb_private.h2
3 files changed, 41 insertions, 15 deletions
diff --git a/server/confdb/confdb.c b/server/confdb/confdb.c
index 72e5eeb42..7d89f75f2 100644
--- a/server/confdb/confdb.c
+++ b/server/confdb/confdb.c
@@ -673,10 +673,10 @@ int confdb_init(TALLOC_CTX *mem_ctx,
return EOK;
}
-int confdb_get_domain(struct confdb_ctx *cdb,
- TALLOC_CTX *mem_ctx,
- const char *name,
- struct sss_domain_info **_domain)
+static int confdb_get_domain_internal(struct confdb_ctx *cdb,
+ TALLOC_CTX *mem_ctx,
+ const char *name,
+ struct sss_domain_info **_domain)
{
struct sss_domain_info *domain;
struct ldb_result *res;
@@ -803,16 +803,19 @@ done:
}
int confdb_get_domains(struct confdb_ctx *cdb,
- TALLOC_CTX *mem_ctx,
struct sss_domain_info **domains)
{
TALLOC_CTX *tmp_ctx;
struct sss_domain_info *domain, *prevdom = NULL;
- struct sss_domain_info *first = NULL;
char **domlist;
int ret, i;
- tmp_ctx = talloc_new(mem_ctx);
+ if (cdb->doms) {
+ *domains = cdb->doms;
+ return EOK;
+ }
+
+ tmp_ctx = talloc_new(NULL);
if (!tmp_ctx) return ENOMEM;
ret = confdb_get_string_as_list(cdb, tmp_ctx,
@@ -827,7 +830,7 @@ int confdb_get_domains(struct confdb_ctx *cdb,
}
for (i = 0; domlist[i]; i++) {
- ret = confdb_get_domain(cdb, mem_ctx, domlist[i], &domain);
+ ret = confdb_get_domain_internal(cdb, cdb, domlist[i], &domain);
if (ret) {
DEBUG(0, ("Error (%d [%s]) retrieving domain [%s], skipping!\n",
ret, strerror(ret), domlist[i]));
@@ -835,23 +838,46 @@ int confdb_get_domains(struct confdb_ctx *cdb,
continue;
}
- if (first == NULL) {
- first = domain;
- prevdom = first;
+ if (cdb->doms == NULL) {
+ cdb->doms = domain;
+ prevdom = cdb->doms;
} else {
prevdom->next = domain;
prevdom = domain;
}
}
- if (first == NULL) {
+ if (cdb->doms == NULL) {
DEBUG(0, ("No domains configured, fatal error!\n"));
ret = ENOENT;
}
- *domains = first;
+ *domains = cdb->doms;
+ ret = EOK;
done:
talloc_free(tmp_ctx);
return ret;
}
+
+int confdb_get_domain(struct confdb_ctx *cdb,
+ const char *name,
+ struct sss_domain_info **_domain)
+{
+ struct sss_domain_info *dom, *doms;
+ int ret;
+
+ ret = confdb_get_domains(cdb, &doms);
+ if (ret != EOK) {
+ return ret;
+ }
+
+ for (dom = doms; dom; dom = dom->next) {
+ if (strcasecmp(dom->name, name) == 0) {
+ *_domain = dom;
+ return EOK;
+ }
+ }
+
+ return ENOENT;
+}
diff --git a/server/confdb/confdb.h b/server/confdb/confdb.h
index f56508877..d325ac8fb 100644
--- a/server/confdb/confdb.h
+++ b/server/confdb/confdb.h
@@ -91,12 +91,10 @@ int confdb_init(TALLOC_CTX *mem_ctx,
char *confdb_location);
int confdb_get_domain(struct confdb_ctx *cdb,
- TALLOC_CTX *mem_ctx,
const char *name,
struct sss_domain_info **domain);
int confdb_get_domains(struct confdb_ctx *cdb,
- TALLOC_CTX *mem_ctx,
struct sss_domain_info **domains);
#endif
diff --git a/server/confdb/confdb_private.h b/server/confdb/confdb_private.h
index 41fcd2692..1bab99cae 100644
--- a/server/confdb/confdb_private.h
+++ b/server/confdb/confdb_private.h
@@ -25,6 +25,8 @@
struct confdb_ctx {
struct tevent_context *pev;
struct ldb_context *ldb;
+
+ struct sss_domain_info *doms;
};
int parse_section(TALLOC_CTX *mem_ctx, const char *section,