Skip to content

Commit 137b3dc

Browse files
qfiberclaude
andcommitted
fix(caddy): restore SELinux context on /usr/local/bin/caddy
The Caddy binary is downloaded to a mktemp file under /tmp (tmp_t context) and then moved to /usr/local/bin/caddy. The move preserves the source label, so systemd refused to exec the binary with status 203/EXEC and "Permission denied" on SELinux-enforcing hosts even though the file is mode 755. Switch from `mv` to `install` (which writes a new inode under the destination's context) and add an explicit `restorecon` for belt- and-braces. No-op when SELinux is disabled or restorecon is missing. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent cd08a45 commit 137b3dc

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

bootstrap/10-caddy.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,13 @@ TMP_BIN="$(mktemp)"
3939
curl -fsSL --retry 3 -o "${TMP_BIN}" "${DL_URL}" || die "Failed to download Caddy."
4040
chmod +x "${TMP_BIN}"
4141
"${TMP_BIN}" version >/dev/null 2>&1 || die "Downloaded Caddy is not executable."
42-
mv "${TMP_BIN}" "${CADDY_BIN}"
43-
chmod 755 "${CADDY_BIN}"
42+
install -m 0755 -o root -g root "${TMP_BIN}" "${CADDY_BIN}"
43+
rm -f "${TMP_BIN}"
44+
# mktemp lands the binary under tmp_t — without restoring context, systemd
45+
# refuses to exec it ("Permission denied", status=203/EXEC).
46+
if command -v restorecon >/dev/null 2>&1; then
47+
restorecon -v "${CADDY_BIN}" >/dev/null 2>&1 || true
48+
fi
4449
success "Caddy installed → ${CADDY_BIN} ($("${CADDY_BIN}" version | head -1))"
4550

4651
# -----------------------------------------------------------------------------

0 commit comments

Comments
 (0)