Skip to content

Configure file ownership for mounts & volumes - #26

Merged
codethief merged 5 commits into
masterfrom
feat/file_ownership
Jul 24, 2026
Merged

Configure file ownership for mounts & volumes#26
codethief merged 5 commits into
masterfrom
feat/file_ownership

Conversation

@codethief

Copy link
Copy Markdown
Owner

No description provided.

codethief and others added 5 commits July 24, 2026 15:35
Replace the `user: "<name>"` config field with `guestUser: { uid, gid }`
(numeric), enforced to root ({ uid: 0, gid: 0 }) for now.

We plan on using the UID/GID later for ownership for mounted files &
directories, so this change sidesteps doing guest-side username <> ID mapping.

Also drop the `su` wrapper when launching the guest shell/command: the shell
already runs as root (Gondolin's default exec user) with the guest init
environment, so we exec `/bin/sh` directly. This is shell-behavior-preserving on
Alpine (/bin/sh is ash, which `su root` launched anyway); the switch to bash is
planned as a follow-up. `guestHomeDir` now defaults to a hard-coded `/root`
(inferGuestHomeDir removed) since only root is supported.
Switch the interactive shell and command exec from /bin/sh to /bin/bash,
matching Gondolin's own default command (["/bin/bash", "-i"]). bash is present
in the base image.

Done as its own commit after the `su` removal: while `su` was in place it
launched root's passwd shell (ash on Alpine) regardless of the argv we passed,
so the switch only takes effect now.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The top-level `guestHomeDir` config option is now a field of `guestUser`
(`guestUser.homedir`), keeping all guest-user settings in one place. It still
defaults to /root and is used for `~` expansion in guest paths.

Config layers now deep-merge `guestUser` field-by-field, so a child layer that
sets `guestUser` without `homedir` inherits the parent's homedir rather than
clobbering it.
Add an OwnershipProvider that wraps a VirtualProvider and rewrites the uid/gid
reported to the guest via stat/lstat (and an open handle's stat), so mounted
host files appear owned by a configured owner regardless of their real on-host
ownership. It clones the Stats (preserving the prototype so isDirectory() etc.
keep working) rather than mutating the backend's object, and forwards every
other operation verbatim.

buildVfsMounts/buildVfsVolumes now wrap each provider outermost with
OwnershipProvider, so ownership is consistent across all mount modes (incl.
overlay upper-layer and guest-created files).

Mounts and volumes accept an `owner: { uid?, gid? }` config option; unset fields
fall back to the guest user (`guestUser`). This is display-only — it does not
change on-host ownership, and the guest's chown remains a no-op.

The default owner is now the guest user (root, 0:0), so mounts/volumes no longer
surface the raw host uid/gid — avoiding e.g. git's "detected dubious ownership".
@codethief
codethief force-pushed the feat/file_ownership branch from c59f6f7 to 4edb29f Compare July 24, 2026 13:42
@codethief codethief changed the title Make file ownership customizable for mounts & volumes Configure file ownership for mounts & volumes Jul 24, 2026
@codethief
codethief merged commit cb35e52 into master Jul 24, 2026
4 checks passed
@codethief
codethief deleted the feat/file_ownership branch July 24, 2026 13:43
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