diff --git a/chv-guest/chv-cell.py b/chv-guest/chv-cell.py index dfdd654..41e03bc 100644 --- a/chv-guest/chv-cell.py +++ b/chv-guest/chv-cell.py @@ -131,9 +131,17 @@ def build_nspawn_argv(command, network="veth", "systemd-nspawn", "--quiet", "--machine=%s" % MACHINE, "--directory=/", + # round-11 真机修复:nspawn 255 拒裸 --directory=/(须 + # --ephemeral 或 --volatile),也拒裸 --no-new-privileges + #(把它当作带必填参数的选项,吞掉下一个参数后报错)。 + # 选 --ephemeral:根文件系统快照 + overlay,单元内除 bind + # 出去的目录外一律可写、用完即弃——与 P2“共享客机 rootfs、 + # 只 bind workspace/.codex//run/chv”的设计一致;--volatile + # 会把根置只读,codex 写 $HOME 下非 bind 路径时会失败。 + "--ephemeral", "--as-pid2", "--private-users=%d:%d" % (UID_BASE, UID_COUNT), - "--no-new-privileges", + "--no-new-privileges=yes", "--system-call-filter=%s" % SYSCALL_FILTER, ] for cap in DROP_CAPABILITIES: diff --git a/cloud/tests/test_chv_muse_p2.py b/cloud/tests/test_chv_muse_p2.py index 0beeaa3..c510e40 100644 --- a/cloud/tests/test_chv_muse_p2.py +++ b/cloud/tests/test_chv_muse_p2.py @@ -43,7 +43,12 @@ class CellArgvTest(unittest.TestCase): self.assertIn("--machine=chv-cell", argv) self.assertIn("--directory=/", argv) self.assertIn("--as-pid2", argv) - self.assertIn("--no-new-privileges", argv) + # round-11 真机修复:nspawn 255 拒裸 --no-new-privileges + #(当作带必填参数的选项)与裸 --directory=/(须 + # --ephemeral/--volatile),见 p2.log 的解析报错。 + self.assertIn("--no-new-privileges=yes", argv) + self.assertNotIn("--no-new-privileges", argv) + self.assertIn("--ephemeral", argv) def test_muse_named_capabilities_dropped(self): argv = CELL.build_nspawn_argv(["true"])