fix(agent): generate systemd-safe bwrap ExecStart #11
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/agent-systemd-unit-quoting"
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?
Problem (P1)
Sandboxed (bwrap/netns) deploys failed at the
systemctl restartstep withUnit … has a bad unit file setting. systemd's command lexer rejected the generatedExecStartasUnbalanced quotingand dropped the directive, so the unit had noExecStartand never started.Root cause: the agent emitted an inline
/bin/bash -c 'exec 11< <(printf "%s" "…") … bwrap --file 11 /etc/resolv.conf …'wrapper verbatim intoExecStart. The embedded multiline file content, unescaped", and literal%swere parsed by systemd before bash ever saw them.Fix
bash -c+ FD-passing (exec NN< <(printf …)→bwrap --file NN) entirely; bind/etc/resolv.conf,/etc/hosts,/etc/passwddirectly via--ro-bind-tryso no multiline content reaches the unit file.systemdExecArg(doubles%→%%, escapes quotes/backslashes/whitespace)./usr/bin/nsenter; real uid/gid viausermgr.AppUserIDs; working resolver viaHostResolvConfPath; rewrite loopback URLs in env for the sandbox netns; iptables INPUT rule for host access.Verification
go test ./internal/sandbox/... ./internal/deploy/... ./internal/usermgr/...→ okgo build ./...→ cleanTestBwrapExecLinenow asserts the exec line embeds noprintf/multiline content.Fixes the P1 in
docs/field-reports/2026-06-08-agent-systemd-unit-quoting-bug.md.Note: the agent binary is deployed to nodes manually (no auto-update), so nodes still run the broken agent until rebuilt + redeployed after merge.