-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
call syscall.Setgroups on groups from /etc/passwd and /etc/group #37
Conversation
Signed-off-by: Caleb Lloyd <caleblloyd@gmail.com>
c6a9f11
to
933f30c
Compare
In my experience the extra groups are not picked up also when the old and new uid/gid are matching. I believe that is because the fixuid process is not being run by the new uid user, it is actually run as root (because of the suid bit) and thus it never matches with the groups defined in the /etc/groups |
Can you provide an example of an /etc/passwd, /etc/group, and a UID/GID to launch the container with that generates the unexpected result? |
Sure.
Same result when the uid/gid inside does not match the outside (just extra logs about updating user/group and chowning home folder). At the moment when fixuid binary gets started as root (as the consequence of having setuid root bit set) it looses all previously set user and group ids. As a standard security precaution. Or the groups inside the /etc/group in the container are just plainly ignored when the user/group is supplied from the command line. |
Running it this way:
does produce your expected behavior that it shows full groups if the called uid is matching and just the test group if it is not matching. So it looks like the Docker run ignores /etc/group contents if there is any group specified on the command line and just resets the extra groups to an empty list. |
I don't think it loses groups, the Effective UID just gets set to 0 (root). I'm not a POSIX expert by any means but I believe that getgroups stays the same inside the setuid script.
Yes - this seems to be exactly what is happening. So we probably should run it every time then, since the instructions indicate that the user should set the group ID and most probably do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Signed-off-by: Caleb Lloyd <caleblloyd@gmail.com>
Updated to set supplemental groups every run |
Signed-off-by: Caleb Lloyd <caleblloyd@gmail.com>
As the new fixuid version correctly retains the groups for the user. Refs boxboat/fixuid#30 Refs boxboat/fixuid#37
Fixes #30
After UID/GID changes have been made, group membership that didn't match on container launch in
/etc/passwd
and/etc/groups
may now matchThis can be changed with
syscall.Setgroups
but will only remain effective if the next program is called viaexec
. In "command" mode the child process callingsyscall.Setgroups
won't affect the parent.It also shouldn't need to be run on subsequent starts, because the container start process should resolve the proper groups from
/etc/passwd
and/etc/group
after these files have already been changed