@namzu/sandbox 23.0.1 → 25.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/CHANGELOG.md +290 -0
  2. package/dist/backends/http-worker-client.d.ts +3 -1
  3. package/dist/backends/http-worker-client.d.ts.map +1 -1
  4. package/dist/backends/http-worker-client.js +15 -4
  5. package/dist/backends/http-worker-client.js.map +1 -1
  6. package/dist/index.d.ts +2 -0
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +1 -0
  9. package/dist/index.js.map +1 -1
  10. package/dist/local-virtual-computer/client.d.ts +21 -0
  11. package/dist/local-virtual-computer/client.d.ts.map +1 -0
  12. package/dist/local-virtual-computer/client.js +503 -0
  13. package/dist/local-virtual-computer/client.js.map +1 -0
  14. package/dist/local-virtual-computer/detached-process.d.ts +15 -0
  15. package/dist/local-virtual-computer/detached-process.d.ts.map +1 -0
  16. package/dist/local-virtual-computer/detached-process.js +111 -0
  17. package/dist/local-virtual-computer/detached-process.js.map +1 -0
  18. package/dist/local-virtual-computer/detached-worker.d.ts +11 -0
  19. package/dist/local-virtual-computer/detached-worker.d.ts.map +1 -0
  20. package/dist/local-virtual-computer/detached-worker.js +97 -0
  21. package/dist/local-virtual-computer/detached-worker.js.map +1 -0
  22. package/dist/local-virtual-computer/dialect.d.ts +26 -0
  23. package/dist/local-virtual-computer/dialect.d.ts.map +1 -0
  24. package/dist/local-virtual-computer/dialect.js +61 -0
  25. package/dist/local-virtual-computer/dialect.js.map +1 -0
  26. package/dist/local-virtual-computer/engine.d.ts +63 -0
  27. package/dist/local-virtual-computer/engine.d.ts.map +1 -0
  28. package/dist/local-virtual-computer/engine.js +125 -0
  29. package/dist/local-virtual-computer/engine.js.map +1 -0
  30. package/dist/local-virtual-computer/guest-stdio.d.ts +15 -0
  31. package/dist/local-virtual-computer/guest-stdio.d.ts.map +1 -0
  32. package/dist/local-virtual-computer/guest-stdio.js +330 -0
  33. package/dist/local-virtual-computer/guest-stdio.js.map +1 -0
  34. package/dist/local-virtual-computer/index.d.ts +36 -0
  35. package/dist/local-virtual-computer/index.d.ts.map +1 -0
  36. package/dist/local-virtual-computer/index.js +341 -0
  37. package/dist/local-virtual-computer/index.js.map +1 -0
  38. package/dist/local-virtual-computer/podman-machine.d.ts +17 -0
  39. package/dist/local-virtual-computer/podman-machine.d.ts.map +1 -0
  40. package/dist/local-virtual-computer/podman-machine.js +181 -0
  41. package/dist/local-virtual-computer/podman-machine.js.map +1 -0
  42. package/dist/local-virtual-computer/setup/contract.d.ts +360 -0
  43. package/dist/local-virtual-computer/setup/contract.d.ts.map +1 -0
  44. package/dist/local-virtual-computer/setup/contract.js +3 -0
  45. package/dist/local-virtual-computer/setup/contract.js.map +1 -0
  46. package/dist/local-virtual-computer/setup/elevated.d.ts +78 -0
  47. package/dist/local-virtual-computer/setup/elevated.d.ts.map +1 -0
  48. package/dist/local-virtual-computer/setup/elevated.js +548 -0
  49. package/dist/local-virtual-computer/setup/elevated.js.map +1 -0
  50. package/dist/local-virtual-computer/setup/host.d.ts +12 -0
  51. package/dist/local-virtual-computer/setup/host.d.ts.map +1 -0
  52. package/dist/local-virtual-computer/setup/host.js +93 -0
  53. package/dist/local-virtual-computer/setup/host.js.map +1 -0
  54. package/dist/local-virtual-computer/setup/idle.d.ts +18 -0
  55. package/dist/local-virtual-computer/setup/idle.d.ts.map +1 -0
  56. package/dist/local-virtual-computer/setup/idle.js +38 -0
  57. package/dist/local-virtual-computer/setup/idle.js.map +1 -0
  58. package/dist/local-virtual-computer/setup/image.d.ts +7 -0
  59. package/dist/local-virtual-computer/setup/image.d.ts.map +1 -0
  60. package/dist/local-virtual-computer/setup/image.js +124 -0
  61. package/dist/local-virtual-computer/setup/image.js.map +1 -0
  62. package/dist/local-virtual-computer/setup/index.d.ts +17 -0
  63. package/dist/local-virtual-computer/setup/index.d.ts.map +1 -0
  64. package/dist/local-virtual-computer/setup/index.js +17 -0
  65. package/dist/local-virtual-computer/setup/index.js.map +1 -0
  66. package/dist/local-virtual-computer/setup/limits.d.ts +30 -0
  67. package/dist/local-virtual-computer/setup/limits.d.ts.map +1 -0
  68. package/dist/local-virtual-computer/setup/limits.js +58 -0
  69. package/dist/local-virtual-computer/setup/limits.js.map +1 -0
  70. package/dist/local-virtual-computer/setup/plan.d.ts +8 -0
  71. package/dist/local-virtual-computer/setup/plan.d.ts.map +1 -0
  72. package/dist/local-virtual-computer/setup/plan.js +131 -0
  73. package/dist/local-virtual-computer/setup/plan.js.map +1 -0
  74. package/dist/local-virtual-computer/setup/readiness.d.ts +11 -0
  75. package/dist/local-virtual-computer/setup/readiness.d.ts.map +1 -0
  76. package/dist/local-virtual-computer/setup/readiness.js +320 -0
  77. package/dist/local-virtual-computer/setup/readiness.js.map +1 -0
  78. package/dist/local-virtual-computer/setup/registry.d.ts +18 -0
  79. package/dist/local-virtual-computer/setup/registry.d.ts.map +1 -0
  80. package/dist/local-virtual-computer/setup/registry.js +50 -0
  81. package/dist/local-virtual-computer/setup/registry.js.map +1 -0
  82. package/dist/local-virtual-computer/setup/restart.d.ts +8 -0
  83. package/dist/local-virtual-computer/setup/restart.d.ts.map +1 -0
  84. package/dist/local-virtual-computer/setup/restart.js +60 -0
  85. package/dist/local-virtual-computer/setup/restart.js.map +1 -0
  86. package/dist/local-virtual-computer/setup/resume.d.ts +14 -0
  87. package/dist/local-virtual-computer/setup/resume.d.ts.map +1 -0
  88. package/dist/local-virtual-computer/setup/resume.js +58 -0
  89. package/dist/local-virtual-computer/setup/resume.js.map +1 -0
  90. package/dist/local-virtual-computer/setup/run.d.ts +8 -0
  91. package/dist/local-virtual-computer/setup/run.d.ts.map +1 -0
  92. package/dist/local-virtual-computer/setup/run.js +200 -0
  93. package/dist/local-virtual-computer/setup/run.js.map +1 -0
  94. package/dist/local-virtual-computer/setup/windows-folder.d.ts +11 -0
  95. package/dist/local-virtual-computer/setup/windows-folder.d.ts.map +1 -0
  96. package/dist/local-virtual-computer/setup/windows-folder.js +14 -0
  97. package/dist/local-virtual-computer/setup/windows-folder.js.map +1 -0
  98. package/dist/local-virtual-computer/setup/wsl-package.d.ts +19 -0
  99. package/dist/local-virtual-computer/setup/wsl-package.d.ts.map +1 -0
  100. package/dist/local-virtual-computer/setup/wsl-package.js +242 -0
  101. package/dist/local-virtual-computer/setup/wsl-package.js.map +1 -0
  102. package/dist/local-virtual-computer/setup/wslc-shared.d.ts +27 -0
  103. package/dist/local-virtual-computer/setup/wslc-shared.d.ts.map +1 -0
  104. package/dist/local-virtual-computer/setup/wslc-shared.js +137 -0
  105. package/dist/local-virtual-computer/setup/wslc-shared.js.map +1 -0
  106. package/dist/local-virtual-computer/ssh-forward.d.ts +19 -0
  107. package/dist/local-virtual-computer/ssh-forward.d.ts.map +1 -0
  108. package/dist/local-virtual-computer/ssh-forward.js +179 -0
  109. package/dist/local-virtual-computer/ssh-forward.js.map +1 -0
  110. package/dist/local-virtual-computer/wslc-engine.d.ts +27 -0
  111. package/dist/local-virtual-computer/wslc-engine.d.ts.map +1 -0
  112. package/dist/local-virtual-computer/wslc-engine.js +98 -0
  113. package/dist/local-virtual-computer/wslc-engine.js.map +1 -0
  114. package/local-computer/Dockerfile +99 -0
  115. package/local-computer/app-catalog.cjs +240 -0
  116. package/local-computer/app-native-host.cjs +144 -0
  117. package/local-computer/browser-home.cjs +249 -0
  118. package/local-computer/build-image.mjs +310 -0
  119. package/local-computer/desktop-worker.cjs +477 -0
  120. package/local-computer/entrypoint.sh +161 -0
  121. package/local-computer/home.html +28 -0
  122. package/local-computer/new-tab/home.css +255 -0
  123. package/local-computer/new-tab/home.js +65 -0
  124. package/local-computer/new-tab/manifest.json +12 -0
  125. package/local-computer/new-tab/wordmark.svg +33 -0
  126. package/local-computer/openbox-rc.xml +41 -0
  127. package/local-computer/prepare-home.cjs +121 -0
  128. package/local-computer/tint2rc +44 -0
  129. package/package.json +13 -4
  130. package/src/backends/http-worker-client.ts +31 -3
  131. package/src/index.ts +13 -0
  132. package/src/local-virtual-computer/client.ts +573 -0
  133. package/src/local-virtual-computer/detached-process.ts +133 -0
  134. package/src/local-virtual-computer/detached-worker.ts +124 -0
  135. package/src/local-virtual-computer/dialect.ts +83 -0
  136. package/src/local-virtual-computer/engine.ts +197 -0
  137. package/src/local-virtual-computer/guest-stdio.ts +332 -0
  138. package/src/local-virtual-computer/index.ts +447 -0
  139. package/src/local-virtual-computer/podman-machine.ts +264 -0
  140. package/src/local-virtual-computer/setup/contract.ts +395 -0
  141. package/src/local-virtual-computer/setup/elevated.ts +655 -0
  142. package/src/local-virtual-computer/setup/host.ts +100 -0
  143. package/src/local-virtual-computer/setup/idle.ts +39 -0
  144. package/src/local-virtual-computer/setup/image.ts +159 -0
  145. package/src/local-virtual-computer/setup/index.ts +16 -0
  146. package/src/local-virtual-computer/setup/limits.ts +68 -0
  147. package/src/local-virtual-computer/setup/plan.ts +144 -0
  148. package/src/local-virtual-computer/setup/readiness.ts +386 -0
  149. package/src/local-virtual-computer/setup/registry.ts +50 -0
  150. package/src/local-virtual-computer/setup/restart.ts +64 -0
  151. package/src/local-virtual-computer/setup/resume.ts +65 -0
  152. package/src/local-virtual-computer/setup/run.ts +225 -0
  153. package/src/local-virtual-computer/setup/windows-folder.ts +13 -0
  154. package/src/local-virtual-computer/setup/wsl-package.ts +242 -0
  155. package/src/local-virtual-computer/setup/wslc-shared.ts +147 -0
  156. package/src/local-virtual-computer/ssh-forward.ts +195 -0
  157. package/src/local-virtual-computer/wslc-engine.ts +124 -0
  158. package/worker/server.js +1499 -0
@@ -0,0 +1,548 @@
1
+ import { randomBytes } from 'node:crypto';
2
+ import { mkdir, readFile } from 'node:fs/promises';
3
+ import { posix, win32 } from 'node:path';
4
+ import { trustedWindowsDirectory } from './windows-folder.js';
5
+ /**
6
+ * The one elevated process of a setup plan.
7
+ *
8
+ * Windows PowerShell (a Microsoft-signed program, so the Windows prompt names
9
+ * Microsoft rather than an unknown publisher) is started with
10
+ * `Start-Process -Verb RunAs` and runs a FIXED script handed over with
11
+ * `-EncodedCommand`. There is no script file anyone could edit between the
12
+ * prompt and the run. Values reach the script only as single-quoted PowerShell
13
+ * literals, after being validated here. Inside, only Microsoft tools run:
14
+ * dism.exe, msiexec.exe and Get-FileHash.
15
+ *
16
+ * Exit codes of the elevated script: 0 ok, 3010 restart required,
17
+ * 20 enabling Windows features failed, 21 installing the WSL package failed,
18
+ * 22 the package did not match the pinned digest. The launcher (a second,
19
+ * non-elevated PowerShell) prints `NAMZU_EXIT=<code>` with the child's exit
20
+ * code, 1223 when the person declined the prompt, or `NAMZU_LAUNCH_FAILED`,
21
+ * and exits 0 itself: the command runner keeps no output from a process that
22
+ * exits nonzero, so the code travels on stdout.
23
+ *
24
+ * The elevated child cannot be stopped from here. Aborting the signal stops
25
+ * waiting and stops reading progress; if the person already approved, the
26
+ * elevated steps run to the end.
27
+ */
28
+ export const ELEVATED_EXIT = {
29
+ ok: 0,
30
+ restartRequired: 3010,
31
+ enableFeaturesFailed: 20,
32
+ installWslFailed: 21,
33
+ packageMismatch: 22,
34
+ folderFailed: 23,
35
+ cancelled: 1223,
36
+ };
37
+ const ELEVATED_STEPS = ['enable-windows-features', 'install-wsl'];
38
+ const STANDARD_ADMIN_GROUP_SID = 'S-1-5-32-544';
39
+ const WINDOWS_11_FIRST_BUILD = 22000;
40
+ const POLL_MS = 250;
41
+ /** Windows refuses a command line longer than 32,767 characters. */
42
+ const MAX_COMMAND_LINE = 30000;
43
+ /** Write, append, delete, delete-children, attribute and extended-attribute writes, change permissions, take ownership. */
44
+ const WRITE_RIGHTS_MASK = 0xd0156;
45
+ const PROGRESS_FILE = 'elevated-progress.jsonl';
46
+ /** Quotes, line breaks and control characters, including PowerShell's typographic quotes. */
47
+ const FORBIDDEN_QUOTES = /['"\u2018\u2019\u201A\u201B\u201C\u201D\u201E]/;
48
+ function hasControlCharacter(value) {
49
+ for (let i = 0; i < value.length; i++) {
50
+ const code = value.charCodeAt(i);
51
+ if (code < 0x20 || code === 0x7f)
52
+ return true;
53
+ }
54
+ return false;
55
+ }
56
+ function usesWindowsPaths(directory) {
57
+ return /^[A-Za-z]:[\\/]/.test(directory);
58
+ }
59
+ function psLiteral(value) {
60
+ return `'${value.replace(/'/g, "''")}'`;
61
+ }
62
+ function checkLiteralPath(label, value) {
63
+ if (FORBIDDEN_QUOTES.test(value) || hasControlCharacter(value)) {
64
+ throw new Error(`${label} contains a quote, a line break or a control character.`);
65
+ }
66
+ }
67
+ function inside(api, directory, candidate) {
68
+ const fold = (value) => (api === win32 ? value.toLowerCase() : value);
69
+ const relative = api.relative(fold(api.resolve(directory)), fold(api.resolve(candidate)));
70
+ return relative !== '' && !relative.startsWith('..') && !api.isAbsolute(relative);
71
+ }
72
+ const RUN_ID = /^[0-9a-f]{32}$/;
73
+ const USER_SID_PLACEHOLDER = '@@USER_SID@@';
74
+ /** The encoded elevated script must stay well under what ShellExecute accepts for a RunAs launch. */
75
+ const MAX_INNER_ENCODED = 16000;
76
+ function joinFor(base, ...parts) {
77
+ return (usesWindowsPaths(base) ? win32 : posix).join(base, ...parts);
78
+ }
79
+ /**
80
+ * Validate a request and build both scripts. Exported for tests; the public
81
+ * entry point is {@link runElevatedWslcSteps}. Throws on any request that
82
+ * could put a foreign value into a script.
83
+ */
84
+ export function buildElevatedScripts(request, options = {}) {
85
+ const { steps, wslPackage, host } = request;
86
+ if (host.platform !== 'win32')
87
+ throw new Error('Elevated setup runs only on Windows.');
88
+ if (!Array.isArray(steps) || steps.length === 0) {
89
+ throw new Error('No elevated step was requested.');
90
+ }
91
+ const wanted = new Set(steps);
92
+ if (wanted.size !== steps.length)
93
+ throw new Error('An elevated step was listed twice.');
94
+ for (const step of steps) {
95
+ if (!ELEVATED_STEPS.includes(step))
96
+ throw new Error(`"${String(step)}" is not an elevated step.`);
97
+ }
98
+ if (host.windowsBuild === undefined ||
99
+ !Number.isInteger(host.windowsBuild) ||
100
+ host.windowsBuild < 1) {
101
+ throw new Error('The Windows build is unknown.');
102
+ }
103
+ const isWindows11 = host.windowsBuild >= WINDOWS_11_FIRST_BUILD;
104
+ const stateDirectory = host.stateDirectory;
105
+ const api = usesWindowsPaths(stateDirectory) ? win32 : posix;
106
+ if (!api.isAbsolute(stateDirectory))
107
+ throw new Error('The setup directory is not an absolute path.');
108
+ checkLiteralPath('The setup directory', stateDirectory);
109
+ const runId = options.runId ?? randomBytes(16).toString('hex');
110
+ if (!RUN_ID.test(runId))
111
+ throw new Error('The run id is not 32 hex characters.');
112
+ const windowsDirectory = options.windowsDirectory ?? trustedWindowsDirectory(host.env);
113
+ const progressFile = joinFor(windowsDirectory, 'Temp', `namzu-wsl-${runId}`, PROGRESS_FILE);
114
+ let installBlock = '';
115
+ if (wanted.has('install-wsl')) {
116
+ if (!wslPackage)
117
+ throw new Error('Installing WSL needs the downloaded package.');
118
+ const { path, sha256 } = wslPackage;
119
+ if (!api.isAbsolute(path))
120
+ throw new Error('The WSL package path is not absolute.');
121
+ checkLiteralPath('The WSL package path', path);
122
+ if (!path.toLowerCase().endsWith('.msi'))
123
+ throw new Error('The WSL package is not an .msi file.');
124
+ if (path.split(/[\\/]/).some((segment) => segment === '..' || segment === '.')) {
125
+ throw new Error('The WSL package path is not normalised.');
126
+ }
127
+ if (!inside(api, stateDirectory, path)) {
128
+ throw new Error('The WSL package is not inside the setup directory.');
129
+ }
130
+ if (!/^[0-9a-fA-F]{64}$/.test(sha256))
131
+ throw new Error('The WSL package digest is not a SHA-256.');
132
+ installBlock = installBlockFor(path, sha256.toLowerCase());
133
+ }
134
+ else if (wslPackage !== undefined) {
135
+ throw new Error('A WSL package was given but install-wsl was not requested.');
136
+ }
137
+ const inner = innerScript({
138
+ runId,
139
+ enable: wanted.has('enable-windows-features'),
140
+ install: wanted.has('install-wsl'),
141
+ isWindows11,
142
+ installBlock,
143
+ });
144
+ // A real SID is at most 184 characters; budget for the longest.
145
+ const sample = inner.replace(USER_SID_PLACEHOLDER, 'S-1-5-21'.padEnd(184, '1'));
146
+ if (encodeCommand(sample).length > MAX_INNER_ENCODED) {
147
+ throw new Error('The elevated script is too long.');
148
+ }
149
+ const launcher = launcherScript(inner);
150
+ const launcherArgs = [
151
+ '-NoProfile',
152
+ '-NonInteractive',
153
+ '-ExecutionPolicy',
154
+ 'Bypass',
155
+ '-EncodedCommand',
156
+ encodeCommand(launcher),
157
+ ];
158
+ if (launcherArgs.join(' ').length > MAX_COMMAND_LINE) {
159
+ throw new Error('The elevated script is too long for one command line.');
160
+ }
161
+ return { inner, launcher, launcherArgs, progressFile, isWindows11 };
162
+ }
163
+ export function encodeCommand(script) {
164
+ return Buffer.from(script, 'utf16le').toString('base64');
165
+ }
166
+ function installBlockFor(msi, sha256) {
167
+ return [
168
+ "$cur = 'install-wsl'",
169
+ "Note $cur 'started'",
170
+ `$src = ${psLiteral(msi)}`,
171
+ `$want = ${psLiteral(sha256)}`,
172
+ // The package is copied into a folder only administrators can enter, then
173
+ // hashed and installed from there, so nothing can swap it after the check.
174
+ "$pkg = Join-Path $dir 'pkg'",
175
+ 'if (Test-Path -LiteralPath $pkg) { throw "pkg exists" }',
176
+ 'try {',
177
+ ' $item = Get-Item -LiteralPath $src -Force',
178
+ ' if ($item.Attributes -band [IO.FileAttributes]::ReparsePoint) { throw "link" }',
179
+ ' New-Item -ItemType Directory -Path $pkg | Out-Null',
180
+ ' $pacl = New-Object Security.AccessControl.DirectorySecurity',
181
+ ' $pacl.SetAccessRuleProtection($true, $false)',
182
+ ' foreach ($sid in $adminSids) { $pacl.AddAccessRule((Rule $sid "FullControl" "ContainerInherit,ObjectInherit")) }',
183
+ ' Set-Acl -LiteralPath $pkg -AclObject $pacl',
184
+ ' Test-Folder $pkg $false',
185
+ " $msi = Join-Path $pkg 'wsl.msi'",
186
+ ' Copy-Item -LiteralPath $src -Destination $msi',
187
+ ' $got = (Get-FileHash -LiteralPath $msi -Algorithm SHA256).Hash',
188
+ ' if ($got -ine $want) {',
189
+ " Note $cur 'failed' @{ exitCode = 22 }",
190
+ ` $code = ${ELEVATED_EXIT.packageMismatch}`,
191
+ ' } else {',
192
+ " $msilog = Join-Path $dir 'wsl-install.log'",
193
+ ' if (Test-Path -LiteralPath $msilog) { throw "log exists" }',
194
+ " $args2 = @('/i', ('\"' + $msi + '\"'), '/qn', '/norestart', '/l*v', ('\"' + $msilog + '\"'))",
195
+ " $p = Start-Process -FilePath (Join-Path $sys 'msiexec.exe') -ArgumentList $args2 -Wait -PassThru",
196
+ ' $c = $p.ExitCode',
197
+ ' if ($c -eq 0) {',
198
+ " Note $cur 'finished' @{ result = 'ok' }",
199
+ ' } elseif ($c -eq 3010 -or $c -eq 1641) {',
200
+ ' $restart = $true',
201
+ " Note $cur 'finished' @{ result = 'restart-required' }",
202
+ ' } else {',
203
+ " Note $cur 'failed' @{ exitCode = $c }",
204
+ ` $code = ${ELEVATED_EXIT.installWslFailed}`,
205
+ ' }',
206
+ ' }',
207
+ '} finally {',
208
+ ' Remove-Item -LiteralPath $pkg -Recurse -Force -ErrorAction SilentlyContinue',
209
+ '}',
210
+ ].join('\n');
211
+ }
212
+ function innerScript(parts) {
213
+ const features = parts.isWindows11
214
+ ? ["'VirtualMachinePlatform'"]
215
+ : ["'VirtualMachinePlatform'", "'Microsoft-Windows-Subsystem-Linux'"];
216
+ const lines = [
217
+ "$ErrorActionPreference = 'Stop'",
218
+ // Tools and modules come from the operating system, never from the environment.
219
+ '$sys = [Environment]::SystemDirectory',
220
+ '$win = [Environment]::GetFolderPath([Environment+SpecialFolder]::Windows)',
221
+ '$env:PATH = $sys',
222
+ "$env:PSModulePath = Join-Path $sys 'WindowsPowerShell\\v1.0\\Modules'",
223
+ `$userSid = '${USER_SID_PLACEHOLDER}'`,
224
+ "$adminSids = @('S-1-5-32-544', 'S-1-5-18')",
225
+ 'function Rule($sid, $rights, $inherit) {',
226
+ ' $id = New-Object Security.Principal.SecurityIdentifier $sid',
227
+ " New-Object Security.AccessControl.FileSystemAccessRule($id, $rights, $inherit, 'None', 'Allow')",
228
+ '}',
229
+ 'function Test-Folder($path, $allowUser) {',
230
+ ' $item = Get-Item -LiteralPath $path -Force',
231
+ ' if (-not $item.PSIsContainer -or ($item.Attributes -band [IO.FileAttributes]::ReparsePoint)) { throw "link" }',
232
+ ' $a = Get-Acl -LiteralPath $path',
233
+ ' $owner = $a.GetOwner([Security.Principal.SecurityIdentifier]).Value',
234
+ ' if ($adminSids -notcontains $owner) { throw "owner" }',
235
+ ' if (-not $a.AreAccessRulesProtected) { throw "inherited" }',
236
+ ' foreach ($r in $a.GetAccessRules($true, $true, [Security.Principal.SecurityIdentifier])) {',
237
+ ' $who = $r.IdentityReference.Value',
238
+ ' if ($adminSids -contains $who) { continue }',
239
+ ` if ($allowUser -and $who -eq $userSid -and $r.AccessControlType -eq 'Allow' -and (([int]$r.FileSystemRights -band ${WRITE_RIGHTS_MASK}) -eq 0)) { continue }`,
240
+ ' throw "access"',
241
+ ' }',
242
+ '}',
243
+ '$code = 0',
244
+ '$restart = $false',
245
+ "$cur = ''",
246
+ '$log = $null',
247
+ 'function Note($step, $phase, $extra) {',
248
+ ' try {',
249
+ ' $o = [ordered]@{ step = $step; phase = $phase }',
250
+ ' if ($extra) { foreach ($k in $extra.Keys) { $o[$k] = $extra[$k] } }',
251
+ ' $line = (ConvertTo-Json -InputObject $o -Compress) + "`n"',
252
+ ' [IO.File]::AppendAllText($log, $line, (New-Object Text.UTF8Encoding $false))',
253
+ ' } catch {}',
254
+ '}',
255
+ 'try {',
256
+ // The folder for progress and logs: new, owned by administrators, readable
257
+ // (not writable) by the person who started setup. Elevated code writes
258
+ // nowhere a standard user can write.
259
+ ` $dir = Join-Path $win ('Temp\\namzu-wsl-${parts.runId}')`,
260
+ // Exclusive creation: New-Item without -Force fails when the name exists,
261
+ // so a folder someone else prepared is never adopted. The ACL is applied
262
+ // and then READ BACK: the owner must be an administrator account, the
263
+ // access list must be protected, and nobody but administrators may hold
264
+ // more than read.
265
+ ' New-Item -ItemType Directory -Path $dir | Out-Null',
266
+ ' $acl = New-Object Security.AccessControl.DirectorySecurity',
267
+ ' $acl.SetAccessRuleProtection($true, $false)',
268
+ ' foreach ($sid in $adminSids) { $acl.AddAccessRule((Rule $sid "FullControl" "ContainerInherit,ObjectInherit")) }',
269
+ ' $acl.AddAccessRule((Rule $userSid "Read" "ContainerInherit,ObjectInherit"))',
270
+ ' Set-Acl -LiteralPath $dir -AclObject $acl',
271
+ ' Test-Folder $dir $true',
272
+ " $log = Join-Path $dir 'elevated-progress.jsonl'",
273
+ ' if (Test-Path -LiteralPath $log) { throw "log exists" }',
274
+ ];
275
+ if (parts.enable) {
276
+ lines.push(" $cur = 'enable-windows-features'", " Note $cur 'started'", ' $dismRestart = $false', ` foreach ($name in @(${features.join(', ')})) {`, ' & (Join-Path $sys \'dism.exe\') /online /enable-feature "/featurename:$name" /all /norestart | Out-Null', ' $c = $LASTEXITCODE', ' if ($c -eq 3010) { $dismRestart = $true }', " elseif ($c -ne 0) { Note $cur 'failed' @{ exitCode = $c }; $code = " +
277
+ `${ELEVATED_EXIT.enableFeaturesFailed}; break }`, ' }', ' if ($code -eq 0) {', " if ($dismRestart) { $restart = $true; Note $cur 'finished' @{ result = 'restart-required' } }", " else { Note $cur 'finished' @{ result = 'ok' } }", ' }');
278
+ }
279
+ if (parts.install) {
280
+ lines.push(` if ($code -eq 0) {\n${parts.installBlock
281
+ .split('\n')
282
+ .map((line) => ` ${line}`)
283
+ .join('\n')}\n }`);
284
+ }
285
+ lines.push('} catch {', ` if ($cur -eq 'install-wsl') { $code = ${ELEVATED_EXIT.installWslFailed} } elseif ($cur -eq '') { $code = ${ELEVATED_EXIT.folderFailed} } else { $code = ${ELEVATED_EXIT.enableFeaturesFailed} }`, " Note $cur 'failed' @{ exitCode = 1 }", '}', `if ($code -eq 0 -and $restart) { $code = ${ELEVATED_EXIT.restartRequired} }`, 'exit $code');
286
+ return lines.join('\n');
287
+ }
288
+ function launcherScript(inner) {
289
+ return [
290
+ "$ErrorActionPreference = 'Stop'",
291
+ '$sys = [Environment]::SystemDirectory',
292
+ '$env:PATH = $sys',
293
+ "$env:PSModulePath = Join-Path $sys 'WindowsPowerShell\\v1.0\\Modules'",
294
+ 'try {',
295
+ " $ps = Join-Path $sys 'WindowsPowerShell\\v1.0\\powershell.exe'",
296
+ ' $sid = [Security.Principal.WindowsIdentity]::GetCurrent().User.Value',
297
+ ` $inner = ${psLiteral(inner)}.Replace('${USER_SID_PLACEHOLDER}', $sid)`,
298
+ ' $enc = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($inner))',
299
+ ' $psi = New-Object Diagnostics.ProcessStartInfo',
300
+ ' $psi.FileName = $ps',
301
+ " $psi.Arguments = '-NoProfile -NonInteractive -ExecutionPolicy Bypass -EncodedCommand ' + $enc",
302
+ // Windows looks for DLLs in the working directory before the system ones;
303
+ // never let that be a folder the person can write to.
304
+ ' $psi.WorkingDirectory = $sys',
305
+ " $psi.Verb = 'runas'",
306
+ ' $psi.UseShellExecute = $true',
307
+ " $psi.WindowStyle = 'Hidden'",
308
+ // ShellExecute raises a Win32Exception straight from the declined prompt.
309
+ ' $p = [Diagnostics.Process]::Start($psi)',
310
+ ' $p.WaitForExit()',
311
+ " Write-Output ('NAMZU_EXIT=' + $p.ExitCode)",
312
+ '} catch {',
313
+ ' $e = $_.Exception',
314
+ ' $declined = $false',
315
+ ' while ($e -ne $null) {',
316
+ ` if (($e -is [ComponentModel.Win32Exception] -and $e.NativeErrorCode -eq ${ELEVATED_EXIT.cancelled}) -or $e.Message -match 'cancel+ed by the user') { $declined = $true }`,
317
+ ' $e = $e.InnerException',
318
+ ' }',
319
+ ` if ($declined) { Write-Output 'NAMZU_EXIT=${ELEVATED_EXIT.cancelled}'; exit 0 }`,
320
+ " Write-Output 'NAMZU_LAUNCH_FAILED'",
321
+ '}',
322
+ ].join('\n');
323
+ }
324
+ /** What `whoami /groups` lists for an account: an administrator, even with a filtered token, has the group. */
325
+ export function isAdministratorAccount(whoamiGroupsOutput) {
326
+ for (const row of whoamiGroupsOutput.split(/\r?\n/)) {
327
+ const cells = [...row.matchAll(/"((?:[^"]|"")*)"/g)].map((m) => m[1] ?? '');
328
+ if (cells[2] === STANDARD_ADMIN_GROUP_SID)
329
+ return true;
330
+ }
331
+ return false;
332
+ }
333
+ function isGroupListing(output) {
334
+ return output.split(/\r?\n/).some((row) => /^"[^"]*","[^"]*","S-1-[0-9-]+",/.test(row));
335
+ }
336
+ export function parseProgressLine(line) {
337
+ let value;
338
+ try {
339
+ value = JSON.parse(line.replace(/^\uFEFF/, ''));
340
+ }
341
+ catch {
342
+ return undefined;
343
+ }
344
+ if (typeof value !== 'object' || value === null)
345
+ return undefined;
346
+ const record = value;
347
+ const step = record.step;
348
+ const phase = record.phase;
349
+ if (step !== 'enable-windows-features' && step !== 'install-wsl')
350
+ return undefined;
351
+ if (phase !== 'started' && phase !== 'finished' && phase !== 'failed')
352
+ return undefined;
353
+ const result = record.result === 'ok' || record.result === 'restart-required' ? record.result : undefined;
354
+ const exitCode = typeof record.exitCode === 'number' ? record.exitCode : undefined;
355
+ return { step, phase, result, exitCode };
356
+ }
357
+ /** Map the launcher's answer to an outcome. `standardUser` is only consulted when needed. */
358
+ export function mapElevatedExit(code, steps, failure) {
359
+ switch (code) {
360
+ case ELEVATED_EXIT.ok:
361
+ return { outcome: 'ok' };
362
+ case ELEVATED_EXIT.restartRequired:
363
+ return { outcome: 'restart-required' };
364
+ case ELEVATED_EXIT.cancelled:
365
+ return 'cancelled';
366
+ case ELEVATED_EXIT.enableFeaturesFailed:
367
+ return {
368
+ outcome: 'failed',
369
+ step: 'enable-windows-features',
370
+ code: 'feature-enable-failed',
371
+ exitCode: failure.exitCode ?? code,
372
+ };
373
+ case ELEVATED_EXIT.installWslFailed:
374
+ case ELEVATED_EXIT.packageMismatch:
375
+ return {
376
+ outcome: 'failed',
377
+ step: 'install-wsl',
378
+ code: 'wsl-install-failed',
379
+ exitCode: failure.exitCode ?? code,
380
+ };
381
+ default:
382
+ return {
383
+ outcome: 'failed',
384
+ step: failure.step ?? steps[0] ?? 'enable-windows-features',
385
+ code: 'elevation-failed',
386
+ exitCode: code,
387
+ };
388
+ }
389
+ }
390
+ function progressEvent(line) {
391
+ if (line.phase === 'started')
392
+ return { step: line.step, phase: 'started' };
393
+ if (line.phase === 'finished' && line.result) {
394
+ return { step: line.step, phase: 'finished', result: line.result };
395
+ }
396
+ return undefined;
397
+ }
398
+ function sleepUnlessSettled(ms, settled, signal) {
399
+ return new Promise((resolve) => {
400
+ const timer = setTimeout(done, ms);
401
+ function done() {
402
+ clearTimeout(timer);
403
+ signal?.removeEventListener('abort', done);
404
+ resolve();
405
+ }
406
+ signal?.addEventListener('abort', done, { once: true });
407
+ settled.then(done, done);
408
+ });
409
+ }
410
+ class ProgressTail {
411
+ file;
412
+ onProgress;
413
+ seen = 0;
414
+ failures = [];
415
+ constructor(file, onProgress) {
416
+ this.file = file;
417
+ this.onProgress = onProgress;
418
+ }
419
+ async poll() {
420
+ let text;
421
+ try {
422
+ text = await readFile(this.file, 'utf8');
423
+ }
424
+ catch {
425
+ return;
426
+ }
427
+ const lines = text.split('\n');
428
+ lines.pop(); // the last piece is empty or a line still being written
429
+ for (; this.seen < lines.length; this.seen++) {
430
+ const parsed = parseProgressLine(lines[this.seen]?.trim() ?? '');
431
+ if (!parsed)
432
+ continue;
433
+ if (parsed.phase === 'failed')
434
+ this.failures.push(parsed);
435
+ const event = progressEvent(parsed);
436
+ if (event)
437
+ this.onProgress?.(event);
438
+ }
439
+ }
440
+ }
441
+ /**
442
+ * Names the launcher may inherit. Everything else (runtime hooks such as the
443
+ * profiler, startup-hook and compatibility-layer variables, PATHEXT, module
444
+ * paths, anything a caller or a registry value added) is dropped, because the
445
+ * elevated copy of Windows PowerShell inherits what the launcher has.
446
+ * Values set for the person in the registry (`HKCU\Environment`) reach every
447
+ * process they start and cannot be defended against from here.
448
+ */
449
+ const LAUNCHER_ENV_ALLOW = /^(ComSpec|USERNAME|USERDOMAIN|USERPROFILE|APPDATA|LOCALAPPDATA|ProgramData|ProgramFiles(\(x86\)|W6432)?|CommonProgramFiles(\(x86\)|W6432)?|PROCESSOR_[A-Z]+|NUMBER_OF_PROCESSORS|OS)$/i;
450
+ function underProfile(profile, value) {
451
+ if (!profile || !/^[A-Za-z]:\\/.test(profile))
452
+ return false;
453
+ const fold = (text) => text.replace(/[\\/]+$/, '').toLowerCase();
454
+ return fold(value).startsWith(`${fold(profile)}\\`);
455
+ }
456
+ function launcherEnvironment(host, windowsDirectory) {
457
+ const env = {};
458
+ let profile;
459
+ for (const [name, value] of Object.entries(host.env)) {
460
+ if (/^USERPROFILE$/i.test(name))
461
+ profile = value;
462
+ }
463
+ for (const [name, value] of Object.entries(host.env)) {
464
+ if (value === undefined)
465
+ continue;
466
+ if (LAUNCHER_ENV_ALLOW.test(name))
467
+ env[name] = value;
468
+ else if (/^(TEMP|TMP)$/i.test(name) && underProfile(profile, value))
469
+ env[name] = value;
470
+ }
471
+ return {
472
+ ...env,
473
+ SystemRoot: windowsDirectory,
474
+ windir: windowsDirectory,
475
+ PATH: `${windowsDirectory}\\System32`,
476
+ };
477
+ }
478
+ export const runElevatedWslcSteps = (request) => runElevatedWith(request, {});
479
+ /** {@link runElevatedWslcSteps} with the run id and Windows folder a test pins. */
480
+ export async function runElevatedWith(request, options) {
481
+ const { host, signal, onProgress } = request;
482
+ const scripts = buildElevatedScripts(request, options);
483
+ const steps = request.steps;
484
+ signal?.throwIfAborted();
485
+ await mkdir(host.stateDirectory, { recursive: true });
486
+ const windowsDirectory = options.windowsDirectory ?? trustedWindowsDirectory(host.env);
487
+ const powershell = `${windowsDirectory}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
488
+ const tail = new ProgressTail(scripts.progressFile, onProgress);
489
+ let finished = false;
490
+ const launched = host.runner
491
+ .run(powershell, scripts.launcherArgs, {
492
+ signal,
493
+ env: launcherEnvironment(host, windowsDirectory),
494
+ cwd: `${windowsDirectory}\\System32`,
495
+ })
496
+ .then((output) => ({ ok: true, output }), () => ({ ok: false }))
497
+ .finally(() => {
498
+ finished = true;
499
+ });
500
+ while (!finished) {
501
+ await sleepUnlessSettled(POLL_MS, launched, signal);
502
+ if (signal?.aborted)
503
+ throw signal.reason;
504
+ await tail.poll();
505
+ }
506
+ const settled = await launched;
507
+ if (signal?.aborted)
508
+ throw signal.reason;
509
+ await tail.poll();
510
+ const lastFailure = tail.failures[tail.failures.length - 1] ?? {};
511
+ const fallbackStep = steps[0] ?? 'enable-windows-features';
512
+ const failed = (exitCode) => ({
513
+ outcome: 'failed',
514
+ step: fallbackStep,
515
+ code: 'elevation-failed',
516
+ exitCode,
517
+ });
518
+ let mapped;
519
+ const match = settled.ok ? /NAMZU_EXIT=(-?\d+)/.exec(settled.output) : null;
520
+ if (match?.[1] !== undefined) {
521
+ mapped = mapElevatedExit(Number(match[1]), steps, lastFailure);
522
+ }
523
+ else {
524
+ mapped = 'launch-failed';
525
+ }
526
+ if (mapped === 'cancelled' || mapped === 'launch-failed') {
527
+ // A standard user who cannot supply an administrator's approval reads
528
+ // differently from an administrator who said no.
529
+ const standard = await isStandardUser(host, windowsDirectory, signal);
530
+ if (standard)
531
+ return { outcome: 'needs-administrator' };
532
+ return mapped === 'cancelled' ? { outcome: 'cancelled' } : failed();
533
+ }
534
+ return mapped;
535
+ }
536
+ async function isStandardUser(host, root, signal) {
537
+ try {
538
+ const output = await host.runner.run(`${root}\\System32\\whoami.exe`, ['/groups', '/fo', 'csv', '/nh'], { signal, env: launcherEnvironment(host, root), cwd: `${root}\\System32` });
539
+ // Only a listing that parses and lacks the group shows a standard user;
540
+ // empty or garbled output shows nothing.
541
+ return isGroupListing(output) && !isAdministratorAccount(output);
542
+ }
543
+ catch {
544
+ // Not knowing is not a reason to tell an administrator they are not one.
545
+ return false;
546
+ }
547
+ }
548
+ //# sourceMappingURL=elevated.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"elevated.js","sourceRoot":"","sources":["../../../src/local-virtual-computer/setup/elevated.ts"],"names":[],"mappings":"AAAA,OA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K,WAAW,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAA;IACpE,CAAC;IACD,OAAO,MAAM,CAAA;AACd,CAAC;AAED,KAAK,UAAU,cAAc,CAC5B,IAAmB,EACnB,IAAY,EACZ,MAAoB;IAEpB,IAAI,CAAC;QACJ,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CACnC,GAAG,IAAI,wBAAwB,EAC/B,CAAC,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,EAChC,EAAE,MAAM,EAAE,GAAG,EAAE,mBAAmB,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,IAAI,YAAY,EAAE,CAC1E,CAAA;QACD,wEAAwE;QACxE,yCAAyC;QACzC,OAAO,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAA;IACjE,CAAC;IAAC,MAAM,CAAC;QACR,yEAAyE;QACzE,OAAO,KAAK,CAAA;IACb,CAAC;AACF,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { type CreateWslcSetupHost } from './contract.js';
2
+ /**
3
+ * The processor type of the PC. On Windows a 32-bit process sees its own
4
+ * type in `PROCESSOR_ARCHITECTURE`; the PC's is in `PROCESSOR_ARCHITEW6432`.
5
+ * Neither is `process.arch`, which names the Node build, not the machine.
6
+ */
7
+ export declare function windowsArchitectureOf(env: NodeJS.ProcessEnv): string;
8
+ /** `REG_DWORD 0x1f` becomes 31; anything else is undefined. */
9
+ export declare function parseRegDword(output: string): number | undefined;
10
+ /** The real Windows host, with `overrides` applied. */
11
+ export declare const createWslcSetupHost: CreateWslcSetupHost;
12
+ //# sourceMappingURL=host.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../../src/local-virtual-computer/setup/host.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,mBAAmB,EAAyB,MAAM,eAAe,CAAA;AAW/E;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,CAKpE;AAUD,kEAAkE;AAClE,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGhE;AAED,uDAAuD;AACvD,eAAO,MAAM,mBAAmB,EAAE,mBA0DjC,CAAA"}