Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions bin/omarchy-windows-vm
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,12 @@ mounted_leaf_matches() {
actual=$(stat -Lc '%d:%i' "$stable" 2>/dev/null) || return 1
owner=$(stat -Lc '%u' "$stable" 2>/dev/null) || return 1
mode=$(stat -Lc '%a' "$stable" 2>/dev/null) || return 1
[[ $actual == "$identity" && $owner == "$CALLER_UID" && $mode == 700 ]]
# dockur re-applies mode 2777 to the shared source on every start (Samba
# guest share), and btrfs does not clear the resulting setgid bit with a
# plain octal chmod (2777/2700 persist). Require only that the caller owns
# the source and retains full owner rwx, tolerating the setgid/guest bits
# the container intentionally applies while keeping identity checks strict.
[[ $actual == "$identity" && $owner == "$CALLER_UID" && $(( (8#$mode & 8#0700) == 8#0700 )) == 1 ]]
}

bind_mount_leaf() {
Expand Down Expand Up @@ -580,14 +585,17 @@ prepare_caller_mounts() {
# Privacy is an explicit preflight step for both already-pinned sources, not
# a side effect halfway through the two-mount transaction. Old umask-022
# installs are hardened together before either Docker-facing anchor changes.
# btrfs retains the setgid bit set by dockur's 2777 chmod on the shared
# source even after the octal chmod below, so accept any owner-rwx mode
# (2777/2700) here rather than demanding the exact private 0700.
chmod 0700 -- "/proc/$BASHPID/fd/$storage_fd" "/proc/$BASHPID/fd/$shared_fd" || {
exec {storage_fd}<&-
exec {shared_fd}<&-
return 1
}
storage_mode=$(stat -Lc '%a' "/proc/$BASHPID/fd/$storage_fd" 2>/dev/null) || storage_mode=""
shared_mode=$(stat -Lc '%a' "/proc/$BASHPID/fd/$shared_fd" 2>/dev/null) || shared_mode=""
if [[ $storage_mode != 700 || $shared_mode != 700 ]]; then
if [[ $(( (8#$storage_mode & 8#0700) == 8#0700 )) != 1 || $(( (8#$shared_mode & 8#0700) == 8#0700 )) != 1 ]]; then
exec {storage_fd}<&-
exec {shared_fd}<&-
return 1
Expand Down
13 changes: 13 additions & 0 deletions test/shell.d/windows-vm-mount-boundary-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,19 @@ chown root:root "$USERS_DIR"
mounts_ready || fail "restored production boundaries were rejected"
pass "root rejects wrong-owned and group-writable production mount boundaries without mutation"

# dockur sets an empty /shared bind to 2777 for Samba guest access on every
# start; btrfs keeps the setgid bit even after an octal chmod. The final guard
# must tolerate the tolerant owner-rwx shared mode instead of failing the VM.
# Reinstating exact 0700 must likewise stay accepted, proving the check was
# loosened only wide enough to cover the container-applied mode.
chmod 2777 /home/shared-target
mounts_ready || fail "final guard rejected a dockur-style 2777 shared source"
restored_mode=$(command stat -Lc '%a' /home/shared-target)
[[ $restored_mode == 2777 ]] || fail "shared source unexpectedly changed while testing 2777 tolerance"
chmod 0700 /home/shared-target
mounts_ready || fail "final guard rejected a hardened 0700 shared source"
pass "dockur 2777 shared mode is tolerated while exact 0700 stays accepted"

expected_space=$(command df -P -- /home/storage-target | awk 'NR==2 {print int($4/1024/1024)}')
actual_space=$(available_storage_gb)
[[ $actual_space == "$expected_space" ]] || fail "disk-space helper did not measure the storage target filesystem"
Expand Down