fix(packaging): let the service user read its own config - #11
Merged
Conversation
`systemctl start labelfab-agent` fails on any fresh install:
PermissionError: [Errno 13] Permission denied: '/etc/labelfab/agent.toml'
postinst did `chmod 750 /etc/labelfab` but never chowned it, so the directory
stayed root:root. The unit runs as User=labelfab, which therefore could not even
traverse it. The package has been unusable out of the box since the unit gained
User=labelfab; the only reason it was not obvious is that postinst deliberately
enables without starting, so the failure waits until an operator finishes setup and
looks like their misconfiguration rather than ours.
Now root-owned and group-readable: the agent can read its config, only root can
write it. The config file itself was also shipping 0664 -- world-readable, which it
has no reason to be even with the password held outside it -- so it is 0640 now.
Demonstrated in a clean bookworm container, installing each .deb and su'ing to the
service user:
0.2.0 /etc/labelfab root:root read: NO -> PermissionError
0.2.1 /etc/labelfab root:labelfab read: YES -> config loads
The chown of agent.toml is guarded by a -f test because postinst also runs on
upgrade, where a purged-config box would otherwise fail the script under `set -e`.
impuls42
added a commit
that referenced
this pull request
Jul 30, 2026
Fresh installs could not start: postinst left /etc/labelfab root-owned so the labelfab service user could not read its own config (#11).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
systemctl start labelfab-agentfails on any fresh install:postinst.shdoeschmod 750 /etc/labelfabbut never chowns it, so it staysroot:root. The unit runs asUser=labelfab, which cannot even traverse the directory — let alone read the config.Found by installing 0.2.0 from apt-tap onto the workshop box and starting the service for the first time.
The package has been unusable out of the box since the unit gained
User=labelfab. It stayed hidden becausepostinstdeliberately enables-but-does-not-start, so the failure surfaces later, during operator setup, where it reads like their misconfiguration rather than ours.Verification
Both
.debs built from this tree and installed in a cleandebian:bookworm, thensu'd to the service user:/etc/labelfabdrwxr-x--- root rootPermissionErrordrwxr-x--- root labelfabChange
Root-owned, group-readable: the agent can read its config, only root can write it.
agent.tomlwas also shipping0664— world-readable. It has no reason to be, even with the MQTT password deliberately held outside it, so it is0640now.The
chownofagent.tomlis guarded by a-ftest:postinstalso runs on upgrade, and on a box whose config had been purged the unguarded form would abort the script underset -e.