aboutsummaryrefslogtreecommitdiffstats
path: root/guts
diff options
context:
space:
mode:
authorPeter Seebach <seebs@eee12.(none)>2010-03-30 13:36:05 -0500
committerPeter Seebach <seebs@eee12.(none)>2010-03-30 13:39:32 -0500
commitd72c06a2b004425c06dac405f17ca26e241f61fd (patch)
treec10fec59a47951d2589ee7948d758512e44c8c65 /guts
parent35e89652b7d51f2246ee9a8de7592b19f9e6125d (diff)
downloadpseudo-d72c06a2b004425c06dac405f17ca26e241f61fd.tar.gz
pseudo-d72c06a2b004425c06dac405f17ca26e241f61fd.tar.bz2
pseudo-d72c06a2b004425c06dac405f17ca26e241f61fd.zip
Implement getgroups(), so id(1) will work.
Document some limitations of getgroups()/setgroups().
Diffstat (limited to 'guts')
-rw-r--r--guts/README6
-rw-r--r--guts/getgroups.c12
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;