You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: the first run fails: RestrictSUIDSGID=yes in pullgate-run@.service blocks the setgid outbox #19
and then the listener logs read the outbox ... permission denied, because the outbox is left as root:pullgate 0700.
Cause: pullgate-run@.service sets RestrictSUIDSGID=yes. That seccomp filter refuses every chmod that sets the setuid or setgid bit, with EPERM. But spool.Ensure (internal/spool/spool.go, the outbox entry) sets the outbox to 0770 | os.ModeSetgid. The tests and the end-to-end test do not run under the unit, so CI did not see it.
Found on 2026-11-16, in the first real install of v0.1.0.
Workaround: a drop-in for the run unit with RestrictSUIDSGID=no.
Proposal
Decide which side changes, and write why in DESIGN.md section 4:
a) The outbox does not need setgid: root writes each outbox file with group pullgate itself (an explicit fchown), so RestrictSUIDSGID=yes can stay. Preferred: it keeps the unit tighter.
b) Keep setgid, and remove RestrictSUIDSGID=yes from pullgate-run@.service, with a comment that says why. Update the systemd-analyze security table in the README.
Done when
A fresh install with the units of contrib/systemd/, with no drop-in, makes the spool and finishes the first pullgate run NAME with no error.
A CI test runs pullgate run under the real pullgate-run@.service sandbox (for example systemd-run --wait -p ... with the unit's settings, or a container with systemd), so a unit setting that breaks a run fails CI.
The listener reads the outbox after that first run (a test covers the modes and owners of DESIGN.md section 4).
The README says what to do on a host that has the v0.1.0 workaround drop-in (remove it after the update).
More on the cause (2026-11-16): RestrictSUIDSGID=no alone is not enough. Then the chmod succeeds, but the kernel clears the setgid bit without an error: root is not in the group pullgate, and pullgate-run@.service has no CAP_FSETID in its CapabilityBoundingSet. The outbox ends as drwxrwx--- root pullgate, so Send writes each message as root:root 0640 and the listener cannot read it (open .../outbox/...: permission denied), and no question reaches Telegram. The run itself logs result=asked, so nothing shows the failure on the root side.
The workaround needs both lines in the drop-in: RestrictSUIDSGID=no and CapabilityBoundingSet=CAP_FSETID.
This makes option a) (no setgid; root sets the group of each outbox file with an explicit fchown to the listener group) more attractive: it needs neither. Add to "Done when": a message that root writes to the outbox can be read by the listener user under the real units (a test that checks the group of the written file, not only the directory mode).
Fixed in #21 (squash commit 1236625). I chose option a): no setgid bit, and RestrictSUIDSGID=yes stays in pullgate-run@.service. Root gives each outbox file the listener's group itself, with fchown on the open file before the rename. The reason is in DESIGN.md section 4 ("No setgid bit on the outbox").
Evidence for each box:
A fresh install with the units of contrib/systemd/, with no drop-in, makes the spool and finishes the first pullgate run NAME with no error. The new CI job "first run under the units" (test/units/first-run.sh) does exactly this on the CI runner, as root, following the README. On the merged code it logs msg=asked ... result=asked, with no ERROR or WARN line.
A CI test runs pullgate run under the real pullgate-run@.service sandbox. The same job starts the real unit with systemctl start pullgate-run@config-repo.service. The first commit of fix: the first run works under RestrictSUIDSGID=yes (no setgid outbox) #21 had only this test, and it failed on the old code with the error of this issue: fix /var/spool/pullgate/config-repo/outbox: chmod /var/spool/pullgate/config-repo/outbox: operation not permitted.
The listener reads the outbox after that first run (a test covers the modes and owners of DESIGN.md section 4). The CI job checks the owners and modes of section 4 (root pullgate 770 for the outbox, root pullgate 640 for its file, and the others). Then it starts the real pullgate-listen.service against a fake Telegram on 127.0.0.1, and checks that the listener sent the question (msg="question sent") and removed the file from the outbox. Go tests: TestOwnersAndModes and TestSendDeny in internal/spool/spool_test.go.
The README says what to do on a host that has the v0.1.0 workaround drop-in. README, "The systemd units" → "Update from 0.1.0": find the drop-in with systemctl cat, remove RestrictSUIDSGID=no, systemctl daemon-reload. The next run takes the setgid bit off the outbox by itself.
Reopened: GitHub closed this on the merge, but the last "Done when" box (the fix is in a released version) is still open. The release PR #18 waits for the owner's OK. Close this after the release.
Activity
groupsky commentedon Nov 16, 2026
More on the cause (2026-11-16):
RestrictSUIDSGID=noalone is not enough. Then thechmodsucceeds, but the kernel clears the setgid bit without an error: root is not in the grouppullgate, andpullgate-run@.servicehas noCAP_FSETIDin itsCapabilityBoundingSet. The outbox ends asdrwxrwx--- root pullgate, soSendwrites each message asroot:root 0640and the listener cannot read it (open .../outbox/...: permission denied), and no question reaches Telegram. The run itself logsresult=asked, so nothing shows the failure on the root side.The workaround needs both lines in the drop-in:
RestrictSUIDSGID=noandCapabilityBoundingSet=CAP_FSETID.This makes option a) (no setgid; root sets the group of each outbox file with an explicit
fchownto the listener group) more attractive: it needs neither. Add to "Done when": a message that root writes to the outbox can be read by the listener user under the real units (a test that checks the group of the written file, not only the directory mode).groupsky commentedon Nov 16, 2026
Fixed in #21 (squash commit 1236625). I chose option a): no setgid bit, and
RestrictSUIDSGID=yesstays inpullgate-run@.service. Root gives each outbox file the listener's group itself, withfchownon the open file before the rename. The reason is in DESIGN.md section 4 ("No setgid bit on the outbox").Evidence for each box:
contrib/systemd/, with no drop-in, makes the spool and finishes the firstpullgate run NAMEwith no error. The new CI job "first run under the units" (test/units/first-run.sh) does exactly this on the CI runner, as root, following the README. On the merged code it logsmsg=asked ... result=asked, with no ERROR or WARN line.pullgate rununder the realpullgate-run@.servicesandbox. The same job starts the real unit withsystemctl start pullgate-run@config-repo.service. The first commit of fix: the first run works under RestrictSUIDSGID=yes (no setgid outbox) #21 had only this test, and it failed on the old code with the error of this issue:fix /var/spool/pullgate/config-repo/outbox: chmod /var/spool/pullgate/config-repo/outbox: operation not permitted.root pullgate 770for the outbox,root pullgate 640for its file, and the others). Then it starts the realpullgate-listen.serviceagainst a fake Telegram on 127.0.0.1, and checks that the listener sent the question (msg="question sent") and removed the file from the outbox. Go tests:TestOwnersAndModesandTestSendDenyininternal/spool/spool_test.go.systemctl cat, removeRestrictSUIDSGID=no,systemctl daemon-reload. The next run takes the setgid bit off the outbox by itself.pullgate --versionfails with "flag provided but not defined" #14 and fix: pullgate-listen.service has no [Install] section, so enable fails and the listener does not start after a reboot #20.Both reviews ran (the security reviewer and a correctness review). What they found and what was fixed is in the description of #21.
groupsky commentedon Nov 16, 2026
Reopened: GitHub closed this on the merge, but the last "Done when" box (the fix is in a released version) is still open. The release PR #18 waits for the owner's OK. Close this after the release.
groupsky commentedon Nov 16, 2026
install.shfrom the tag installed it in a throwaway container, and/usr/local/bin/pullgate --versionprintedpullgate 0.1.1(full output on fix:pullgate --versionfails with "flag provided but not defined" #14).All boxes are met, so I close this issue.