From 7ac324e0b94f1b27b6e66ae4bfd58df202c00e48 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 13 Apr 2009 17:10:04 -0400 Subject: Fix a couple of segfaults and timeout checks --- server/responder/nss/nsssrv_cmd.c | 43 ++++++++++----------------------- server/responder/pam/pam_LOCAL_domain.c | 2 +- 2 files changed, 14 insertions(+), 31 deletions(-) (limited to 'server/responder') diff --git a/server/responder/nss/nsssrv_cmd.c b/server/responder/nss/nsssrv_cmd.c index f5555ed9..ba444ccf 100644 --- a/server/responder/nss/nsssrv_cmd.c +++ b/server/responder/nss/nsssrv_cmd.c @@ -347,7 +347,7 @@ static void nss_cmd_getpwnam_callback(void *ptr, int status, cmdctx->name)); ret = ENOENT; } - if (dctx->domain == NULL) { + if (dom == NULL) { DEBUG(2, ("No matching domain found for [%s], fail!\n", cmdctx->name)); ret = ENOENT; @@ -696,31 +696,22 @@ static void nss_cmd_getpwuid_callback(void *ptr, int status, ret = EOK; - for (dom = dctx->domain->next; dom; dom = dom->next) { - - ncret = nss_ncache_check_uid(nctx->ncache, nctx->neg_timeout, + dom = dctx->domain->next; + ncret = nss_ncache_check_uid(nctx->ncache, nctx->neg_timeout, cmdctx->id); - if (ncret == ENOENT) break; - - neghit = true; - } - /* reset neghit if we still have a domain to check */ - if (dom) neghit = false; - - dctx->domain = dom; - - if (neghit) { + if (ncret == EEXIST) { DEBUG(3, ("Uid [%lu] does not exist! (negative cache)\n", (unsigned long)cmdctx->id)); ret = ENOENT; } - if (dctx->domain == NULL) { + if (dom == NULL) { DEBUG(0, ("No matching domain found for [%lu], fail!\n", (unsigned long)cmdctx->id)); ret = ENOENT; } if (ret == EOK) { + dctx->domain = dom; dctx->check_provider = (dctx->domain->provider != NULL); if (dctx->res) talloc_free(res); dctx->res = NULL; @@ -1723,7 +1714,7 @@ static void nss_cmd_getgrnam_callback(void *ptr, int status, cmdctx->name)); ret = ENOENT; } - if (dctx->domain == NULL) { + if (dom == NULL) { DEBUG(2, ("No matching domain found for [%s], fail!\n", cmdctx->name)); ret = ENOENT; @@ -2057,31 +2048,23 @@ static void nss_cmd_getgrgid_callback(void *ptr, int status, ret = EOK; - for (dom = dctx->domain->next; dom; dom = dom->next) { - - ncret = nss_ncache_check_gid(nctx->ncache, nctx->neg_timeout, - cmdctx->id); - if (ncret == ENOENT) break; + dom = dctx->domain->next; - neghit = true; - } - /* reset neghit if we still have a domain to check */ - if (dom) neghit = false; - - dctx->domain = dom; - - if (neghit) { + ncret = nss_ncache_check_gid(nctx->ncache, nctx->neg_timeout, + cmdctx->id); + if (ncret == EEXIST) { DEBUG(3, ("Gid [%lu] does not exist! (negative cache)\n", (unsigned long)cmdctx->id)); ret = ENOENT; } - if (dctx->domain == NULL) { + if (dom == NULL) { DEBUG(0, ("No matching domain found for [%lu], fail!\n", (unsigned long)cmdctx->id)); ret = ENOENT; } if (ret == EOK) { + dctx->domain = dom; dctx->check_provider = (dctx->domain->provider != NULL); if (dctx->res) talloc_free(res); dctx->res = NULL; diff --git a/server/responder/pam/pam_LOCAL_domain.c b/server/responder/pam/pam_LOCAL_domain.c index df2803e5..dc394ab8 100644 --- a/server/responder/pam/pam_LOCAL_domain.c +++ b/server/responder/pam/pam_LOCAL_domain.c @@ -407,7 +407,7 @@ int LOCAL_pam_handler(struct pam_auth_req *preq) ret = sysdb_get_user_attr(lreq, lreq->dbctx, preq->domain, preq->pd->user, attrs, - local_handler_callback, preq); + local_handler_callback, lreq); if (ret != EOK) { DEBUG(1, ("sysdb_get_user_attr failed.\n")); -- cgit