Repository navigation
fix(base): give safe.directory to every user - #152
Merged
Merged
Conversation
`git config --global` ran as root during the build, so the entry landed in /root/.gitconfig and the dev user never read it. A workspace whose files carry another UID then failed git's ownership check with "dubious ownership". Write the entry with `--system` to /etc/gitconfig, and assert in the PR smoke test that dev can read it. Update the Coder template comments and its README to name both sources of git safety: the image's system config and the deployment's GIT_CONFIG_* env vars. Co-authored-by: Tom Grozev <1491414+TomGrozev@users.noreply.github.com>
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.
Summary
The base image wrote git's ownership escape hatch as root, into a file only root reads. Switch the scope one level up, so it reaches every user:
--globalas root/root/.gitconfig--system/etc/gitconfigEffect on a workspace mount:
The Coder template keeps its
GIT_CONFIG_*env vars, because the template can run an older published image. Comments incoder-template/main.tfandcoder-template/README.mdnow name both sources.Evidence
docker run --rm ghcr.io/tomgrozev/devcontainer-base:latest git config --get-all safe.directoryprinted nothing, because the value sat in/root/.gitconfig.After: the
PR Smoke Testsjob assertstest "$(git config --get-all safe.directory)" = "*"as the image's default userdev.No local run: this host has no container runtime.
Merge Danger
Door: two-way. Reverting restores the old scope.
Blast Radius: base image, and every image built on it (elixir, rust, agent layers).
*disables git's ownership check for all repositories in every derived image. The image already intended that with--global; the change only makes the intent take effect. Users who want the check keep it by unsetting the entry or mounting their own/etc/gitconfig.