Skip to content

fix(packaging): make /etc/mcpproxy writable by the service user#825

Merged
Dumbris merged 1 commit into
mainfrom
fix/etc-mcpproxy-dir-perms
Jul 10, 2026
Merged

fix(packaging): make /etc/mcpproxy writable by the service user#825
Dumbris merged 1 commit into
mainfrom
fix/etc-mcpproxy-dir-perms

Conversation

@Dumbris

@Dumbris Dumbris commented Jul 10, 2026

Copy link
Copy Markdown
Member

Companion to #822 (thanks @Eun for the report and the unit-file fix).

#822 added /etc/mcpproxy to ReadWritePaths=, lifting systemd's ProtectSystem=strict namespace restriction. That is necessary but not sufficient — POSIX permissions still apply.

nfpm.yaml declares only the files under /etc/mcpproxy, so the directory is created implicitly. Verified against a .deb built from this tree:

$ tar -tvf data.tar.gz | grep etc/mcpproxy/
drwxr-xr-x  root root      ./etc/mcpproxy/
-rw-r-----  root mcpproxy  ./etc/mcpproxy/mcp_config.json

The service runs as User=mcpproxy. Saving from the web UI goes through config.SaveConfigatomicWriteFile, which creates mcp_config.json.tmp.<hex> in this directory and renames it over the config — so the service needs write+search on the directory, not just the file. Against root:root 0755 that is EACCES, and SaveConfig's os.MkdirAll(dir, 0700) is a no-op on an existing directory, so nothing repairs it at runtime.

postinstall.sh now runs:

install -d -m 2770 -o root -g mcpproxy /etc/mcpproxy

2770: group-writable so mcpproxy can write; setgid so files created there keep the mcpproxy group; no access for others (the config holds API keys). This mirrors the existing install -d for /var/lib/mcpproxy, and doing it in postinstall rather than as an nfpm dir entry also repairs the permissions on hosts that installed an earlier package.

Verification: sh -n and shellcheck clean; built the .deb with nfpm and confirmed the shipped postinst carries the line and that the unit file carries #822's ReadWritePaths.

#822 added /etc/mcpproxy to ReadWritePaths=, which lifts systemd's
ProtectSystem=strict namespace restriction. That is necessary but not
sufficient: POSIX permissions still apply.

nfpm declares only the FILES under /etc/mcpproxy, so the directory is
created implicitly. Verified against a package built from this tree:

    $ tar -tvf data.tar.gz | grep etc/mcpproxy/
    drwxr-xr-x  root root  ./etc/mcpproxy/
    -rw-r-----  root mcpproxy  ./etc/mcpproxy/mcp_config.json

The service runs as User=mcpproxy. Saving from the web UI goes through
config.SaveConfig -> atomicWriteFile, which creates
mcp_config.json.tmp.<hex> IN THIS DIRECTORY and renames it over the
config — so the service needs write+search on the directory, not just on
the file. Against a root:root 0755 directory that fails with EACCES, and
SaveConfig's os.MkdirAll(dir, 0700) is a no-op on an existing directory,
so nothing repairs it at runtime.

postinstall.sh now does:

    install -d -m 2770 -o root -g mcpproxy /etc/mcpproxy

2770: group-writable so mcpproxy can write; setgid so files created there
keep the mcpproxy group; no access for others, since the config holds API
keys. This mirrors the existing `install -d` for /var/lib/mcpproxy, and
doing it in postinstall rather than as an nfpm dir entry also repairs the
permissions on hosts that installed an earlier package.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying mcpproxy-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 937e172
Status: ✅  Deploy successful!
Preview URL: https://8a075a55.mcpproxy-docs.pages.dev
Branch Preview URL: https://fix-etc-mcpproxy-dir-perms.mcpproxy-docs.pages.dev

View logs

@github-actions

Copy link
Copy Markdown

📦 Build Artifacts

Workflow Run: View Run
Branch: fix/etc-mcpproxy-dir-perms

Available Artifacts

  • archive-darwin-amd64 (28 MB)
  • archive-darwin-arm64 (25 MB)
  • archive-linux-amd64 (16 MB)
  • archive-linux-arm64 (15 MB)
  • archive-windows-amd64 (28 MB)
  • archive-windows-arm64 (25 MB)
  • frontend-dist-pr (0 MB)
  • installer-dmg-darwin-amd64 (22 MB)
  • installer-dmg-darwin-arm64 (19 MB)

How to Download

Option 1: GitHub Web UI (easiest)

  1. Go to the workflow run page linked above
  2. Scroll to the bottom "Artifacts" section
  3. Click on the artifact you want to download

Option 2: GitHub CLI

gh run download 29083718588 --repo smart-mcp-proxy/mcpproxy-go

Note: Artifacts expire in 14 days.

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Dumbris
Dumbris merged commit cc2a749 into main Jul 10, 2026
41 of 42 checks passed
@Dumbris
Dumbris deleted the fix/etc-mcpproxy-dir-perms branch July 10, 2026 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants