From 7f57a4ea14acc4bd041b38390fbc9cc5765c5772 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Thu, 20 Feb 2014 13:55:57 +0000 Subject: [PATCH] * grp.cc (get_groups): Don't add gid to list if it's ILLEGAL_GID. (getgrouplist): Return number of groups, just like glibc. --- winsup/cygwin/ChangeLog | 5 +++++ winsup/cygwin/grp.cc | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 71717883e..506a63bcd 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2014-02-20 Corinna Vinschen + + * grp.cc (get_groups): Don't add gid to list if it's ILLEGAL_GID. + (getgrouplist): Return number of groups, just like glibc. + 2014-02-19 Corinna Vinschen * passwd.cc (pg_ent::setent): Initialize cygheap domain info. diff --git a/winsup/cygwin/grp.cc b/winsup/cygwin/grp.cc index 18e091642..665cb173d 100644 --- a/winsup/cygwin/grp.cc +++ b/winsup/cygwin/grp.cc @@ -570,7 +570,7 @@ get_groups (const char *user, gid_t gid, cygsidlist &gsids) cygsid usersid, grpsid; if (usersid.getfrompw (pw)) get_server_groups (gsids, usersid, pw); - if (grpsid.getfromgr (grp)) + if (gid != ILLEGAL_GID && grpsid.getfromgr (grp)) gsids += grpsid; cygheap->user.reimpersonate (); } @@ -626,7 +626,7 @@ getgrouplist (const char *user, gid_t gid, gid_t *groups, int *ngroups) } if (cnt > *ngroups) ret = -1; - *ngroups = cnt; + ret = *ngroups = cnt; syscall_printf ( "%d = getgrouplist(%s, %u, %p, %d)", ret, user, gid, groups, *ngroups);