Repository navigation
Commit 4106557
Add a diagnostic job that probes process-token and file ownership
Temporarily add a `diag-token` job to `.github/workflows/cygwin-test.yml`
that creates an empty directory through several distinct code paths and
reports the NTFS Owner of each. The intent is to demonstrate empirically
that the Owner asymmetry described in the next commit ("Cover submodule
working trees in safe.directory on Cygwin") falls out of which kinds of
processes appear in the ancestry of the file-creating call -- specifically
whether a Cygwin or Cygwin-derived runtime (`cygwin1.dll` for Cygwin git;
`msys-2.0.dll` loaded by Git for Windows's bundled MSYS2 `sh.exe` for
shell-dispatched subcommands like `git submodule`) has rewritten the
process token's `TokenOwner` field at DLL initialization.
The job runs on `windows-latest` with the same Cygwin install used by
the existing test jobs. It runs two scripts in sequence: the first
through PowerShell, the second through Cygwin's bash. Each test creates
an empty directory and reports its Owner via `Get-Acl` (PowerShell side)
or `stat -c '%U(%u)'` (Cygwin side).
PowerShell-side tests:
- A: PowerShell `New-Item -ItemType Directory`
- B: PowerShell-spawned Git for Windows `git init`
(reports the Owner of both the parent directory and `.git`)
- C: `cmd.exe`-spawned `mkdir`
- G: PowerShell-spawned Git Bash that re-invokes PowerShell, whose
`New-Item` creates the directory -- a Win32-only chain interrupted
by a single Cygwin link in the middle
Cygwin-side tests:
- D: Cygwin `mkdir`
- E: Cygwin-spawned Cygwin `git init`
(reports the Owner of both the parent directory and `.git`)
- F: Cygwin-spawned Git for Windows `git init`
(reports the Owner of both the parent directory and `.git`)
Observed results
----------------
A run of this job on this commit produces:
| Test | Owner of created directory |
| ---- | ----------------------------------------- |
| A | `BUILTIN\Administrators` |
| B | `BUILTIN\Administrators` (both paths) |
| C | `BUILTIN\Administrators` |
| G | `runneradmin` (uid 197108) |
| D | `runneradmin` (uid 197108) |
| E | `runneradmin` (uid 197108) (both paths) |
| F | `runneradmin` (uid 197108) (both paths) |
Tests A, B, and C run in process trees containing only Win32 binaries
(PowerShell, Git for Windows `git.exe`, `cmd.exe`). Their tokens hold
the kernel-default `TokenOwner` for `runneradmin`'s full administrative
access token, which is `BUILTIN\Administrators` because `runneradmin`
is the built-in local Administrator account (RID 500) and
`FilterAdministratorToken=0` exempts it from UAC token filtering.
Test B also reports `BUILTIN\Administrators` for the `git init`-created
`.git`, confirming that `CreateProcessW`'s token duplication propagates
the parent's `TokenOwner` to the child Win32 binary.
Tests D, E, F, and G run with Cygwin's bash somewhere in the parent
chain. Cygwin's `cygheap_user::init` calls
`NtSetInformationToken(hProcToken, TokenOwner, &user_sid, ...)` at DLL
initialization, which rewrites the `TokenOwner` field from
`BUILTIN\Administrators` to the user SID. The mutation is inherited by
every descendant via `CreateProcessW` token duplication.
Tests F and G are the load-bearing cases for the next commit's
mechanism explanation. Test F's child is a Git for Windows `git.exe`,
which performs no token-rewriting of its own but inherits the
already-mutated token from its Cygwin bash parent and produces a
user-owned `.git` directory. Test G strengthens this by replacing
git with a fresh PowerShell that uses its own `New-Item` builtin:
the only Cygwin-family runtime in the chain is the intermediate
`bash.exe`, the entry and exit are both ordinary Win32 shells, and
the resulting directory is still user-owned. So no part of the
mechanism depends on git, MSYS2 sh dispatch, or any property of the
final-link binary -- it depends only on whether *some* process in
the ancestry loaded a Cygwin-family runtime, which carries forward
through every subsequent `CreateProcessW`.
This `diag-token` job, like the `reproduce-safe-dir` matrix added in
the previous commit, is temporary and should be removed before this
work is integrated.
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 8fc41fb commit 4106557
1 file changed
Lines changed: 102 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
105 | 207 | | |
106 | 208 | | |
107 | 209 | | |
| |||
0 commit comments