* [PATCH] Fix __nscd_get{grouplist,ai}
@ 2005-02-07 13:18 Jakub Jelinek
2005-02-07 22:55 ` Ulrich Drepper
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2005-02-07 13:18 UTC (permalink / raw)
To: Ulrich Drepper; +Cc: Glibc hackers
Hi!
If nscd is running, but
enable-cache group no
then initgroups will set just the group passed to it as second argument
and not the other ones.
I guess when host caching is disabled and getaddrinfo is used, the result
will be similar.
Furthermore, running nscd -d with one of the 3 caches disabled and Ctrl-Cing
it results in a segfault, also fixed by the patch below.
2005-02-07 Jakub Jelinek <jakub@redhat.com>
* nscd/nscd.c (termination_handler): Avoid segfault if some database
is not enabled.
* nscd/nscd_getai.c (__nscd_getai): If ai_resp->found == -1, set
__nss_not_use_nscd_hosts and return -1.
* nscd/nscd_initgroups.c (__nscd_getgrouplist): If
initgr_resp->found == -1, set __nss_not_use_nscd_group and return -1.
Avoid leaking sockets.
--- libc/nscd/nscd.c.jj 2005-01-19 14:12:59.000000000 +0100
+++ libc/nscd/nscd.c 2005-02-07 13:31:03.554553157 +0100
@@ -442,6 +442,9 @@ termination_handler (int signum)
/* Synchronize memory. */
for (int cnt = 0; cnt < lastdb; ++cnt)
{
+ if (!dbs[cnt].enabled)
+ continue;
+
/* Make sure nobody keeps using the database. */
dbs[cnt].head->timestamp = 0;
--- libc/nscd/nscd_initgroups.c.jj 2004-11-10 10:30:32.000000000 +0100
+++ libc/nscd/nscd_initgroups.c 2005-02-07 14:01:57.271312190 +0100
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2004, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2004.
@@ -75,7 +75,7 @@ __nscd_getgrouplist (const char *user, g
sizeof (initgr_resp_mem));
if (sock == -1)
{
- /* nscd not running or wrong version or hosts caching disabled. */
+ /* nscd not running or wrong version. */
__nss_not_use_nscd_group = 1;
goto out;
}
@@ -101,7 +101,7 @@ __nscd_getgrouplist (const char *user, g
(initgr_resp->ngrps + 1) * sizeof (gid_t));
if (newp == NULL)
/* We cannot increase the buffer size. */
- goto out;
+ goto out_close;
*groupsp = newp;
*size = initgr_resp->ngrps + 1;
@@ -125,6 +125,13 @@ __nscd_getgrouplist (const char *user, g
}
else
{
+ if (__builtin_expect (initgr_resp->found == -1, 0))
+ {
+ /* The daemon does not cache this database. */
+ __nss_not_use_nscd_group = 1;
+ goto out_close;
+ }
+
/* No group found yet. */
retval = 0;
@@ -143,6 +150,7 @@ __nscd_getgrouplist (const char *user, g
(*groupsp)[retval++] = group;
}
+ out_close:
if (sock != -1)
close_not_cancel_no_status (sock);
out:
--- libc/nscd/nscd_getai.c.jj 2004-11-25 14:35:57.000000000 +0100
+++ libc/nscd/nscd_getai.c 2005-02-07 14:02:38.952871053 +0100
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2004, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2004.
@@ -78,7 +78,7 @@ __nscd_getai (const char *key, struct ns
sizeof (ai_resp_mem));
if (sock == -1)
{
- /* nscd not running or wrong version or hosts caching disabled. */
+ /* nscd not running or wrong version. */
__nss_not_use_nscd_hosts = 1;
goto out;
}
@@ -151,6 +151,13 @@ __nscd_getai (const char *key, struct ns
}
else
{
+ if (__builtin_expect (ai_resp->found == -1, 0))
+ {
+ /* The daemon does not cache this database. */
+ __nss_not_use_nscd_hosts = 1;
+ goto out_close;
+ }
+
/* Store the error number. */
*h_errnop = ai_resp->error;
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix __nscd_get{grouplist,ai}
2005-02-07 13:18 [PATCH] Fix __nscd_get{grouplist,ai} Jakub Jelinek
@ 2005-02-07 22:55 ` Ulrich Drepper
0 siblings, 0 replies; 2+ messages in thread
From: Ulrich Drepper @ 2005-02-07 22:55 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Glibc hackers
[-- Attachment #1: Type: text/plain, Size: 109 bytes --]
Applied.
--
⧠Ulrich Drepper ⧠Red Hat, Inc. ⧠444 Castro St ⧠Mountain View, CA â
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-02-07 22:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-07 13:18 [PATCH] Fix __nscd_get{grouplist,ai} Jakub Jelinek
2005-02-07 22:55 ` Ulrich Drepper
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).