summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSumit Bose <sbose@redhat.com>2011-03-07 10:04:13 +0100
committerStephen Gallagher <sgallagh@redhat.com>2011-03-07 11:14:51 -0500
commit0d407ee06aab1200dc8ff11d021a3e8e06d9d5c9 (patch)
tree17724b5dd002e033c130d47a5a9f8cbe3e18e459
parentbcf6d695c7df37bf5b0847d0c6c19d709ba4cf36 (diff)
downloadsssd-0d407ee06aab1200dc8ff11d021a3e8e06d9d5c9.tar.gz
sssd-0d407ee06aab1200dc8ff11d021a3e8e06d9d5c9.tar.xz
sssd-0d407ee06aab1200dc8ff11d021a3e8e06d9d5c9.zip
Add missing name to struct getent_ctx for missing netgroup
https://fedorahosted.org/sssd/ticket/817 Refactor set_netgroup_entry() To avoid wrong or missing netgroup names in the getent_ctx destructor set_netgroup_entry() now takes the name out of the getent_ctx struct instead of using a separate argument.
-rw-r--r--src/responder/nss/nsssrv_netgroup.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/responder/nss/nsssrv_netgroup.c b/src/responder/nss/nsssrv_netgroup.c
index c5ca36f53..6d74330d5 100644
--- a/src/responder/nss/nsssrv_netgroup.c
+++ b/src/responder/nss/nsssrv_netgroup.c
@@ -57,16 +57,19 @@ static errno_t get_netgroup_entry(struct nss_ctx *nctx,
static int netgr_hash_remove (TALLOC_CTX *ctx);
static errno_t set_netgroup_entry(struct nss_ctx *nctx,
- char *name,
struct getent_ctx *netgr)
{
hash_key_t key;
hash_value_t value;
int hret;
+ if (netgr->name == NULL) {
+ DEBUG(1, ("Missing netgroup name.\n"));
+ return EINVAL;
+ }
/* Add this entry to the hash table */
key.type = HASH_KEY_STRING;
- key.str = name;
+ key.str = netgr->name;
value.type = HASH_VALUE_PTR;
value.ptr = netgr;
hret = hash_enter(nctx->netgroups, &key, &value);
@@ -270,7 +273,7 @@ static struct tevent_req *setnetgrent_send(TALLOC_CTX *mem_ctx,
goto error;
}
- ret = set_netgroup_entry(nctx, client->netgr_name, state->netgr);
+ ret = set_netgroup_entry(nctx, state->netgr);
if (ret != EOK) {
DEBUG(1, ("set_netgroup_entry failed.\n"));
talloc_free(state->netgr);
@@ -494,8 +497,14 @@ static errno_t lookup_netgr_step(struct setent_step_ctx *step_ctx)
netgr->ready = true;
netgr->entries = NULL;
netgr->lookup_table = step_ctx->nctx->netgroups;
+ netgr->name = talloc_strdup(netgr, step_ctx->name);
+ if (netgr->name == NULL) {
+ DEBUG(1, ("talloc_strdup failed.\n"));
+ talloc_free(netgr);
+ return ENOMEM;
+ }
- ret = set_netgroup_entry(step_ctx->nctx, step_ctx->name, netgr);
+ ret = set_netgroup_entry(step_ctx->nctx, netgr);
if (ret != EOK) {
DEBUG(1, ("set_netgroup_entry failed, ignored.\n"));
}