Skip to content

fix(start-os): use a private temp file for the login banner's db snapshot - #3615

Open
JesseMarkowitz wants to merge 1 commit into
Start9Labs:masterfrom
JesseMarkowitz:fix/motd-private-temp-file
Open

fix(start-os): use a private temp file for the login banner's db snapshot#3615
JesseMarkowitz wants to merge 1 commit into
Start9Labs:masterfrom
JesseMarkowitz:fix/motd-private-temp-file

Conversation

@JesseMarkowitz

Copy link
Copy Markdown

Problem

projects/start-os/build/lib/motd staged its start-cli db dump output at a fixed path:

DB_DUMP="/tmp/startos_db.json"

pam_motd runs the script as root at login, so that file is created root-owned. Every later non-root invocation then fails to write it, and the banner silently degrades to Services: Unknown, WAN: N/A, NTP: Unknown — the exact fields parse_essential_db_info exists to fill.

Reproduced on a 0.4.0.1 box as the start9 user:

start9@orion:~$ /usr/lib/startos/motd
/usr/lib/startos/motd: 7: cannot create /tmp/startos_db.json: Permission denied
    │ Services: Unknown                WAN:     N/A                     │
    │ Local:    192.168.50.204         NTP:     Unknown                 │

It is also a predictable path in a world-writable directory.

Fix

Use mktemp, and remove the file on every exit path. The previous code also leaked the snapshot when start-cli was absent or the dump failed — both of those returned without cleanup.

Verification

Ran the script against a live 0.4.0.1 server with the blocking /tmp/startos_db.json still in place:

  • Before: Services: Unknown, WAN: N/A, NTP: Unknown
  • After: Services: 5/5 running, WAN: 65.78.82.12, NTP: Synced

Also exercised the two failure paths — server unreachable, and start-cli not on PATH. Both degrade to the same banner as before and leave zero temp files behind. sh -n clean.

Two things for a maintainer to confirm

  1. Base branch. CONTRIBUTING.md says to target a next/* branch when the latest release is not a pre-release, and start-os/v0.4.0.1 is tagged. But next/patch still has the pre-monorepo layout (no projects/), so this is based on master instead. Happy to retarget.

  2. Changelog heading. ## [0.4.0.1] is a cut origin tag, so per the root AGENTS.md this entry goes under a new heading — ## [0.4.0.2]. I did not bump the manifests that heading is coupled to, because per VERSION_BUMP.md an OS revision bump also requires a new version/v0_4_0_2.rs migration module and a Current change, which is a release action rather than part of a bug fix. Say the word if you'd rather this land under a different heading.

🤖 Generated with Claude Code

https://claude.ai/code/session_011wQBSdkk5GYtD3LAvCnaGJ

…shot

The motd staged its `start-cli db dump` output at a fixed `/tmp/startos_db.json`.
pam_motd runs the script as root at login, so that file is created root-owned;
every later non-root invocation then fails to write it and the banner silently
degrades to `Services: Unknown`, `WAN: N/A` and `NTP: Unknown`. It is also a
predictable path in a world-writable directory.

Use mktemp, and remove the file on every exit path — the previous code also
leaked the snapshot when `start-cli` was absent or the dump failed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011wQBSdkk5GYtD3LAvCnaGJ
@JesseMarkowitz
JesseMarkowitz force-pushed the fix/motd-private-temp-file branch from 1511e2b to 9da42f1 Compare August 1, 2026 01:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant