>From 9251aff794832e0e37f5b747b69e756ac836f181 Mon Sep 17 00:00:00 2001 From: Joakim Sindholt Date: Tue, 12 Jul 2016 10:13:23 +0200 Subject: [PATCH] fix getgrouplist without nscd --- src/passwd/getgrouplist.c | 2 +- src/passwd/nscd_query.c | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/passwd/getgrouplist.c b/src/passwd/getgrouplist.c index 43e5182..fd0bf5f 100644 --- a/src/passwd/getgrouplist.c +++ b/src/passwd/getgrouplist.c @@ -17,7 +17,7 @@ int getgrouplist(const char *user, gid_t gid, gid_t *groups, int *ngroups) struct group *res; FILE *f; int swap = 0; - int32_t resp[INITGR_LEN]; + int32_t resp[INITGR_LEN] = {0}; uint32_t *nscdbuf = 0; char *buf = 0; char **mem = 0; diff --git a/src/passwd/nscd_query.c b/src/passwd/nscd_query.c index d38e371..8641e4f 100644 --- a/src/passwd/nscd_query.c +++ b/src/passwd/nscd_query.c @@ -40,7 +40,13 @@ retry: buf[0] = NSCDVERSION; fd = socket(PF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0); - if (fd < 0) return NULL; + if (fd < 0) { + if (errno == EACCES || errno == EAFNOSUPPORT || errno == EPROTONOSUPPORT) { + errno = errno_save; + return fopen("/dev/null", "re"); + } + return 0; + } if(!(f = fdopen(fd, "r"))) { close(fd); -- 2.7.3