Lock down ability to run su command. #654
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change enables
pam_wheel
so that execution ofsu
can be restricted to just theroot
user or any users in thewheel
group. By default, no users would be in thewheel
group, so only theroot
user can executesu
. It is believed this will not interfere withsudo
mechanism used by the image.This is being done to partly address issues raised in #560 as raised by @minrk.
It should eliminate the current problem that when running as a random user ID which is not in the
/etc/passwd
file, andsetuid
capabilities has not been dropped for the container, that the user can runsu
by adding a password for a target user, by virtue of being placed in theroot
group as fallback when user ID has no group.The reason
/etc/passwd
file is writable toroot
group in the first place was due to the need to add an entry into the file when being run as a random user ID. Without it, Jupyter notebooks or third party packages it relies on, can fail due to the lack of the entry.Write access to
/etc/group
by members of theroot
group is also dropped by this change because leaving that would mean they would have been able to add themselves to thewheel
group and give themselves the ability to runsu
still.Write access to
/etc/group
wasn't essential. Adding group entries for random primary group ID running eliminated warning messages from interactive shells created, but lack of the group entry is not known to cause Jupyter notebooks or any other Python package to fail.Presuming no one can see any other avenues for still running
su
, and this doesn't interfere with use ofsudo
, this change is necessary before consideration can be given for changingNB_GID
to group ID0
instead or100
. The later point of changingNB_GID
being to allow image to be run as random user ID, without still needing to add group ID100
as a supplemental group for the container.