Skip to content

Commit 3d613a4

Browse files
committed
fix(test): qualify build-dir owner with its domain
The Windows DACL stamps in run-tests-parallel.sh, soak-test.sh and memlab.sh pass the current user to icacls by bare name. Git Bash resolves whoami to coreutils, which prints an unqualified name, and icacls resolves an unqualified name against the machine before the user. On a host whose name equals the user's (COMPUTERNAME=BUILD with user build) the grant lands on an empty principal: BUILD\:(OI)(CI)(F) Combined with the /inheritance:r on the same invocation, the directory ends up granting no usable account. run-tests-parallel.sh then cannot write its own log directory and the wave dies with: build/c/test-logs/results.txt: Permission denied FAIL: test-runner --list-suites exited nonzero Prefix the name with USERDOMAIN when it is set, which makes the account unambiguous, and fall back to the bare name otherwise. SYSTEM and Administrators in the same invocations already use SID form and are unaffected. Signed-off-by: PETRO YAKOVYSHYN <petroyakovyshyn@gmail.com>
1 parent 564d32c commit 3d613a4

3 files changed

Lines changed: 21 additions & 0 deletions

File tree

‎scripts/memlab.sh‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@ if [[ "$BINARY" == *.exe ]] && command -v cygpath >/dev/null 2>&1 &&
3535
! command -v winepath >/dev/null 2>&1; then
3636
WIN_ROOT=$(mktemp -d "$(cygpath "$USERPROFILE")/cbm-memlab.XXXXXX")
3737
WIN_ROOT_W="$(cygpath -w "$WIN_ROOT")"
38+
# Qualify with the domain: a bare name from coreutils `whoami` resolves
39+
# against the machine first, so on a host whose name equals the user's the
40+
# grant lands on an empty principal.
3841
ME="$(whoami | tr -d '\r')"
42+
if [ -n "${USERDOMAIN:-}" ]; then
43+
ME="${USERDOMAIN}\\${ME}"
44+
fi
3945
MSYS2_ARG_CONV_EXCL='*' icacls "$WIN_ROOT_W" /reset /Q >/dev/null 2>&1 || true
4046
if ! MSYS2_ARG_CONV_EXCL='*' icacls "$WIN_ROOT_W" /inheritance:r \
4147
/grant:r "${ME}:(OI)(CI)F" '*S-1-5-18:(OI)(CI)F' '*S-1-5-32-544:(OI)(CI)F' \

‎scripts/run-tests-parallel.sh‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,16 @@ stamp_windows_build_dir() {
5858
esac
5959
local runner_dir_w me norm_out stamp_out reset_out
6060
runner_dir_w="$(cygpath -w "$(dirname "$RUNNER")")"
61+
# Qualify the account with its domain. Git Bash resolves `whoami` to
62+
# coreutils, which prints a bare name, and icacls resolves a bare name
63+
# against the machine first: on a host whose name equals the user's
64+
# (COMPUTERNAME=BUILD, user build) the grant lands on an empty principal
65+
# (BUILD\) and, combined with /inheritance:r above, locks this script out
66+
# of its own log directory.
6167
me="$(whoami | tr -d '\r')"
68+
if [ -n "${USERDOMAIN:-}" ]; then
69+
me="${USERDOMAIN}\\${me}"
70+
fi
6271
# Normalize FIRST: some runner images stamp EXPLICIT (non-inherited)
6372
# Authenticated-Users ACEs onto the workspace tree, which /inheritance:r
6473
# cannot strip and /grant:r does not touch (it replaces only the granted

‎scripts/soak-test.sh‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,13 @@ mkdir -p "$RESULTS_DIR"
7777
soak_stamp_windows_dir() {
7878
local dir_w me output
7979
dir_w="$(cygpath -w "$1")"
80+
# Qualify with the domain: a bare name from coreutils `whoami` resolves
81+
# against the machine first, so on a host whose name equals the user's the
82+
# grant lands on an empty principal.
8083
me="$(whoami | tr -d '\r')"
84+
if [ -n "${USERDOMAIN:-}" ]; then
85+
me="${USERDOMAIN}\\${me}"
86+
fi
8187
if ! output=$(MSYS2_ARG_CONV_EXCL='*' icacls "$dir_w" /reset /Q 2>&1); then
8288
echo "FAIL: soak DACL normalize failed (dir=$dir_w user=$me)" >&2
8389
printf '%s\n' "$output" >&2

0 commit comments

Comments
 (0)