rig/commands/lib
cluade-reviewer-andresmgsl 7f2501d0fe
Some checks failed
ci / check (pull_request) Failing after 7s
ci / install (pull_request) Successful in 4s
ci / db-integration (pull_request) Successful in 4s
labels / labels (pull_request) Failing after 7s
fix: refuse a PATH without /usr/sbin, before the token prompt
Reported from a real ci-box: `rig forgejo-runner install` read a registration
token off the operator's terminal and then died with

  …/forgejo-runner-install.sh: line 250: useradd: command not found

rig checked `id -u` and concluded it could administer the machine. Being root
and being able to FIND the admin binaries are different facts, and only the
first was asserted. `su` without `-`, sudo with a sanitised secure_path, and
several container images all produce a root shell with no /usr/sbin on PATH,
which is where useradd lives.

Three call sites had it: both runner installers and users apply. The last is
the worst — it runs mid-convergence, so a PATH-shorn root could fail partway
through a user sweep rather than before it starts.

require_admin_bins refuses rather than repairing PATH itself: a command that
quietly prepends /usr/sbin teaches the operator nothing and leaves a
misconfigured host misconfigured. The message names the remedy and,
deliberately, not this script — echoing an internal path back at someone who
typed `rig forgejo-runner install` is the unhelpful half of the original error.

It sits beside each root check, so identity and capability are asserted
together and before anything is spent. A secret typed for a run that could
never succeed is the avoidable half of this bug, and there is a test for
exactly that ordering.

Closes #139

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 18:39:03 +00:00
..
admin-path.sh fix: refuse a PATH without /usr/sbin, before the token prompt 2026-08-01 18:39:03 +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