Skip to content

fix(packaging): let the service user read its own config - #11

Merged
impuls42 merged 1 commit into
mainfrom
fix/postinst-config-ownership
Jul 30, 2026
Merged

fix(packaging): let the service user read its own config#11
impuls42 merged 1 commit into
mainfrom
fix/postinst-config-ownership

Conversation

@impuls42

Copy link
Copy Markdown
Member

The bug

systemctl start labelfab-agent fails on any fresh install:

PermissionError: [Errno 13] Permission denied: '/etc/labelfab/agent.toml'

postinst.sh does chmod 750 /etc/labelfab but never chowns it, so it stays root:root. The unit runs as User=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 because postinst deliberately 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 clean debian:bookworm, then su'd to the service user:

version /etc/labelfab service user can read config config loads
0.2.0 drwxr-x--- root root NO — permission denied PermissionError
0.2.1 drwxr-x--- root labelfab YES OK

Change

Root-owned, group-readable: the agent can read its config, only root can write it.

agent.toml was also shipping 0664 — world-readable. It has no reason to be, even with the MQTT password deliberately held outside it, so it is 0640 now.

The chown of agent.toml is guarded by a -f test: postinst also runs on upgrade, and on a box whose config had been purged the unguarded form would abort the script under set -e.

`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
impuls42 merged commit bbe2a82 into main Jul 30, 2026
1 check passed
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).
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