Skip to content

tests: cover gpasswd as a group administrator - #287

Merged
pierre-warnier merged 1 commit into
mainfrom
test/gpasswd-group-admin
Sep 6, 2026
Merged

tests: cover gpasswd as a group administrator#287
pierre-warnier merged 1 commit into
mainfrom
test/gpasswd-group-admin

Conversation

@pierre-warnier

Copy link
Copy Markdown
Collaborator

Follow-up to #282, as promised there.

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 /etc/group and /etc/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.

The test bites

Taking gpasswd back off SETUID_APPLETS and rebuilding:

=== admin adds a member, gpasswd OFF the setuid list ===
gpasswd: Permission denied
exit=1
t3:x:1005:                      ← group unchanged

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.

Deployment suite        235 passed, 0 failed
make check              exit 0

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.
@pierre-warnier
pierre-warnier merged commit f3a20b2 into main Sep 6, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant