me

/

vinix-ports Public
382 commits 0 issues 0 pull requests 1 contributor Discussions Projects Snippets LOC history Platform CI

Reject native desktop collisions with signed X11 packages

diviocity committed 5 days ago · 6dc096b518cce26d030bba4732f54ac980a54cc9 View patch
Unverified signature 3 files changed +24 -6
tests/FEED.md +1 -1

@@ -176,7 +176,7 @@ python3 tools/release-inputs.py "$arch" "$repo" "$desktop_client" "$desktop_x11_

176176 "$fingerprint" "$vinix_commit" "$release_tag"

177177```

178178

179-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.

179+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.

180180

181181`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`.

182182

tests/native-layer.py +15 -2

@@ -25,9 +25,9 @@ class NativeLayer(unittest.TestCase):

2525 self.package_command = self.root / "usr/bin/pkg"

2626 self.package_command.write_bytes(b"package-owned command")

2727

28- def install(self):

28+ def install(self, seed_roots=()):

2929 receipt = io.StringIO()

30- install_native_layer(self.source, self.root, csv.writer(receipt, delimiter="\t"))

30+ install_native_layer(self.source, self.root, csv.writer(receipt, delimiter="\t"), seed_roots)

3131 receipt.seek(0)

3232 return list(csv.reader(receipt, delimiter="\t"))

3333

@@ -68,6 +68,19 @@ class NativeLayer(unittest.TestCase):

6868 self.install()

6969 self.assertEqual(self.package_command.read_bytes(), b"package-owned command")

7070

71+ def test_refuses_to_replace_a_package_owner_in_the_x11_seed_client(self):

72+ x11_root = self.source.with_name("graphics")

73+ (x11_root / "usr/bin").mkdir(parents=True)

74+ owner = x11_root / "usr/bin/Xvfb-glx"

75+ owner.write_bytes(b"packaged Xvfb")

76+ path = Path("usr/bin/Xvfb-glx")

77+ (self.source / path).symlink_to("vinix-desktop")

78+

79+ with self.assertRaisesRegex(ValueError, "seed client's /usr/bin/Xvfb-glx"):

80+ self.install([x11_root])

81+ self.assertEqual(owner.read_bytes(), b"packaged Xvfb")

82+ self.assertFalse((self.root / path).is_symlink())

83+

7184 def test_refuses_to_traverse_a_destination_symlink(self):

7285 (self.root / "usr/share").symlink_to("bin")

7386 (self.source / "usr/share").mkdir()

tools/stage-image.py +8 -3

@@ -49,7 +49,7 @@ def native_link_target(relative, link):

4949 raise ValueError(f"native link leaves the guest root: /{relative}")

5050

5151

52-def install_native_layer(source, root, table):

52+def install_native_layer(source, root, table, seed_roots=()):

5353 hard_links = {}

5454

5555 def walk(directory, destination):

@@ -60,8 +60,13 @@ def install_native_layer(source, root, table):

6060 raise ValueError(f"native layer touches a reserved path: /{relative}")

6161 info = origin.lstat()

6262 mode = info.st_mode

63+ directory_entry = stat.S_ISDIR(mode)

64+ for seed_root in seed_roots:

65+ seeded = seed_root / relative

66+ if os.path.lexists(seeded) and (not directory_entry or seeded.is_symlink() or not seeded.is_dir()):

67+ raise ValueError(f"native layer conflicts with the seed client's /{relative}")

6368 exists = os.path.lexists(target)

64- if stat.S_ISDIR(mode):

69+ if directory_entry:

6570 if exists and (target.is_symlink() or not target.is_dir()):

6671 raise ValueError(f"native directory shadows a staged file: /{relative}")

6772 if not exists:

@@ -187,7 +192,7 @@ def stage(args):

187192 with manifest.open("x", newline="") as records:

188193 table = csv.writer(records, delimiter="\t", lineterminator="\n")

189194 table.writerow(("path", "type", "mode", "sha256_or_link"))

190- install_native_layer(native, root, table)

195+ install_native_layer(native, root, table, [client / "root" for client in args.seed_client])

191196 if args.release:

192197 release_file = write_directory(root, "etc") / "vinix-release"

193198 with release_file.open("x") as output_file: