[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
id not showing supplementary groups
From: |
Javier Pello |
Subject: |
id not showing supplementary groups |
Date: |
Wed, 23 Apr 2008 12:46:12 +0200 |
User-agent: |
Thunderbird 2.0.0.12 (X11/20080327) |
Hi,
I have just downloaded and installed coreutils-6.11 and I have come
across a change in behaviour in the id program which does not seem
to be documented. Specifically, id no longer prints the supplementary
groups of the current process when invoked without a user argument,
as in the following example:
~$ ./coreutils-6.10/src/id -G
100 8 10 14
~$ ./coreutils-6.11/src/id -G
100
Furthermore, the behaviour is not consistent. If the uid of the
process appears in /etc/passwd, then id shows the groups that uid
is a member of (as defined in /etc/group); if the uid does not appear
in /etc/passwd, then id shows the actual supplementary groups of the
process (which is the right thing to do). I have attached a simple
program that can be used to check this:
~# ./a.out 100
(100:0) 13 17 19
0 13 17 19
~# ./a.out 101
(101:0) 13 17 19
0 100
~# ./a.out 102
(102:0) 13 17 19
0 13 17 19
(In my system, 101 is a valid uid appearing in /etc/passwd, belonging
to group 100, while 100 and 102 are not. I am running linux 2.6.25
with glibc 2.7.)
I take this to be a bug (please correct me if I am wrong).
The attached patch would fix it.
Thanks,
Javier
--- src/id.c~ 2008-04-19 23:34:23.000000000 +0200
+++ src/id.c 2008-04-23 12:40:22.000000000 +0200
@@ -208,10 +208,8 @@
}
else
{
- struct passwd const *pwd;
euid = geteuid ();
- pwd = getpwuid (euid);
- user_name = pwd ? xstrdup (pwd->pw_name) : NULL;
+ user_name = NULL;
ruid = getuid ();
egid = getegid ();
rgid = getgid ();
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
void showp (void)
{
gid_t list [32];
int ngroups, i;
ngroups = getgroups (0, 0);
if ( ngroups >= 32 ) abort();
getgroups (32, list);
printf ("(%u:%u)", getuid(), getgid());
for (i=0; i<ngroups; i++)
printf (" %u", list[i]);
putchar ('\n');
}
int main (int argc, char **argv, char **envp)
{
static char *args [] = { "id", "-G", 0 };
setgroups (3, (gid_t[]) { 13, 17, 19 });
setuid (atoi(argv[1]));
showp ();
execve ("id", args, envp);
}
- id not showing supplementary groups,
Javier Pello <=