fix(dev): chown cargo volumes on first run so check works without root #99
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/dev-cargo-volume-perms"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
./dev/cargopreviously launched the rust:slim container with--user uid:gid, but the named volumes mounted at/usr/local/cargo/registry,/usr/local/cargo/git,/cargo-target, and/usr/local/rustupare initialised by Docker with the image-path ownership (root:root in the slim image), so cargo immediately failed withPermission denied (os error 13)trying to write the registry on a fresh clone.The wrapper now starts as root, chowns each volume to the host user only when its current owner is not the host uid (idempotent: first run pays a one-time
chown -R, subsequent runs are noops), then drops privileges viasetpriv --reuid=$UID --regid=$GID --clear-groupsbefore invoking cargo. Running as the host user is preserved for the/workbind mount so Cargo.lock and any other files written into the repo land with the right ownership on the host.The dropped shell also forces
HOME=/tmpbecausesetprivinheritsHOME=/rootfrom the root entrypoint, and/rootis mode 700, which blocks libgit2 (invoked by cargo's build-script fingerprinting) from reading~/.gitconfigand produces a misleadingCould not read repository excludeerror.Test plan
just check-servercompletes successfully.just check-fmtruns to completion (the rustup component install path now succeeds as the dropped user).just check-serverdo not perform another fullchown -R(the ownership check skips the walk).