Comment 3 for bug 1355111

Revision history for this message
Lorenz (lqb) wrote :

I had a look in src/newgrp.c
I wonder why the variable grp is overwritten several times, before check_perms is called.
In my understanding, this means the last found group entry wins.

If I have following group entries in my environment:
#From /etc/passwd
comgrp:x:27:user1
#From NIS/LDAP or something similar
comgrp:x:27:user2
#From /etc/gshadow
comgrp:*::user3

user1 and user2 aren't able to change primary group to comgrp because check_perms only sees user3 in that group.
I had expected that all three users are able to change to the comgrp.
What is the correct behaviour? And why?

[src/newgrp.c]
617 grp = getgrnam (group); /* local, no need for xgetgrnam */
[...]
628 grp = find_matching_group (name, grp->gr_gid);
[...]
637 grp = xgetgrnam (group);
[...]
644 grp->gr_mem = sgrp->sg_mem;
[...]
651 check_perms (grp, pwd, group);