From e9ef004605abe667fafa90c9c26864bd6c8597a6 Mon Sep 17 00:00:00 2001 From: diviocity Date: Mon, 30 Nov 2026 12:42:56 +0100 Subject: [PATCH] Supply the locked vpac download account and verify upgrades --- tests/FEED.md | 8 ++++---- tests/accounts-upgrade.py | 37 ++++++++++++++---------------------- vinix-accounts/PKGBUILD.vile | 11 ++++++++++- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/tests/FEED.md b/tests/FEED.md index eaf8d6c..6d81599 100644 --- a/tests/FEED.md +++ b/tests/FEED.md @@ -64,14 +64,14 @@ grep -Fx ID=vinix "$client/root/etc/os-release" ### Preserve account databases on upgrade -The account seed uses the locked root account from Vinix’s own account service. On a builder configured for native vpac builds, this fixture creates two private signed snapshots. The second snapshot adds a vendor group to the package defaults. +The account seed keeps Vinix's locked root account and supplies a locked `nobody` account for vpac downloads. The fixture signs and installs the actual release 1 and release 2 archives in separate repositories. ```sh -PATH="$work:$PATH" python3 tests/accounts-upgrade.py vinix-accounts/PKGBUILD.vile \ - "$work/keys" "$work/accounts-upgrade" x86_64 +PATH="$work:$PATH" python3 tests/accounts-upgrade.py "$old_accounts_archive" \ + "$new_accounts_archive" "$work/keys" "$work/accounts-upgrade" "$arch" ``` -The worker installed the first snapshot, added a locked fixture account and upgraded the same root. vpac kept all three edited databases, retained mode 0600 on shadow and wrote the changed default group to `/etc/group.pacnew`. The receipt at `foundation/receipts/accounts-upgrade-01.log` has SHA-256 `34a898a73168702748ae211a6d1b673a445b99e063f5ed8880583f612d46e294`. +The worker installed and upgraded fresh clients for both target architectures. vpac kept their locally edited databases, retained mode 0600 on shadow and wrote the new defaults into the matching `.pacnew` files. The release 2 cold installs independently validated `nobody` with UID and GID 65534, a locked shadow entry and `/bin/false` as its shell. See `foundation/actual-account-upgrade-02` and `foundation/sandbox-user-accounts-01`, receipt SHA-256 `89fb3e0ec55471b79580ec5fe16d0585f4048a0b36c3157f8c9296a018eabc04` and `21df3c7374876be520ba8fac62f6fb47a46255bac27b7618a56cf1bfc422fb60`. ### Reuse a signed SDK diff --git a/tests/accounts-upgrade.py b/tests/accounts-upgrade.py index d1b8af6..dd7e200 100644 --- a/tests/accounts-upgrade.py +++ b/tests/accounts-upgrade.py @@ -1,7 +1,6 @@ """Upgrade a signed Vinix account seed over locally edited, locked test accounts.""" import argparse from pathlib import Path -import shutil import stat import subprocess @@ -12,16 +11,10 @@ def command(*args): def test(args): args.work.mkdir() - src = args.work / "vinix-accounts" - src.mkdir() - recipe = src / "PKGBUILD.vile" - shutil.copyfile(args.recipe, recipe) - manifest = args.work / "manifest" - command("vpac", "--native-build", recipe, manifest) - old, = manifest.read_text().splitlines() old_feed = args.work / "old-feed" new_feed = args.work / "new-feed" - command("feed", "publish", args.keys, old_feed, args.arch, old) + command("feed", "publish", args.keys, old_feed, args.arch, args.old_package) + command("feed", "publish", args.keys, new_feed, args.arch, args.new_package) client = args.work / "client" command("feed", "install", args.keys, old_feed, args.arch, client, "--fakeroot", "vinix-accounts") etc = client / "root/etc" @@ -32,16 +25,6 @@ def test(args): with path.open("a") as output: output.write(entry + "\n") edited[name] = path.read_bytes() - # Only the private test snapshot changes the packaged default group. - text = recipe.read_text() - start = " #:package, fn() {" - if text.count(start) != 1 or text.count("#:pkgrel, 1,") != 1: - raise ValueError("update fixture must match the original recipe") - text = text.replace("#:pkgrel, 1,", "#:pkgrel, 2,") - recipe.write_text(text.replace(start, start + '\n run("sed", "-i", "$a vendor:x:45001:", "group")')) - command("vpac", "--native-build", recipe, manifest) - new, = manifest.read_text().splitlines() - command("feed", "publish", args.keys, new_feed, args.arch, new) config = (client / "config.vile").read_text() if config.count("/old-feed/") != 1: raise ValueError("expected exactly one initial feed in client configuration") @@ -53,17 +36,25 @@ def test(args): raise RuntimeError(f"local {name} entries changed on upgrade") if stat.S_IMODE((etc / "shadow").stat().st_mode) != 0o600: raise RuntimeError("installed shadow permissions changed") - if "vendor:x:45001:" not in (etc / "group.pacnew").read_text().splitlines(): - raise RuntimeError("new packaged group defaults were not preserved for review") + defaults = { + "passwd": "nobody:x:65534:65534:Unprivileged user:/nonexistent:/bin/false", + "group": "nobody:x:65534:", + "shadow": "nobody:*:0:0:99999:7:::", + } + for name, entry in defaults.items(): + if entry not in (etc / (name + ".pacnew")).read_text().splitlines(): + raise RuntimeError(f"new {name} default was not preserved for review") + if stat.S_IMODE((etc / "shadow.pacnew").stat().st_mode) != 0o600: + raise RuntimeError("new shadow defaults are not private") db = client / "db/local" if not (db / "vinix-accounts-0.1.0-2").is_dir() or (db / "vinix-accounts-0.1.0-1").exists(): raise RuntimeError("account seed version did not upgrade") - print("Account seed upgrade preserved local passwd, group, private shadow and the new group defaults.") + print("Account seed upgrade preserved local passwd, group and private shadow with the new defaults.") if __name__ == "__main__": parser = argparse.ArgumentParser(description=__doc__) - for name in ["recipe", "keys", "work"]: + for name in ("old_package", "new_package", "keys", "work"): parser.add_argument(name, type=lambda path: Path(path).resolve()) parser.add_argument("arch", choices=["x86_64", "aarch64"]) test(parser.parse_args()) diff --git a/vinix-accounts/PKGBUILD.vile b/vinix-accounts/PKGBUILD.vile index a626a28..0267df3 100644 --- a/vinix-accounts/PKGBUILD.vile +++ b/vinix-accounts/PKGBUILD.vile @@ -1,7 +1,7 @@ defpkgbuild(vinix-accounts, #:pkgname, "vinix-accounts", #:pkgver, "0.1.0", - #:pkgrel, 1, + #:pkgrel, 2, #:pkgdesc, "Initial account databases from the Vinix account service", #:arch, [#:any], #:url, "https://github.com/vlang/vinix", @@ -13,10 +13,19 @@ defpkgbuild(vinix-accounts, #:sha256sums, ["79492b90d473e2387338ef1518dfbceb9e3392ae5740235a6696621e42218efa", "7a696fcfba89a55a6d73fa1a03c7f071fad2141340027b17a25db249e26b9be8", "5dffe858d3df0b14106a1bae99da509d4820468fcbb134044627fced7c2534e7"], + #:prepare, fn() { + ; vpac uses this locked account for sandboxed downloads from first boot. + run("sed", "-i", "$a nobody:x:65534:65534:Unprivileged user:/nonexistent:/bin/false", "passwd") + run("sed", "-i", "$a nobody:x:65534:", "group") + run("sed", "-i", "$a nobody:*:0:0:99999:7:::", "shadow") + }, #:check, fn() { run("grep", "-Fx", "root:x:0:0:root:/root:/bin/sh", "passwd") run("grep", "-Fx", "root:x:0:", "group") run("grep", "-Eq", "^root:[!*]", "shadow") + run("grep", "-Fx", "nobody:x:65534:65534:Unprivileged user:/nonexistent:/bin/false", "passwd") + run("grep", "-Fx", "nobody:x:65534:", "group") + run("grep", "-Eq", "^nobody:[!*]", "shadow") }, #:package, fn() { for-each(fn(file) { -- 2.56.1