Skip to content

Commit 6cc9977

Browse files
qfiberclaude
andcommitted
fix(caddy): re-chown /var/log/caddy after validate, before service start
`caddy validate` is run as root in 10-caddy.sh and side-effects the global log directive — it opens /var/log/caddy/caddy.log, creating the file as root:root 0600. Then when the systemd unit starts caddy under User=caddy, the daemon can't append to its own log and dies with "open /var/log/caddy/caddy.log: permission denied". Add a chown -R caddy:caddy on the log dir right before systemctl restart, so any files validate touched are handed back to the runtime user. Not an SELinux issue: confirmed binary is bin_t, log dir is var_log_t, no AVCs at the failure timestamp. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 137b3dc commit 6cc9977

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

bootstrap/10-caddy.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,12 @@ WantedBy=multi-user.target
458458
EOF
459459
systemctl daemon-reload
460460
systemctl enable caddy
461+
462+
# `caddy validate` (run as root above) opens the global log file and creates
463+
# /var/log/caddy/caddy.log as root:root 0600. Re-chown so the caddy user can
464+
# append to it once systemd starts the daemon under User=caddy.
465+
chown -R "${CADDY_USER}:${CADDY_GROUP}" "${CADDY_LOG}"
466+
461467
systemctl restart caddy
462468
sleep 2
463469
systemctl is-active --quiet caddy || die "Caddy failed to start. journalctl -u caddy -n 50"

0 commit comments

Comments
 (0)