summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2013-01-15 22:19:36 -0500
committerJakub Hrozek <jhrozek@redhat.com>2013-02-10 22:08:47 +0100
commit4f118e3e6a25762f40a43e6dbefb09f44adbef32 (patch)
tree35e3eed19b3b462cc94f6aee0050562a7d37e6a8
parentbfba0655bc129ebcffc20b1204e0f87549e0a74e (diff)
downloadsssd-4f118e3e6a25762f40a43e6dbefb09f44adbef32.tar.gz
sssd-4f118e3e6a25762f40a43e6dbefb09f44adbef32.tar.bz2
sssd-4f118e3e6a25762f40a43e6dbefb09f44adbef32.zip
Introduce IS_SUBDOMAIN() macro
Fixes https://fedorahosted.org/sssd/ticket/1766
-rw-r--r--src/db/sysdb_search.c4
-rw-r--r--src/providers/ipa/ipa_subdomains.c4
-rw-r--r--src/responder/common/responder_common.c6
-rw-r--r--src/responder/common/responder_get_domains.c2
-rw-r--r--src/responder/nss/nsssrv_cmd.c6
-rw-r--r--src/responder/pac/pacsrv_cmd.c2
-rw-r--r--src/util/domain_info_utils.c2
-rw-r--r--src/util/util.h2
8 files changed, 15 insertions, 13 deletions
diff --git a/src/db/sysdb_search.c b/src/db/sysdb_search.c
index 8ff29c37..3226acc6 100644
--- a/src/db/sysdb_search.c
+++ b/src/db/sysdb_search.c
@@ -55,7 +55,7 @@ int sysdb_getpwnam(TALLOC_CTX *mem_ctx,
/* If this is a subomain we need to use fully qualified names for the
* search as well by default */
- if (domain->parent && domain->fqnames) {
+ if (IS_SUBDOMAIN(domain) && domain->fqnames) {
ret = ENOMEM;
src_name = talloc_asprintf(tmp_ctx, domain->names->fq_fmt,
name, domain->name);
@@ -243,7 +243,7 @@ int sysdb_getgrnam(TALLOC_CTX *mem_ctx,
/* If this is a subomain we need to use fully qualified names for the
* search as well by default */
- if (domain->parent && domain->fqnames) {
+ if (IS_SUBDOMAIN(domain) && domain->fqnames) {
ret = ENOMEM;
src_name = talloc_asprintf(tmp_ctx, domain->names->fq_fmt,
name, domain->name);
diff --git a/src/providers/ipa/ipa_subdomains.c b/src/providers/ipa/ipa_subdomains.c
index deee153b..28811ae7 100644
--- a/src/providers/ipa/ipa_subdomains.c
+++ b/src/providers/ipa/ipa_subdomains.c
@@ -301,7 +301,7 @@ ipa_subdomains_write_mappings(struct sss_domain_info *domain)
}
for (dom = get_next_domain(domain, true);
- dom && dom->parent; /* if we get back to a parent, stop */
+ dom && IS_SUBDOMAIN(dom); /* if we get back to a parent, stop */
dom = get_next_domain(dom, false)) {
ret = fprintf(fstream, ".%s = %s\n%s = %s\n",
dom->name, dom->realm, dom->name, dom->realm);
@@ -379,7 +379,7 @@ static errno_t ipa_subdomains_refresh(struct ipa_subdomains_ctx *ctx,
/* check existing subdomains */
for (dom = get_next_domain(domain, true);
- dom && dom->parent;
+ dom && IS_SUBDOMAIN(dom); /* if we get back to a parent, stop */
dom = get_next_domain(dom, false)) {
for (c = 0; c < count; c++) {
if (handled[c]) {
diff --git a/src/responder/common/responder_common.c b/src/responder/common/responder_common.c
index 877181f8..c7aead3e 100644
--- a/src/responder/common/responder_common.c
+++ b/src/responder/common/responder_common.c
@@ -894,15 +894,15 @@ responder_get_domain(TALLOC_CTX *sd_mem_ctx, struct resp_ctx *rctx,
struct sss_domain_info *ret_dom = NULL;
for (dom = rctx->domains; dom; dom = get_next_domain(dom, true)) {
- if (!dom->parent) {
+ if (!IS_SUBDOMAIN(dom)) {
time_diff = now - dom->subdomains_last_checked.tv_sec;
}
if (strcasecmp(dom->name, name) == 0 ||
(dom->flat_name != NULL &&
strcasecmp(dom->flat_name, name) == 0)) {
ret_dom = dom;
- if (!dom->parent ||
- (dom->parent && time_diff < rctx->domains_timeout)) {
+ if (!IS_SUBDOMAIN(dom) ||
+ (IS_SUBDOMAIN(dom) && time_diff < rctx->domains_timeout)) {
break;
}
}
diff --git a/src/responder/common/responder_get_domains.c b/src/responder/common/responder_get_domains.c
index b69875e1..defa4a43 100644
--- a/src/responder/common/responder_get_domains.c
+++ b/src/responder/common/responder_get_domains.c
@@ -353,7 +353,7 @@ static errno_t check_last_request(struct resp_ctx *rctx, const char *hint)
if (hint != NULL) {
for (dom = rctx->domains; dom; dom = get_next_domain(dom, true)) {
- if (dom->parent == NULL) {
+ if (!IS_SUBDOMAIN(dom)) {
diff = now - dom->subdomains_last_checked.tv_sec;
/* not a subdomain */
continue;
diff --git a/src/responder/nss/nsssrv_cmd.c b/src/responder/nss/nsssrv_cmd.c
index 76b79ceb..12587ded 100644
--- a/src/responder/nss/nsssrv_cmd.c
+++ b/src/responder/nss/nsssrv_cmd.c
@@ -298,7 +298,7 @@ static int fill_pwent(struct sss_packet *packet,
size_t dom_len = 0;
int delim = 1;
int i, ret, num, t;
- bool add_domain = (dom->fqnames && (dom->parent == NULL));
+ bool add_domain = (!IS_SUBDOMAIN(dom) && dom->fqnames);
const char *domain = dom->name;
const char *namefmt;
bool packet_initialized = false;
@@ -1903,7 +1903,7 @@ static int fill_members(struct sss_packet *packet,
size_t blen;
const char *domain = dom->name;
- bool add_domain = (dom->fqnames && (dom->parent == NULL));
+ bool add_domain = (!IS_SUBDOMAIN(dom) && dom->fqnames);
if (add_domain) {
delim = 1;
@@ -2032,7 +2032,7 @@ static int fill_grent(struct sss_packet *packet,
int i = 0;
int ret, num, memnum;
size_t rzero, rsize;
- bool add_domain = (dom->fqnames && (dom->parent == NULL));
+ bool add_domain = (!IS_SUBDOMAIN(dom) && dom->fqnames);
const char *domain = dom->name;
const char *namefmt;
TALLOC_CTX *tmp_ctx = NULL;
diff --git a/src/responder/pac/pacsrv_cmd.c b/src/responder/pac/pacsrv_cmd.c
index aeb41847..a8191bb9 100644
--- a/src/responder/pac/pacsrv_cmd.c
+++ b/src/responder/pac/pacsrv_cmd.c
@@ -453,7 +453,7 @@ struct tevent_req *pac_save_memberships_send(struct pac_req_ctx *pr_ctx)
state->pr_ctx = pr_ctx;
/* Remote users are members of local groups */
- if (pr_ctx->dom->parent != NULL) {
+ if (IS_SUBDOMAIN(pr_ctx->dom)) {
state->group_dom = pr_ctx->dom->parent;
} else {
state->group_dom = pr_ctx->dom;
diff --git a/src/util/domain_info_utils.c b/src/util/domain_info_utils.c
index 6db7e157..d8ca55da 100644
--- a/src/util/domain_info_utils.c
+++ b/src/util/domain_info_utils.c
@@ -33,7 +33,7 @@ struct sss_domain_info *get_next_domain(struct sss_domain_info *domain,
dom = dom->subdomains;
} else if (dom->next) {
dom = dom->next;
- } else if (descend && dom->parent) {
+ } else if (descend && IS_SUBDOMAIN(dom)) {
dom = dom->parent->next;
} else {
return NULL;
diff --git a/src/util/util.h b/src/util/util.h
index 7697dbb5..7026f0b9 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -585,6 +585,8 @@ errno_t sssd_domain_init(TALLOC_CTX *mem_ctx,
const char *db_path,
struct sss_domain_info **_domain);
+#define IS_SUBDOMAIN(dom) ((dom)->parent != NULL)
+
/* from util_lock.c */
errno_t sss_br_lock_file(int fd, size_t start, size_t len,
int num_tries, useconds_t wait);