Files
Pulse/internal/api
rcourtman 6baf835a0b Let NOPASSWD sudo users run the agent install command (#3283)
## Why
The copied Unix install and setup commands ran `sudo -v` before the
silent token prompt. sudo checks `-v` against its `verifypw` rule, so it
asks for a password whenever *any* matching sudoers entry needs one,
even when the rule that would run a command is NOPASSWD. Ubuntu cloud
images match both `%sudo ALL=(ALL:ALL) ALL` and cloud-init's NOPASSWD
rule, and their default user has no password. So on the hosts providers
most often spin up, the command stopped with `sudo: a password is
required`. Found while installing an agent on a fresh MSP client VM.

## What changes
- The Go builder (`internal/api/configapi/install_command.go`) and the
frontend builder (`frontend-modern/src/utils/agentInstallCommand.ts`)
now run `if ! sudo -n true 2>/dev/null; then sudo -v; fi`. The silent
`sudo -n true` 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: password hosts are prompted
as before, and a policy that allows only bash (where `true` is denied)
still validates. The `if` form keeps the `| sudo` pipe guard in the
contract tests meaningful.
- Tests pin the new preflight. Both bootstrap fixtures' fake sudo
answers `-n true` the way it answers `-v`, so the sudo-refusal cases
still refuse.

## Verification
- On an Ubuntu 24.04 cloud-init host (NOPASSWD user, no password), the
old preflight prints `sudo: a password is required` and the new one
passes without a prompt.
- A Sol 6.1 read-only review flagged that bare `sudo true` would refuse
a bash-only sudoers policy; the `sudo -v` fallback keeps that case
working.
- `go test ./internal/api/configapi/` passes, as do the install-command
and contract tests in `./internal/api` and six affected frontend test
files (187 tests).
- Browser: a production build against the pulse-dev rig, at Settings >
Infrastructure > Install Pulse Agent. All ten Unix commands render the
new preflight, at 1280px and 390px, with no overflow and no page errors
(receipt `dfa48ee9faabee46.json`). The rig tokens minted during the
check were revoked.

Contract-neutral: only the preflight verb changes. Command shape,
privilege dispatch and token handling are unchanged.
2026-10-25 20:54:55 +00:00
..
2026-10-11 22:20:25 +01:00
2026-10-11 22:20:25 +01:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-08-31 19:47:01 +01:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-04-26 17:26:16 +01:00
2026-01-22 00:30:15 +00:00
2026-10-11 22:20:25 +01:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-09-01 01:02:17 +01:00
2026-03-18 16:06:30 +00:00

Internal API Package

This directory contains the API server implementation for Pulse.

Important Note About frontend-modern/

The frontend-modern/ subdirectory that appears here is:

  • AUTO-GENERATED during builds
  • NOT the source code - just a build artifact
  • IN .gitignore - never committed
  • REQUIRED BY GO - The embed directive needs it here

Frontend Development Location

👉 Edit frontend files at: ${PULSE_REPOS_DIR}/pulse/frontend-modern/src/

Why This Structure?

Go's //go:embed directive has limitations:

  1. Cannot use ../ paths to access parent directories
  2. Cannot follow symbolic links
  3. Must embed files within the Go module

This is a known Go limitation and our structure works around it.