fix: avoid recursive chown on host bind-mounted data directories#25
Conversation
Co-authored-by: stritti <184547+stritti@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adjusts the container entrypoint permission-fixup logic to avoid recursively chowning host bind-mounted data directories on every start, preventing unintended host-side ownership changes.
Changes:
- Makes
chownconditional on the directory being root-owned (UID 0). - Removes recursive
-Rownership changes (only the directory node is adjusted). - Applies the same guarded behavior to the fleet DB parent directory and removes verbose
lsdebug output.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a611a0410a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
entrypoint.sh
Outdated
| # Only fix ownership when the directory is still owned by root (e.g. just | ||
| # created above or a brand-new Docker-managed volume). This preserves the | ||
| # original ownership on pre-existing bind mounts. | ||
| if [ "$(stat -c '%u' "$DATA_DIR")" = "0" ]; then |
There was a problem hiding this comment.
Verify DATA_DIR is accessible after skipping chown
This guard now leaves any non-root-owned bind mount untouched, but the process is always dropped to UID 1000 (gosu clawmetry), so mounts owned by a different host UID with private permissions (for example 0700/0750) become unreadable or unwritable at runtime. In that scenario the container starts but ClawMetry cannot access its workspace data, which is a regression from the previous behavior that force-fixed ownership; at minimum this path should validate access and fail fast with guidance.
Useful? React with 👍 / 👎.
stritti
left a comment
There was a problem hiding this comment.
Das Umbiegen der Berechtigungen ist ein Sicherheitsproblem. Wie kann das ursprüngliche Problem auf anderer Weise gelöst werden?
Co-authored-by: stritti <184547+stritti@users.noreply.github.com>
Der Ansatz der Runtime-Permission-Fixup (gosu-Pattern) ist in Docker-Entrypoints üblich und sicher, solange die Guards greifen – was wir jetzt haben. Die eigentliche Alternative wäre, den Container nie als root zu starten:
Wenn du diese strengere Variante bevorzugst (kein Root-Start, keine Runtime-chown), kann ich die Umstellung vornehmen. |
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.