summaryrefslogtreecommitdiff
path: root/src/responder
diff options
context:
space:
mode:
authorSumit Bose <sbose@redhat.com>2012-02-15 06:14:26 -0500
committerStephen Gallagher <sgallagh@redhat.com>2012-04-24 09:19:43 -0400
commit10894343a975174b7efe5a178641df71c7ef9f57 (patch)
treede2de0c872baf686b7f35318f3a29fa4c4f531c2 /src/responder
parent3d715363a3bfac489b7500dd70de6b6bdc7aa405 (diff)
downloadsssd-10894343a975174b7efe5a178641df71c7ef9f57.tar.gz
sssd-10894343a975174b7efe5a178641df71c7ef9f57.tar.bz2
sssd-10894343a975174b7efe5a178641df71c7ef9f57.zip
Check sub-domains in nss_cmd_get{pwuid|grgid}_search()
Diffstat (limited to 'src/responder')
-rw-r--r--src/responder/nss/nsssrv_cmd.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/src/responder/nss/nsssrv_cmd.c b/src/responder/nss/nsssrv_cmd.c
index 84aa98d2..da3fa6fd 100644
--- a/src/responder/nss/nsssrv_cmd.c
+++ b/src/responder/nss/nsssrv_cmd.c
@@ -974,6 +974,28 @@ static void nss_cmd_getpwuid_dp_callback(uint16_t err_maj, uint32_t err_min,
* anything else on a fatal error
*/
+struct sss_domain_info *get_next_dom_or_subdom(struct sss_domain_info *dom)
+{
+ /* Note that we don't know if the dom is a domain or a subdomain,
+ * therefore:
+ *
+ * If it is a subdomain and it doesn't have any siblings (subdomains
+ * of the same primary domain), return next primary domain
+ */
+ if (dom->next == NULL && dom->parent != NULL) {
+ return dom->parent->next;
+ }
+
+ /* If it's primary domain, the next returned should be its first
+ * subdomain */
+ if (dom->subdomains != NULL) {
+ return dom->subdomains[0];
+ }
+
+ /* Any other scenario */
+ return dom->next;
+}
+
static int nss_cmd_getpwuid_search(struct nss_dom_ctx *dctx)
{
struct nss_cmd_ctx *cmdctx = dctx->cmdctx;
@@ -994,7 +1016,7 @@ static int nss_cmd_getpwuid_search(struct nss_dom_ctx *dctx)
"(id out of range)\n",
(unsigned long)cmdctx->id, dom->name));
if (cmdctx->check_next) {
- dom = dom->next;
+ dom = get_next_dom_or_subdom(dom);
continue;
}
return ENOENT;
@@ -1031,7 +1053,7 @@ static int nss_cmd_getpwuid_search(struct nss_dom_ctx *dctx)
if (dctx->res->count == 0 && !dctx->check_provider) {
/* if a multidomain search, try with next */
if (cmdctx->check_next) {
- dom = dom->next;
+ dom = get_next_dom_or_subdom(dom);
continue;
}
@@ -2364,7 +2386,7 @@ static int nss_cmd_getgrgid_search(struct nss_dom_ctx *dctx)
"(id out of range)\n",
(unsigned long)cmdctx->id, dom->name));
if (cmdctx->check_next) {
- dom = dom->next;
+ dom = get_next_dom_or_subdom(dom);
continue;
}
return ENOENT;
@@ -2401,7 +2423,7 @@ static int nss_cmd_getgrgid_search(struct nss_dom_ctx *dctx)
if (dctx->res->count == 0 && !dctx->check_provider) {
/* if a multidomain search, try with next */
if (cmdctx->check_next) {
- dom = dom->next;
+ dom = get_next_dom_or_subdom(dom);
continue;
}