Skip to content

Commit 655e4da

Browse files
EliahKaganclaude
andcommitted
Add Win32 NTFS Owner view to the Cygwin ownership-display step
The ownership-display step on `cygwin-test.yml` previously reported file ownership only via Cygwin's `ls -ld`. That goes through Cygwin's SID-to-uid mapping (well-known SIDs by RID; machine-local accounts by `0x30000 + RID`). The mapping is deterministic and reversible, so in principle one can recover the actual NTFS Owner SID from what Cygwin prints. But it is a step removed from a direct Win32-API observation, and that distance has made several preceding diagnostic experiments in this chain effectively "Cygwin's view of NTFS ownership," not direct verification that what Cygwin calls `Administrators` really is `BUILTIN\Administrators` (S-1-5-32-544) and what it calls `runneradmin(197108)` really is the local Administrator account (S-1-5-21-...-500). Add a parallel block to the same step that uses Cygwin's interop to shell out to `powershell.exe -Command "(Get-Acl ...).Owner"` for the same set of paths. The output is the NTAccount form (`BUILTIN\Administrators`, `<machine>\runneradmin`, etc.) of the SID Win32 itself records, with no Cygwin layer in between. This is a permanent addition to the kept ownership-display step -- having both views side by side in every Cygwin CI run is more informative than either alone, and serves as a built-in sanity check on Cygwin's mapping in case it ever drifts. The corresponding step in `pythonpackage.yml` (Windows-native) uses Git Bash MSYS2 `ls`, which has the same class of indirection and arguably benefits from the same enhancement -- left for a follow-up if useful, since the load-bearing observations for the bug this chain fixes are all on the Cygwin runner. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 9825828 commit 655e4da

1 file changed

Lines changed: 35 additions & 1 deletion

File tree

‎.github/workflows/cygwin-test.yml‎

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ jobs:
8484
8585
- name: Show file ownership and safe.directory entries
8686
run: |
87-
echo "==================== File ownership ===================="
87+
echo "==================== File ownership (Cygwin view, ls -ld) ===================="
8888
for p in \
8989
"$(pwd)" \
9090
"$(pwd)/.git" \
@@ -99,6 +99,40 @@ jobs:
9999
fi
100100
done
101101
echo
102+
echo "==================== File ownership (Win32 view, Get-Acl) ===================="
103+
# Cygwin's ls -ld and stat go through Cygwin's SID-to-uid mapping
104+
# (well-known SIDs by their RID, machine-local accounts by 0x30000+RID).
105+
# The mapping is deterministic, but going via Win32 Get-Acl gives the
106+
# NTAccount form of the NTFS Owner SID directly, with no Cygwin layer
107+
# in between -- useful for confirming that what Cygwin reports as
108+
# "Administrators" really is the BUILTIN\Administrators SID (S-1-5-32-544)
109+
# rather than some local-machine account that Cygwin happens to map to
110+
# the same uid. The workflow sets CYGWIN_NOWINPATH=1, so Windows paths
111+
# are not on Cygwin's $PATH; invoke powershell.exe by absolute path.
112+
ps_exe=/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe
113+
if [ -x "$ps_exe" ]; then
114+
for p in \
115+
"$(pwd)" \
116+
"$(pwd)/.git" \
117+
"$(pwd)/git/ext/gitdb" \
118+
"$(pwd)/git/ext/gitdb/.git" \
119+
"$(pwd)/git/ext/gitdb/gitdb/ext/smmap" \
120+
"$(pwd)/git/ext/gitdb/gitdb/ext/smmap/.git" \
121+
"${HOME:-}/.gitconfig"; do
122+
if [ -n "$p" ] && [ -e "$p" ]; then
123+
wp=$(cygpath -w "$p")
124+
# Escape single-quotes for PowerShell single-quoted string literal: ' -> ''
125+
wp_escaped=${wp//\'/\'\'}
126+
owner=$("$ps_exe" -NoProfile -NonInteractive -Command \
127+
"try { (Get-Acl -LiteralPath '${wp_escaped}').Owner } catch { 'ERROR: ' + \$_.Exception.Message }" \
128+
2>/dev/null | tr -d '\r')
129+
printf " %-44s %s\n" "$owner" "$wp"
130+
fi
131+
done
132+
else
133+
echo "($ps_exe not found -- skipping Win32 view)"
134+
fi
135+
echo
102136
echo "==================== safe.directory entries ===================="
103137
git config --global --get-all safe.directory 2>&1 || echo "(none)"
104138

0 commit comments

Comments
 (0)