[SSSD] [PATCH] Fix two netgroup issues

Jakub Hrozek jhrozek at redhat.com
Wed Mar 7 19:47:11 UTC 2012


Hi,

Amith reported these two issues.

[PATCH 1/2] Save original name into the in-memory cache
We were saving the original name into the netgroup hash when the object
was first constructed but when no domain matched, we would save the cased
name. The first request that was constructed with the original name was never
marked as "ready", so another request with the same name was stuck waiting.

[PATCH 2/2]
setnetgrent return codes are handled in the _done callback, some of them
gracefully, such as ENOENT that sends an empty reply. This patch uses
tevent_req_post() to always call the callback and handle error conditions
there. In particular, Amith was able to trigger this error by requesting
a netgroup by raw name when all domains were marked as FQDN only
-------------- next part --------------
From 83369849ea2c8ec62adaa319f66489b3fd7049e6 Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhrozek at redhat.com>
Date: Wed, 7 Mar 2012 19:56:21 +0100
Subject: [PATCH 1/2] Save original name into the in-memory cache

---
 src/responder/nss/nsssrv_netgroup.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/responder/nss/nsssrv_netgroup.c b/src/responder/nss/nsssrv_netgroup.c
index 9cb3422f2c2e157129d802ace555449991a33f43..bce1d47751ea82d70ba524e82eeea86c1fe850bc 100644
--- a/src/responder/nss/nsssrv_netgroup.c
+++ b/src/responder/nss/nsssrv_netgroup.c
@@ -510,7 +510,7 @@ static errno_t lookup_netgr_step(struct setent_step_ctx *step_ctx)
         netgr->found = false;
         netgr->entries = NULL;
         netgr->lookup_table = step_ctx->nctx->netgroups;
-        netgr->name = talloc_strdup(netgr, name);
+        netgr->name = talloc_strdup(netgr, step_ctx->name);
         if (netgr->name == NULL) {
             DEBUG(1, ("talloc_strdup failed.\n"));
             talloc_free(netgr);
-- 
1.7.7.6

-------------- next part --------------
From b13b66f2d7bac825be86fd71974d829c45e2fb54 Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhrozek at redhat.com>
Date: Wed, 7 Mar 2012 19:55:26 +0100
Subject: [PATCH 2/2] Handle errors from lookup_netgr_step gracefully

---
 src/responder/nss/nsssrv_netgroup.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/responder/nss/nsssrv_netgroup.c b/src/responder/nss/nsssrv_netgroup.c
index bce1d47751ea82d70ba524e82eeea86c1fe850bc..81c29bcc7ed6dcff83bbf80e692bdb87ceab7f85 100644
--- a/src/responder/nss/nsssrv_netgroup.c
+++ b/src/responder/nss/nsssrv_netgroup.c
@@ -189,6 +189,7 @@ static struct tevent_req *setnetgrent_send(TALLOC_CTX *mem_ctx,
 
     state->dctx = talloc_zero(state, struct nss_dom_ctx);
     if (!state->dctx) {
+        ret = ENOMEM;
         goto error;
     }
     dctx = state->dctx;
@@ -207,6 +208,7 @@ static struct tevent_req *setnetgrent_send(TALLOC_CTX *mem_ctx,
     if (domname) {
         dctx->domain = responder_get_domain(client->rctx->domains, domname);
         if (!dctx->domain) {
+            ret = EINVAL;
             goto error;
         }
 
@@ -224,6 +226,7 @@ static struct tevent_req *setnetgrent_send(TALLOC_CTX *mem_ctx,
         /* Save the netgroup name for getnetgrent */
         client->netgr_name = talloc_strdup(client, state->netgr_shortname);
         if (!client->netgr_name) {
+            ret = ENOMEM;
             goto error;
         }
     }
@@ -264,6 +267,7 @@ static struct tevent_req *setnetgrent_send(TALLOC_CTX *mem_ctx,
          */
         state->netgr = talloc_zero(nctx, struct getent_ctx);
         if (!state->netgr) {
+            ret = ENOMEM;
             goto error;
         }
         dctx->netgr = state->netgr;
@@ -275,6 +279,7 @@ static struct tevent_req *setnetgrent_send(TALLOC_CTX *mem_ctx,
                                            client->netgr_name);
         if (!state->netgr->name) {
             talloc_free(state->netgr);
+            ret = ENOMEM;
             goto error;
         }
 
@@ -325,7 +330,8 @@ static struct tevent_req *setnetgrent_send(TALLOC_CTX *mem_ctx,
                 return req;
             }
 
-            /* An unexpected error occurred */
+            /* An unexpected error occurred or no domains
+             * were eligible for the search */
             goto error;
         }
         tevent_req_done(req);
@@ -339,8 +345,9 @@ static struct tevent_req *setnetgrent_send(TALLOC_CTX *mem_ctx,
     return req;
 
 error:
-    talloc_free(req);
-    return NULL;
+    tevent_req_error(req, ret);
+    tevent_req_post(req, cmdctx->cctx->ev);
+    return req;
 }
 
 static void lookup_netgr_dp_callback(uint16_t err_maj, uint32_t err_min,
-- 
1.7.7.6



More information about the sssd-devel mailing list