From 6dc096b518cce26d030bba4732f54ac980a54cc9 Mon Sep 17 00:00:00 2001 From: diviocity Date: Mon, 30 Nov 2026 19:45:41 +0100 Subject: [PATCH] Reject native desktop collisions with signed X11 packages --- tests/FEED.md | 2 +- tests/native-layer.py | 17 +++++++++++++++-- tools/stage-image.py | 11 ++++++++--- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/tests/FEED.md b/tests/FEED.md index 851fe1b..5e5b38f 100644 --- a/tests/FEED.md +++ b/tests/FEED.md @@ -176,7 +176,7 @@ python3 tools/release-inputs.py "$arch" "$repo" "$desktop_client" "$desktop_x11_ "$fingerprint" "$vinix_commit" "$release_tag" ``` -Use `amd64` or `arm64` for `release_arch`. The tool checks the native desktop and login ELF targets, requires the signed seed to contain the installed versions from both clients, and adds the release tag to the initramfs. It writes the initramfs, X11 overlay, build info and checksum files together. The ISO driver checks the checksums and build info against its selected release before building the kernel. +Use `amd64` or `arm64` for `release_arch`. The tool checks the native desktop and login ELF targets, rejects collisions with files from either installed client, requires the signed seed to contain the installed versions from both clients, and adds the release tag to the initramfs. It writes the initramfs, X11 overlay, build info and checksum files together. The ISO driver checks the checksums and build info against its selected release before building the kernel. `python3 tests/release-inputs.py` covers the output format and wrong-architecture rejection. The worker also confirmed the tag in a signed test initramfs and rejected a second client requiring a package missing from the signed seed. See `foundation/ports-release-inputs-contract-02`, receipt SHA-256 `75e7b4ae23a4f0ea27f93dfd740d37d1ed3abc4cfbea906ec957186c65a1e543`. diff --git a/tests/native-layer.py b/tests/native-layer.py index 15ae61f..3afdfff 100644 --- a/tests/native-layer.py +++ b/tests/native-layer.py @@ -25,9 +25,9 @@ class NativeLayer(unittest.TestCase): self.package_command = self.root / "usr/bin/pkg" self.package_command.write_bytes(b"package-owned command") - def install(self): + def install(self, seed_roots=()): receipt = io.StringIO() - install_native_layer(self.source, self.root, csv.writer(receipt, delimiter="\t")) + install_native_layer(self.source, self.root, csv.writer(receipt, delimiter="\t"), seed_roots) receipt.seek(0) return list(csv.reader(receipt, delimiter="\t")) @@ -68,6 +68,19 @@ class NativeLayer(unittest.TestCase): self.install() self.assertEqual(self.package_command.read_bytes(), b"package-owned command") + def test_refuses_to_replace_a_package_owner_in_the_x11_seed_client(self): + x11_root = self.source.with_name("graphics") + (x11_root / "usr/bin").mkdir(parents=True) + owner = x11_root / "usr/bin/Xvfb-glx" + owner.write_bytes(b"packaged Xvfb") + path = Path("usr/bin/Xvfb-glx") + (self.source / path).symlink_to("vinix-desktop") + + with self.assertRaisesRegex(ValueError, "seed client's /usr/bin/Xvfb-glx"): + self.install([x11_root]) + self.assertEqual(owner.read_bytes(), b"packaged Xvfb") + self.assertFalse((self.root / path).is_symlink()) + def test_refuses_to_traverse_a_destination_symlink(self): (self.root / "usr/share").symlink_to("bin") (self.source / "usr/share").mkdir() diff --git a/tools/stage-image.py b/tools/stage-image.py index fc65d76..af79b38 100644 --- a/tools/stage-image.py +++ b/tools/stage-image.py @@ -49,7 +49,7 @@ def native_link_target(relative, link): raise ValueError(f"native link leaves the guest root: /{relative}") -def install_native_layer(source, root, table): +def install_native_layer(source, root, table, seed_roots=()): hard_links = {} def walk(directory, destination): @@ -60,8 +60,13 @@ def install_native_layer(source, root, table): raise ValueError(f"native layer touches a reserved path: /{relative}") info = origin.lstat() mode = info.st_mode + directory_entry = stat.S_ISDIR(mode) + for seed_root in seed_roots: + seeded = seed_root / relative + if os.path.lexists(seeded) and (not directory_entry or seeded.is_symlink() or not seeded.is_dir()): + raise ValueError(f"native layer conflicts with the seed client's /{relative}") exists = os.path.lexists(target) - if stat.S_ISDIR(mode): + if directory_entry: if exists and (target.is_symlink() or not target.is_dir()): raise ValueError(f"native directory shadows a staged file: /{relative}") if not exists: @@ -187,7 +192,7 @@ def stage(args): with manifest.open("x", newline="") as records: table = csv.writer(records, delimiter="\t", lineterminator="\n") table.writerow(("path", "type", "mode", "sha256_or_link")) - install_native_layer(native, root, table) + install_native_layer(native, root, table, [client / "root" for client in args.seed_client]) if args.release: release_file = write_directory(root, "etc") / "vinix-release" with release_file.open("x") as output_file: -- 2.56.1