From https://unix.stackexchange.com/a/18290/674
The kernel view
Conceptually, there are three sets of groups that a process is a member of. Each set is a subset of the following one.
- The single group that is the process's default group, which files created by this process will belong to.
- The set of groups that are checked when the group requires permission to open a file.
- The set of groups that a process running with extra privileges process can draw upon.
For historical reasons, these sets are respectively:
- the effective group ID (egid);
- the effective group ID plus the supplementary group IDs;
- all of the above plus the real group ID and the saved set-group-ID.
Questions:
What is the case of "a process running with extra privileges process can draw upon" in point 3?
Is this case different from the case of "when the group requires permission to open a file" in point 2?
Do the "supplementary group IDs" include the primary group ID, in general and in point 2 respectively?
By "in general", I mean that I notice the output of
id
includes both primary and supplementary groups followinggroups=
, while https://unix.stackexchange.com/a/18203/674 says "each user can belong to a number of supplementary groups - and these are listed at the end ofid
output." So I wonder if the primary group is also a supplementary group?
Thanks.
setresuid()
I think a process can be running without CAP_SETGID, but still shuffle its UIDs around if they are different, e.g. it's "real" GID may be a different group that it can switch back to. I think that's really what point 3 is trying to refer to. – sourcejedi Sep 04 '18 at 11:51CAP_SETGID
is rather more than that, oops ;-). (To be fair though I didn’t claim a link in my comment on your question — but I did in my answer.) – Stephen Kitt Sep 04 '18 at 12:20/etc/passwd
, can two lines with different user names and the same user ID have different values for the group ID field, or must they have the same value for the group ID field? – Tim Sep 04 '18 at 15:29write
andwall
. – JdeBP Sep 05 '18 at 07:34CAP_SETGID
. setgid binaries do fit the bill as far as the scenario being discusses goes, since they’re not privileged (by theCAP_SETGID
definition) but can still switch group ids. – Stephen Kitt Sep 05 '18 at 08:13