summaryrefslogtreecommitdiff
path: root/server/responder/common
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2009-02-27 13:35:33 -0500
committerSimo Sorce <ssorce@redhat.com>2009-02-27 17:11:23 -0500
commit24480f7fa3bf3f40bd9fb7c865f9e3b329bf3ed8 (patch)
tree735441471a4e8c5fcc2dd9b9311b000f44584e29 /server/responder/common
parent60bbc5034e546b7df7a6f782e3353b863f49618b (diff)
downloadsssd-24480f7fa3bf3f40bd9fb7c865f9e3b329bf3ed8.tar.gz
sssd-24480f7fa3bf3f40bd9fb7c865f9e3b329bf3ed8.tar.bz2
sssd-24480f7fa3bf3f40bd9fb7c865f9e3b329bf3ed8.zip
Refactor creation of domain_map into confdb
The NSS provider, the Data Provider backends and the InfoPipe all need access to the domain map provided by the confdb. Instead of reimplimenting it in multiple places, it is now provided in a pair of helper functions from the confdb. confdb_get_domains() returns a domain map by reference. Always returns the most up-to-date set of domains from the confdb. confdb_get_domains_list() returns an array of strings of all the domain names. Always returns the most up-to-date set of domains from the confdb. This patch also modifies the btreemap_get_keys() function to better handle memory and report allocation failures.
Diffstat (limited to 'server/responder/common')
-rw-r--r--server/responder/common/responder_common.c71
1 files changed, 3 insertions, 68 deletions
diff --git a/server/responder/common/responder_common.c b/server/responder/common/responder_common.c
index 74e03215..f532102f 100644
--- a/server/responder/common/responder_common.c
+++ b/server/responder/common/responder_common.c
@@ -319,85 +319,20 @@ failed:
return EIO;
}
-/* domain names are case insensitive for now
- * NOTE: this function is not utf-8 safe,
- * only ASCII names for now */
-static int _domain_comparator(const void *key1, const void *key2)
-{
- return strcasecmp((const char *)key1, (const char *)key2);
-}
-
static int sss_init_domains(struct nss_ctx *nctx)
{
- char *path;
- char **domains;
- char *provider;
TALLOC_CTX *tmp_ctx;
- struct nss_domain_info *info;
- int ret, i, c;
+ int ret;
int retval;
tmp_ctx = talloc_new(nctx);
- ret = confdb_get_domains(nctx->cdb, tmp_ctx, &domains);
+ ret = confdb_get_domains(nctx->cdb, nctx, &nctx->domain_map);
if (ret != EOK) {
retval = ret;
goto done;
}
- i = 0;
- c = 0;
- while (domains[i] != NULL) {
- DEBUG(3, ("Adding domain %s to the map\n", domains[i]));
-
- path = talloc_asprintf(tmp_ctx, "config/domains/%s", domains[i]);
- if (!path) {
- retval = ENOMEM;
- goto done;
- }
-
- /* alloc on tmp_ctx, it will be stolen by btreemap_set_value */
- info = talloc_zero(tmp_ctx, struct nss_domain_info);
- if (!info) {
- retval = ENOMEM;
- goto done;
- }
-
- /* Build the basedn for this domain */
- info->basedn = talloc_asprintf(info, SYSDB_DOM_BASE, domains[i]);
- DEBUG(3, ("BaseDN: %s\n", info->basedn));
-
- ret = confdb_get_int(nctx->cdb, tmp_ctx, path,
- "enumerate", false, &(info->enumerate));
- if (ret != EOK) {
- DEBUG(0, ("Failed to fetch enumerate for [%s]!\n", domains[i]));
- }
-
- ret = confdb_get_bool(nctx->cdb, tmp_ctx, path,
- "legacy", false, &(info->legacy));
- if (ret != EOK) {
- DEBUG(0, ("Failed to fetch legacy for [%s]!\n", domains[i]));
- }
-
- ret = confdb_get_string(nctx->cdb, tmp_ctx, path, "provider",
- NULL, &provider);
- if (ret != EOK) {
- DEBUG(0, ("Failed to fetch provider for [%s]!\n", domains[i]));
- }
- if (provider) info->has_provider = true;
-
- ret = btreemap_set_value(nctx, &nctx->domain_map,
- domains[i], info,
- _domain_comparator);
- if (ret != EOK) {
- DEBUG(1, ("Failed to store domain info, aborting!\n"));
- retval = ret;
- goto done;
- }
-
- i++;
- c++;
- }
- if (c == 0) {
+ if (nctx->domain_map == NULL) {
/* No domains configured!
* Note: this should never happen, since LOCAL should
* always be configured */