fix(packaging): make /etc/mcpproxy writable by the service user#825
Merged
Conversation
#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.
Deploying mcpproxy-docs with
|
| 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 |
📦 Build ArtifactsWorkflow Run: View Run Available Artifacts
How to DownloadOption 1: GitHub Web UI (easiest)
Option 2: GitHub CLI gh run download 29083718588 --repo smart-mcp-proxy/mcpproxy-go
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Companion to #822 (thanks @Eun for the report and the unit-file fix).
#822 added
/etc/mcpproxytoReadWritePaths=, lifting systemd'sProtectSystem=strictnamespace restriction. That is necessary but not sufficient — POSIX permissions still apply.nfpm.yamldeclares only the files under/etc/mcpproxy, so the directory is created implicitly. Verified against a.debbuilt from this tree:The service runs as
User=mcpproxy. Saving from the web UI goes throughconfig.SaveConfig→atomicWriteFile, which createsmcp_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. Againstroot:root 0755that isEACCES, andSaveConfig'sos.MkdirAll(dir, 0700)is a no-op on an existing directory, so nothing repairs it at runtime.postinstall.shnow runs:2770: group-writable somcpproxycan write; setgid so files created there keep themcpproxygroup; no access for others (the config holds API keys). This mirrors the existinginstall -dfor/var/lib/mcpproxy, and doing it inpostinstallrather than as an nfpm dir entry also repairs the permissions on hosts that installed an earlier package.Verification:
sh -nandshellcheckclean; built the.debwith nfpm and confirmed the shippedpostinstcarries the line and that the unit file carries #822'sReadWritePaths.