Skip to content

docs(liveswap): run as the hotserve user with runuser, not sudo -u - #366

Merged
earthlingdavey merged 2 commits into
mainfrom
docs/liveswap-runuser
Oct 29, 2026
Merged

earthlingdavey merged 2 commits into
mainfrom
docs/liveswap-runuser

Conversation

@earthlingdavey

@earthlingdavey earthlingdavey commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

liveswap/README.md had three commands that run as the hotserve user through sudo -u hotserve …:

  • poking an app's health endpoint over its socket;
  • stopping a pre_start unit that hangs;
  • stopping the units left behind after a restart with no liveswap block.

The box's privileged path is root over SSH, and a Debian 13 box need not have sudo installed (debian:trixie doesn't). On such a box each line ends sudo: command not found. This is the same failure class as #323, found while fixing it.

Each line now uses runuser -u hotserve --, from util-linux, which is always present, and says "as root". runuser does not take VAR=value as an argument the way sudo does, so the two systemctl --user lines put env before XDG_RUNTIME_DIR=…. Checked in debian:trixie: runuser -u nobody -- env XDG_RUNTIME_DIR=/run/user/$(id -u nobody) sh -c 'id -un; echo $XDG_RUNTIME_DIR' prints nobody and /run/user/65534.

Each command is now on one source line, so a copy from the raw file (less on the box) doesn't split $(id -u hotserve) or end at env. Otherwise the lines keep their shape. backup carries the same three lines, and they reach it with the next merge of main.

Triage, for reviewers: a wrong command in a doc, scored S2 O5 D1 = 10, size 1, risk 2 (no test checks the text). Under the project's rule that is an accepted residual, but the owner asked for the fix. The bar for review findings is the same: a finding is fixed if it names a failure that silently breaks something, or one that holds under a single fault.

Self-review (/code-review medium), two findings not fixed:

  • runuser keeps root's environment where sudo reset it, so a DBUS_SESSION_BUS_ADDRESS from root's session reaches systemctl --user. That changes no outcome: systemctl dials the manager's private socket under $XDG_RUNTIME_DIR/systemd/ first, and falls back to the bus only when that socket is missing. Then hotserve's user manager isn't running and there is nothing to stop either way. Not scored, since no outcome changes.
  • Proxy variables in root's shell reach the curl line. That's the operator's own environment, and a request that goes wrong fails loudly in curl's words. 2×5×1 = 10, size 1, risk 2: accepted.

The box's privileged path is root over SSH, and a Debian 13 box need
not have sudo installed, so the three `sudo -u hotserve …` lines end
`sudo: command not found`. `runuser -u hotserve --` is in util-linux,
always present; `env` carries XDG_RUNTIME_DIR, which runuser does not
take as an argument the way sudo does. Each line now says "as root".
The same failure class as #323.
@earthlingdavey earthlingdavey added the documentation Improvements or additions to documentation label Oct 29, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the updated liveswap command examples.

No open issues 🎉

What changed in this PR

Updates liveswap’s operational examples to work from a root SSH session on boxes without sudo, consistent with the guidance in #323.

Changes:

  • Replaces three sudo -u hotserve commands with runuser -u hotserve -- and clarifies that root runs them.
  • Uses env for the XDG_RUNTIME_DIR assignments and keeps each command on one source line for reliable copying.
File Description
liveswap/​README.md Updates health-check and unit-stop examples to use runuser rather than sudo.

Review effort: Balanced

@earthlingdavey
earthlingdavey merged commit 941db0d into main Oct 29, 2026
21 checks passed
@earthlingdavey
earthlingdavey deleted the docs/liveswap-runuser branch October 29, 2026 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants