fix(web): reload Caddy without setuid sudo - #731
Conversation
Authorize configured agent users for only the reload verb on caddy.service through polkit. This keeps self-serve site publishing available inside Codex command namespaces where the sudo wrapper cannot retain its setuid ownership. Remove the built-in Caddy sudo grant and cover both native rendering and the booted NixOS workflow, including negative unit/verb checks.\n\nFixes #726
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (26)
💤 Files with no reviewable changes (3)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe pull request replaces Caddy reload authorization through setuid sudo with a narrow polkit rule. The rule permits configured agent users to reload only ChangesCaddy reload authorization
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Bug fix · Severity of issue fixed: Medium Sequence Diagram(s)sequenceDiagram
participant Agent
participant systemctl
participant systemd
participant Polkit
Agent->>systemctl: Request reload caddy.service
systemctl->>systemd: Send manage-units request
systemd->>Polkit: Evaluate caddy.service and reload
Polkit-->>systemd: Allow configured agent user
systemd-->>Agent: Reload Caddy
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
reloadoncaddy.servicesystemctl reload caddy.servicedirectlyFixes #726.
Security effect
The new policy matches the caller against the configured agent-user list and matches both polkit details:
unit == caddy.serviceandverb == reload. It does not authorize stop, restart, daemon-reload, or actions on any other unit. Avoiding a setuid transition makes the supported reload path usable from Codex command namespaces wheresudoappears owned bynobody:nogroup.Testing
python3 tests/test_agentbox.py— 151 tests pass, 1 environment-dependent skippython3 scripts/check_backend_parity.py— passnix build -L .#checks.x86_64-linux.module-generated-up-to-date .#checks.x86_64-linux.golden-snapshot .#checks.x86_64-linux.one-spec-both-backends .#checks.x86_64-linux.backend-parity .#checks.x86_64-linux.assemble-module-escaping— passnix build -L .#checks.x86_64-linux.web-surface— passThe booted VM test exercises the literal user flow: write a new
~/sites/*.caddyvhost, reload without sudo from the agent's mount namespace, and fetch the new host. It also confirms that the same caller is deniedstop caddy.service,restart caddy.service, andreload fail2ban.service.