summaryrefslogtreecommitdiffstats
path: root/src/responder/common/responder_common.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/responder/common/responder_common.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/responder/common/responder_common.c')
-rw-r--r--src/responder/common/responder_common.c31
1 files changed, 11 insertions, 20 deletions
diff --git a/src/responder/common/responder_common.c b/src/responder/common/responder_common.c
index 3a634e03b..877181f8d 100644
--- a/src/responder/common/responder_common.c
+++ b/src/responder/common/responder_common.c
@@ -886,41 +886,32 @@ int sss_dp_get_domain_conn(struct resp_ctx *rctx, const char *domain,
struct sss_domain_info *
responder_get_domain(TALLOC_CTX *sd_mem_ctx, struct resp_ctx *rctx,
- const char *domain)
+ const char *name)
{
time_t now = time(NULL);
time_t time_diff;
struct sss_domain_info *dom;
struct sss_domain_info *ret_dom = NULL;
- int i;
- for (dom = rctx->domains; dom; dom = get_next_domain(dom, false)) {
- if (strcasecmp(dom->name, domain) == 0 ||
+ for (dom = rctx->domains; dom; dom = get_next_domain(dom, true)) {
+ if (!dom->parent) {
+ time_diff = now - dom->subdomains_last_checked.tv_sec;
+ }
+ if (strcasecmp(dom->name, name) == 0 ||
(dom->flat_name != NULL &&
- strcasecmp(dom->flat_name, domain) == 0)) {
+ strcasecmp(dom->flat_name, name) == 0)) {
ret_dom = dom;
- break;
- }
-
- for (i = 0; i < dom->subdomain_count; i++) {
- if (strcasecmp(dom->subdomains[i]->name, domain) == 0 ||
- (dom->subdomains[i]->flat_name != NULL &&
- strcasecmp(dom->subdomains[i]->flat_name, domain) == 0)) {
- /* Sub-domains may come and go, so we better copy the struct
- * for each request. */
- ret_dom = copy_subdomain(sd_mem_ctx, dom->subdomains[i]);
+ if (!dom->parent ||
+ (dom->parent && time_diff < rctx->domains_timeout)) {
break;
}
}
- time_diff = now - dom->subdomains_last_checked.tv_sec;
- if (i < dom->subdomain_count && time_diff < rctx->domains_timeout) break;
}
- /* FIXME: we might want to return a real error, e.g. if copy_subdomain
- * fails. */
+
if (!ret_dom) {
DEBUG(SSSDBG_OP_FAILURE, ("Unknown domain [%s], checking for"
- "possible subdomains!\n", domain));
+ "possible subdomains!\n", name));
}
return ret_dom;