Files
Pulse/internal/api/configapi
rcourtman dab7582c95 Let NOPASSWD sudo users run the agent install command
The copied Unix install and setup commands settled sudo with `sudo -v`
before the silent token prompt. sudo applies its verifypw rule to -v, so
it asks for a password whenever any matching sudoers entry needs one,
even if the rule that would run a command is NOPASSWD. Ubuntu cloud
images match both `%sudo ALL=(ALL:ALL) ALL` and the cloud-init NOPASSWD
rule, and the default user there has no password, so the command failed
with "a password is required" for exactly the hosts most providers spin
up. Found while installing an agent on a fresh MSP client VM.

The preflight now tries a silent `sudo -n true` first. It runs a
command, so sudo applies the rule it would actually use, and it passes
for NOPASSWD users and cached credentials. Otherwise the old `sudo -v`
runs unchanged, so hosts that need a password are prompted as before and
a policy that allows only bash (where `true` is denied) still validates.
Both producers (the Go install command builder and the frontend one)
change together, and their tests pin the new preflight; the bootstrap
fixtures' fake sudo answers `-n true` the way it answers `-v`, so the
refusal cases still refuse.

Verified on an Ubuntu 24.04 cloud-init host: the old preflight prints
"sudo: a password is required", the new one passes without a prompt. The
Settings installer renders the new preflight in every Unix command at
desktop and phone widths.

Contract-Neutral: sudo preflight only; command shape, privilege dispatch and token handling unchanged
2026-10-25 19:41:18 +00:00
..