Skip to content

fix: set git safe.directory at system level for non-root container users#1262

Merged
brendan-kellam merged 1 commit into
v5from
brendan/fix-git-system-safe-directory
Jun 2, 2026
Merged

fix: set git safe.directory at system level for non-root container users#1262
brendan-kellam merged 1 commit into
v5from
brendan/fix-git-system-safe-directory

Conversation

@brendan-kellam
Copy link
Copy Markdown
Contributor

Summary

Switches the safe.directory "*" git config in the Dockerfile from --global to --system.

--global writes only to the home directory of the build-time user (/root/.gitconfig). The image intentionally sets no USER directive (see the comment near the entrypoint) and can be run as sourcebot or an arbitrary --user at runtime. In those cases git reads that user's $HOME/.gitconfig, never sees safe.directory, and the "dubious ownership" error this line is meant to prevent still fires.

--system writes to /etc/gitconfig, which is read by every user regardless of who invokes git, so the fix now actually covers all three run modes (root, sourcebot, arbitrary --user).

Risk

Low / net risk reduction:

  • RUN runs as root at build time, so it can write /etc/gitconfig.
  • /etc/gitconfig is created with default umask (644), world-readable, and nothing later chmods /etc, so non-root runtime users can read it.
  • safe.directory is multi-valued and accumulated across config levels, so the lower-precedence system scope can't be clobbered by a user-level gitconfig.

🤖 Generated with Claude Code

Switches the safe.directory "*" config from --global (only written to
/root/.gitconfig) to --system (/etc/gitconfig) so it applies regardless
of which user runs git. The image intentionally sets no USER directive
and can be run as an arbitrary --user, where the global config was never
read, leaving the "dubious ownership" error unfixed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 2, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ed4cc637-9d2f-4f63-870a-aa72ce39b58e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch brendan/fix-git-system-safe-directory

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@brendan-kellam brendan-kellam merged commit dc03e3d into v5 Jun 2, 2026
3 checks passed
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.

1 participant