summaryrefslogtreecommitdiffstats
path: root/src/util/domain_info_utils.c
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2013-01-14 20:30:04 -0500
committerJakub Hrozek <jhrozek@redhat.com>2013-02-10 22:08:47 +0100
commitbba1a5fd62cffcae076d1351df5a83fbc4a6ec17 (patch)
tree8dbc22a528ccda8cc889a5297df2edb1919d86e6 /src/util/domain_info_utils.c
parent1f800ebb0f190854b8296146174f3d696a426333 (diff)
downloadsssd-bba1a5fd62cffcae076d1351df5a83fbc4a6ec17.tar.gz
sssd-bba1a5fd62cffcae076d1351df5a83fbc4a6ec17.tar.xz
sssd-bba1a5fd62cffcae076d1351df5a83fbc4a6ec17.zip
Change the way domains are linked.
- Use a double-linked list for domains and subdomains. - Never remove a subdomain, simply mark it as disabled if it becomes unused. - Rework the way subdomains are refreshed. Now sysdb_update_subdomains() actually updates the current subdomains and marks as disabled the ones not found in the sysdb or add new ones found. It never removes them. Removal of missing domains from sysdb is deferred to the providers, which will perform it at refresh time, for the ipa provider that is done by ipa_subdomains_write_mappings() now. sysdb_update_subdomains() is then used to update the memory hierarchy of the subdomains. - Removes sysdb_get_subdomains() - Removes copy_subdomain() - Add sysdb_subdomain_delete()
Diffstat (limited to 'src/util/domain_info_utils.c')
-rw-r--r--src/util/domain_info_utils.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/src/util/domain_info_utils.c b/src/util/domain_info_utils.c
index 59d5c534b..6db7e157a 100644
--- a/src/util/domain_info_utils.c
+++ b/src/util/domain_info_utils.c
@@ -29,8 +29,8 @@ struct sss_domain_info *get_next_domain(struct sss_domain_info *domain,
dom = domain;
while (dom) {
- if (descend && dom->subdomain_count > 0) {
- dom = dom->subdomains[0];
+ if (descend && dom->subdomains) {
+ dom = dom->subdomains;
} else if (dom->next) {
dom = dom->next;
} else if (descend && dom->parent) {
@@ -44,6 +44,27 @@ struct sss_domain_info *get_next_domain(struct sss_domain_info *domain,
return dom;
}
+struct sss_domain_info *find_subdomain_by_name(struct sss_domain_info *domain,
+ const char *name,
+ bool match_any)
+{
+ struct sss_domain_info *dom = domain;
+
+ while (dom && dom->disabled) {
+ dom = get_next_domain(dom, true);
+ }
+ while (dom) {
+ if (strcasecmp(dom->name, name) == 0 ||
+ ((match_any == true) && (dom->flat_name != NULL) &&
+ (strcasecmp(dom->flat_name, name) == 0))) {
+ return dom;
+ }
+ dom = get_next_domain(dom, true);
+ }
+
+ return NULL;
+}
+
struct sss_domain_info *new_subdomain(TALLOC_CTX *mem_ctx,
struct sss_domain_info *parent,
const char *name,
@@ -136,14 +157,6 @@ fail:
return NULL;
}
-struct sss_domain_info *copy_subdomain(TALLOC_CTX *mem_ctx,
- struct sss_domain_info *subdomain)
-{
- return new_subdomain(mem_ctx, subdomain->parent,
- subdomain->name, subdomain->realm,
- subdomain->flat_name, subdomain->domain_id);
-}
-
errno_t sssd_domain_init(TALLOC_CTX *mem_ctx,
struct confdb_ctx *cdb,
const char *domain_name,