tests: cover gpasswd as a group administrator - #287
Merged
Conversation
The reason gpasswd is setuid is that someone who is not root, but is named an administrator of one group, manages that group's membership. Nothing in the suite exercised a non-root caller of it, and that is the only place the omission shows: the multicall binary drops privilege for every applet not on its setuid list, so leaving gpasswd off that list produces a permission error there and nowhere else. It was off the list when the tool arrived. Twelve assertions: an administrator adds a member without being root and the change lands in both group and gshadow; a plain member may not change the membership, may not appoint administrators and may not use --root; and the administrator list is unchanged after all three refusals. Checked that the test bites by taking gpasswd back off the setuid list and rebuilding -- the administrator is then refused and the group file is untouched. Worth saying that the first attempt at that check appeared to show the fix was unnecessary; the build output had been suppressed and a stale binary was installed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Follow-up to #282, as promised there.
The reason
gpasswdis setuid is that someone who is not root, but is namedan administrator of one group, manages that group's membership. Nothing in the
suite exercised a non-root caller of it — and that is the only place the
omission shows. The multicall binary drops privilege for every applet not on
its setuid list, so leaving
gpasswdoff that list produces a permission errorthere and nowhere else. It was off the list when the tool arrived.
Twelve assertions: an administrator adds a member without being root and the
change lands in both
/etc/groupand/etc/gshadow; a plain member may notchange the membership, may not appoint administrators, and may not use
--root; and the administrator list is unchanged after all three refusals.The test bites
Taking
gpasswdback offSETUID_APPLETSand rebuilding:Worth recording that my first attempt at this check appeared to show the fix
was unnecessary: I had suppressed the build output, cargo had not rebuilt, and
a stale binary went in. The lesson is the usual one — do not hide the output of
the step whose result you are about to reason from.