@linxin666/dsh-win-bash 0.4.13 → 0.4.15

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.
package/README.i18n.yaml CHANGED
@@ -2,5 +2,5 @@
2
2
  # side as of the last confirmed-consistent state. Both languages carry equal authority;
3
3
  # after editing either side, bring the other along and re-record with:
4
4
  # node scripts/verify-docs.mjs --write <dir>
5
- README.md: 72ffe20a242382e5b7f93004a4fdbf0e600c3977
6
- README.zh.md: 5bb459bfa258ebf3da9a6fa81b27e57d16fbcb85
5
+ README.md: 559766d3c5e9f89bebcd54df75c4ec1fe421e30d
6
+ README.zh.md: e5489d2b8ea51fdb53e70121410b85d3c1310b6d
package/README.md CHANGED
@@ -41,8 +41,16 @@ session is what makes that true.
41
41
  - Optionally runs a command as a background job in its own pinned bash process
42
42
  and returns a job id at once, so a long build or watch does not hold the call
43
43
  open or die with the session's shell. See [Background commands](#background-commands).
44
- - Verifies the vendored payload against its SHA256 manifest before the tool is
45
- registered at all; a mismatch refuses the mount.
44
+ - Gives every shell its own private directory under the machine's temp root for
45
+ `TMPDIR`/`TMP`/`TEMP`, and deletes it when that shell ends — on `exit`, on
46
+ timeout or abort, on session disposal, on plugin unload, and when a background
47
+ job settles. Directories a killed host never got to delete are reclaimed on the
48
+ next start, by the pid in their name, so the temp root does not grow one
49
+ directory per shell.
50
+ - Verifies the vendored payload against its SHA256 manifest and publishes a
51
+ verified copy under the DSH home before the tool is registered at all; a
52
+ mismatch refuses the mount, and every shell runs from that copy rather than
53
+ from the package directory.
46
54
  - Replaces the host's own `pwsh` tool on the session's model-facing surface
47
55
  while `win_bash` is registered, so command work goes to bash instead of to
48
56
  the shell a model already knows. See [Which shell to use](#which-shell-to-use).
@@ -237,6 +245,36 @@ same release's full `Git-2.56.0.2-64-bit.tar.bz2`. Every file is registered in
237
245
  text ships beside it. [PROVENANCE.md](PROVENANCE.md) records both source URLs and
238
246
  digests, the curation rules, the payload inventory and the license mapping.
239
247
 
248
+ The tree that runs is a copy, not the packaged one. Windows refuses to rename a
249
+ directory that holds a running executable, and pnpm imports a package by
250
+ renaming a staging directory over it, so a shell started inside
251
+ `node_modules/@linxin666/dsh-win-bash` makes every later update or uninstall of
252
+ this package fail with `ERR_PNPM_EPERM` while it runs. The copy is published at
253
+ `<DSH_HOME>/win-bash/runtime/<payload key>`, where the key comes from the
254
+ checksums manifest: a release that changes only JavaScript reuses the copy
255
+ already there, a copy whose bytes disagree with the manifest is rebuilt before
256
+ anything runs, and an isolated `DSH_HOME` gets its own cache. When that copy
257
+ cannot be written, the verified packaged tree runs instead and one warning line
258
+ says so.
259
+
260
+ Matching the manifest is not enough to make a copy safe to run. A Windows
261
+ mandatory integrity label lives in the file's security descriptor, not in its
262
+ bytes: a data tree carrying an inheritable Low label gives the copied
263
+ `bash.exe` a Low label, and Windows then starts a Low-integrity process even
264
+ from a Medium runner. That process cannot write an ordinary Medium workspace or
265
+ temp directory. Before a copy is reused, before one is published, and again
266
+ after publication, `win_bash` reads the mandatory labels of the directory chain
267
+ and of `bash.exe` through the Windows `icacls` SDDL output. A Low or Untrusted
268
+ tree is never reused and never spawned from; the payload is published into an
269
+ isolated per-user cache root instead (still outside the package), so a stale Low
270
+ cache is abandoned rather than kept alive across restarts and updates. This
271
+ checks metadata only: it never changes a label, a DACL or a token, and it never
272
+ asks the user to lower a workspace label, change the sandbox policy or run DSH
273
+ elevated. If no safe cache root exists, the verified packaged tree runs with an
274
+ explicit warning; only when even that image is labelled Low does the mount fail
275
+ with `unsafe-integrity` and name the `pwsh` fallback. Set
276
+ `DSH_WIN_BASH_RUNTIME_HOME` to override the isolated cache root's parent.
277
+
240
278
  ## Known limitations
241
279
 
242
280
  - Windows x64 only. The payload is a Windows MSYS2 build and the tool refuses
@@ -251,6 +289,11 @@ digests, the curation rules, the payload inventory and the license mapping.
251
289
  - A background job is one command in one process: it has no persistent state
252
290
  across jobs, and it cannot be promoted from a running foreground call
253
291
  (a foreground call that hits `timeoutMs` still stops its shell).
292
+ - The published payload normally lives under `<DSH_HOME>/win-bash/runtime/`,
293
+ and in the isolated per-user cache root when that data tree is labelled Low.
294
+ Each distinct payload keeps one directory there, about 16 MiB, and such a
295
+ directory can be deleted while DSH is stopped: the next mount publishes it
296
+ again.
254
297
 
255
298
  ## Follow-up work
256
299
 
package/README.zh.md CHANGED
@@ -31,7 +31,12 @@ shell 必须持久,因为 shell 是有状态的:一条命令 `cd` 过、expo
31
31
  - 可选地把命令作为后台任务放进它自己的钉死 bash 进程,立即返回 job id,
32
32
  于是长构建或 watch 既不占住这次调用,也不会随会话 shell 一起死。见
33
33
  [后台命令](#后台命令)。
34
- - 工具注册之前先按 SHA256 清单校验随包载荷;摘要不匹配即拒绝挂载。
34
+ - 给每个 shell 一份机器 temp 根下的私有目录(`TMPDIR`/`TMP`/`TEMP`),并在该
35
+ shell 结束时删除它——正常 `exit`、超时或中止、会话销毁、插件卸载,以及后台任务
36
+ 结算时都在内。宿主被强杀、来不及删除的目录,会在下次启动时按目录名里的 pid 回收,
37
+ 因此 temp 根不会每个 shell 攒一个目录。
38
+ - 工具注册之前先按 SHA256 清单校验随包载荷,并把校验过的副本发布到 DSH home
39
+ 下;摘要不匹配即拒绝挂载,且每个 shell 都从该副本启动,而不是从包目录启动。
35
40
  - `win_bash` 注册期间,把宿主自带的 `pwsh` 工具从会话的模型可见面上替换掉,
36
41
  使命令工作落到 bash,而不是落到模型本来就更熟的那个 shell。见
37
42
  [该用哪个 shell](#该用哪个-shell)。
@@ -197,6 +202,26 @@ shell、其 userland 以及精确的 DLL 闭包。同一 release 的两份资产
197
202
  [PROVENANCE.md](PROVENANCE.md) 记录两份来源资产的 URL 与摘要、裁剪规则、载荷清单与
198
203
  许可证对照表。
199
204
 
205
+ 真正运行的是副本,不是包内那棵树。Windows 不允许 rename 一个运行中的可执行文件
206
+ 所在的目录,而 pnpm 导入包正是用 rename 把 staging 目录换成目标目录,所以从
207
+ `node_modules/@linxin666/dsh-win-bash` 里起的 shell,会让此后每次更新或卸载本包
208
+ 都报 `ERR_PNPM_EPERM`,直到它停下。副本发布在
209
+ `<DSH_HOME>/win-bash/runtime/<载荷键>`,键由 checksums 清单导出:只改 JavaScript
210
+ 的发布会复用已有副本,字节与清单不符的副本会在运行之前被重建,独立的 `DSH_HOME`
211
+ 得到自己的缓存。副本写不出来时,改由校验过的包内树运行,并有一条警告说明这一点。
212
+
213
+ 清单匹配还不足以让副本「可以运行」。Windows 强制性完整性标签在文件的安全描述符里,
214
+ 不在字节里:数据树带可继承的 Low 标签时,复制出的 `bash.exe` 也带 Low 标签,于是
215
+ Windows 即使从 Medium runner 启动也会得到 Low 完整性进程,写不了普通 Medium 工作区与
216
+ 临时目录。因此 `win_bash` 在复用副本前、发布副本前、以及发布之后,都会通过 Windows
217
+ `icacls` 的 SDDL 输出核验目录链与 `bash.exe` 的强制性完整性标签。带 Low/Untrusted
218
+ 标签的树不复用、不执行;载荷改为发布到隔离的每用户缓存根(仍在包外),旧 Low 缓存
219
+ 因此被弃用,不会在重启或更新后靠哈希匹配继续存活。这里只读取元数据:不改任何标签、
220
+ DACL 或令牌,也不要求用户降低工作区标签、修改沙箱策略或提权运行 DSH。没有安全候选
221
+ 根时,改由校验过的包内树运行并给出明确警告;只有连包内映像都带 Low 标签,才以
222
+ `unsafe-integrity` 拒绝挂载并指明 `pwsh` 退路。可用 `DSH_WIN_BASH_RUNTIME_HOME`
223
+ 覆盖隔离缓存根的父目录。
224
+
200
225
  ## 已知限制
201
226
 
202
227
  - 仅支持 Windows x64。载荷是 Windows MSYS2 构建,工具在任何其它平台或架构上都拒绝
@@ -209,6 +234,9 @@ shell、其 userland 以及精确的 DLL 闭包。同一 release 的两份资产
209
234
  字节,以及在 provider 留下 spill 文件时完整流在哪里。
210
235
  - 后台任务是「一个进程执行一条命令」:任务之间没有持久状态,也不能由正在跑的前台调用
211
236
  「升级」而来(前台调用到达 `timeoutMs` 时仍然会停掉它的 shell)。
237
+ - 发布的载荷通常位于 `<DSH_HOME>/win-bash/runtime/`;当该数据树带 Low 标签时,
238
+ 改放在隔离的每用户缓存根。每一份不同的载荷在那里保留一个目录(约 16 MiB),DSH
239
+ 停止时可以安全删除它:下一次挂载会重新发布。
212
240
 
213
241
  ## 后续工作
214
242