rig/commands/lib
cluade-reviewer-andresmgsl 7aed6ea098
Some checks failed
ci / check (pull_request) Successful in 55s
ci / install (pull_request) Successful in 3s
ci / db-integration (pull_request) Successful in 3s
labels / labels (pull_request) Failing after 7s
fix: preflight every admin binary a command uses, not only useradd
Addresses codex (1538) and kimi (1539): the sweep caught the reported
incident and not the class. Both are right, and there were four sites, not
three.

  forgejo-runner-install  useradd -> useradd usermod   (usermod -aG docker,
                          reached only after the token has been spent)
  users-apply             useradd usermod -> + groupadd (called two lines
                          into convergence), and visudo when a role needs it
  bootstrap-tenant        NEW site (kimi) — usermod -aG docker runs AFTER
                          docker and node are installed, so an unguarded
                          PATH fails it mid-convergence on a changed machine
  runner-install          unchanged: useradd is the only admin binary it
                          calls, and declaring more would refuse boxes that
                          are fine

visudo is checked after the sudo-install block rather than beside the root
check, because until sudo is installed its absence has an innocent cause.
Below that block it does not: sudo is present, so a missing visudo means
/usr/sbin is off PATH. That case is the quiet one — the sudoers block reads
`command -v visudo` as "no sudo on the box means no role needed it", so
apply reported success having granted roles without the escalation those
roles exist for. The other three sites at least crash.

Measured which binaries this covers (Debian 13): useradd, usermod, groupadd,
userdel, groupdel and visudo are /usr/sbin; gpasswd is /usr/bin and so is
NOT affected and deliberately not preflighted. visudo shares the directory
but ships in `sudo`, not `passwd` — which is why it needs its own treatment.

Tests: the sbin-less fixtures could only ever prove the FIRST binary is
named, since useradd wins every race. Six new checks use partial PATHs that
resolve the earlier binaries and withhold exactly one, plus the ordering
assertions (no token prompt, no group created) and the negative case — a
users file needing no sudo must NOT be refused for a missing visudo.

Refs #139
2026-08-02 00:05:02 +00:00
..
admin-path.sh fix: preflight every admin binary a command uses, not only useradd 2026-08-02 00:05:02 +00:00
forgejo-runner-config.sh fix: the --version read cannot die ahead of its own refusal 2026-07-28 09:26:17 +00:00
manifest.sh fix: read a manifest's final line when the file has no trailing newline 2026-07-20 12:48:39 +00:00
runner-config.sh fix: scope the netmap tag read to Self 2026-07-25 16:02:54 +00:00
sshd.sh fix: don't read a missing /run/sshd as a broken sshd config 2026-07-20 17:58:10 +00:00
templates.sh feat: Forgejo-native CI — a ci-box tenant and a forgejo-runner family 2026-07-27 20:40:54 +00:00
users-config.sh fix(users): the root-door resolver matches whole fields, not substrings 2026-07-20 11:18:37 +00:00