diff options
-rw-r--r-- | guts/README | 6 | ||||
-rw-r--r-- | guts/getgroups.c | 12 |
2 files changed, 14 insertions, 4 deletions
diff --git a/guts/README b/guts/README index a1030c6..efb6e4b 100644 --- a/guts/README +++ b/guts/README @@ -188,3 +188,9 @@ is set, or else the system /etc/* files. setgrent setgroups setpwent + +The implementation of getgroups() is inauthentic in that it always checks +the group file when called, rather than checking the group file once +"at login" (whatever that means in our context) and returning that saved +status. We don't think this matters. setgroups() just fails; this will +be corrected if we come up with a compelling reason to do so. diff --git a/guts/getgroups.c b/guts/getgroups.c index 8394325..f952eaf 100644 --- a/guts/getgroups.c +++ b/guts/getgroups.c @@ -3,11 +3,15 @@ * wrap_getgroups(int size, gid_t *list) { * int rc = -1; */ + struct passwd *p = wrap_getpwuid(wrap_getuid()); + int oldsize = size; - /* you're only in group zero */ - rc = 1; - if (size > 0) { - list[0] = 0; + if (p) { + rc = wrap_getgrouplist(p->pw_name, wrap_getgid(), list, &size); + if (oldsize == 0 || size <= oldsize) + rc = size; + } else { + errno = ENOENT; } /* return rc; |