fix(installer): keep user_created sticky across re-runs #8
Reference in New Issue
Block a user
No description provided.
Delete Branch "fix/service-user-created-sticky"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What & why
Found by finally running the installer on a real systemd host — a privileged Debian 12 container with systemd as PID 1, installing into
/usr/bin,/etcand/var/libfor real. Phase 2's service registration had never actually been executed before (it needs elevation on Windows and a Linux host for systemd), so this is the first run that exercised it end to end.service::prepareanswers "did this run create the service account", which isfalseon every run after the first — by then the account exists. Recording that verbatim made the field describe the run rather than the state, with two consequences:install.jsonchanged on an otherwise-identical second run, breaking the Phase 1 promise that a re-run with nothing new to do writes nothing.uninstallsilently left behind the account this tool created. It removes only an account the record says it created, so after any secondinstallthe flag wasfalseand the user survived the uninstall forever.Reproduced before the fix, on a host where the installer had unambiguously created the account:
The record now inherits
truefrom a prior record naming the same account. Matching on the name matters: inheriting across a rename would authorize deleting a user this installer never made.This is invisible on Windows, where the SCM's virtual account is never created by us and disappears with the service — which is why three phases of Windows smoke runs never showed it. Same family as the two bugs Phase 1's live run caught (
install.jsonrecording the run's verb, and theBridge.cfgcomparison): a record describing the run instead of the state.How it was tested
fmt/clippy -D warnings/ 138 tests on both platforms, plus a new unit test covering the inherit / don't-inherit / different-account cases.On the real systemd host, after the fix, from a clean slate (
userdel, state dirs removed):installrunicgateway-link.service active, enabled, running asrunicgateway; unit carries bothUOLINK_CONFIGandUOLINK_DB_PATH;sidecar.tomlis600 runicgateway:root; db in/var/lib/runicgatewayowned by the service user;/healthanswers protocol 3; record saysuser_created: trueinstallagaininstall.json unchanged, byte-identical, stilluser_created: truedoctorService runicgateway-link.service active, enabled as runicgateway— first exercise ofservice::observeon systemd; the database row correctly shows/var/lib/…rather than the path the binary would pick aloneuninstallremoved the runicgateway service user; binary removed;sidecar.toml+ database kept; nothing listening on 8080; report written; all 24 overlay files still in the ServUO treeChecklist
AI-assisted contributions (required)
Claude Code (Opus 5). I have reviewed and understand every change, and take responsibility for it. AI-authored commits are marked with aCo-Authored-Bytrailer.License