Skip to content

Commit cc2a749

Browse files
authored
fix(packaging): make /etc/mcpproxy writable by the service user (#825)
Companion to #822. That PR added /etc/mcpproxy to ReadWritePaths=, lifting systemd's ProtectSystem=strict namespace restriction — necessary but not sufficient, because POSIX permissions still apply. nfpm declares only the FILES under /etc/mcpproxy, so the directory ships implicitly as root:root 0755 (verified against a .deb built from this tree). The service runs as User=mcpproxy, and SaveConfig -> atomicWriteFile creates mcp_config.json.tmp.<hex> in that directory before renaming it, so the service needs write+search on the directory itself. os.MkdirAll(dir, 0700) is a no-op on an existing directory, so nothing repaired it at runtime. postinstall.sh now runs: install -d -m 2770 -o root -g mcpproxy /etc/mcpproxy 2770: group-writable for mcpproxy, setgid so new files keep the group, no access for others (the config holds API keys). Mirrors the existing install -d for /var/lib/mcpproxy, and repairs permissions on hosts upgrading from an earlier package.
1 parent 8498555 commit cc2a749

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

packaging/linux/postinstall.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,22 @@ set -e
66

77
install -d -m 0750 -o mcpproxy -g mcpproxy /var/lib/mcpproxy
88

9+
# /etc/mcpproxy must be writable by the service, not just readable. Saving from
10+
# the web UI goes through config.SaveConfig -> atomicWriteFile, which creates
11+
# mcp_config.json.tmp.<hex> IN THIS DIRECTORY and renames it over the config —
12+
# so the mcpproxy user needs write+search on the directory itself, not merely
13+
# on the file. nfpm creates /etc/mcpproxy implicitly (root:root 0755) because
14+
# only the files inside it are declared, which left the service unable to
15+
# create the temp file. Adding /etc/mcpproxy to ReadWritePaths= in the unit
16+
# (PR #822) lifts systemd's ProtectSystem=strict namespace restriction; this
17+
# lifts the POSIX one. Both are required.
18+
#
19+
# 2770: group-writable so mcpproxy can write, setgid so files created here keep
20+
# the mcpproxy group, and no access for others (the config holds API keys).
21+
# Doing it here rather than as an nfpm dir entry also repairs the permissions
22+
# on hosts that installed an earlier package.
23+
install -d -m 2770 -o root -g mcpproxy /etc/mcpproxy
24+
925
if command -v systemctl >/dev/null 2>&1; then
1026
systemctl daemon-reload || true
1127
if [ -d /run/systemd/system ]; then

0 commit comments

Comments
 (0)