Supply the locked vpac download account and verify upgrades
@@ -64,14 +64,14 @@ grep -Fx ID=vinix "$client/root/etc/os-release"
64
165### Preserve account databases on upgrade
266
3-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.
67+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.
468
569```sh
6-PATH="$work:$PATH" python3 tests/accounts-upgrade.py vinix-accounts/PKGBUILD.vile \
7- "$work/keys" "$work/accounts-upgrade" x86_64
70+PATH="$work:$PATH" python3 tests/accounts-upgrade.py "$old_accounts_archive" \
71+ "$new_accounts_archive" "$work/keys" "$work/accounts-upgrade" "$arch"
872```
973
10-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`.
74+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`.
1175
1276### Reuse a signed SDK
1377
@@ -1,7 +1,6 @@
11"""Upgrade a signed Vinix account seed over locally edited, locked test accounts."""
22import argparse
33from pathlib import Path
4-import shutil
54import stat
65import subprocess
76
@@ -12,16 +11,10 @@ def command(*args):
1211
1312def test(args):
1413 args.work.mkdir()
15- src = args.work / "vinix-accounts"
16- src.mkdir()
17- recipe = src / "PKGBUILD.vile"
18- shutil.copyfile(args.recipe, recipe)
19- manifest = args.work / "manifest"
20- command("vpac", "--native-build", recipe, manifest)
21- old, = manifest.read_text().splitlines()
2214 old_feed = args.work / "old-feed"
2315 new_feed = args.work / "new-feed"
24- command("feed", "publish", args.keys, old_feed, args.arch, old)
16+ command("feed", "publish", args.keys, old_feed, args.arch, args.old_package)
17+ command("feed", "publish", args.keys, new_feed, args.arch, args.new_package)
2518 client = args.work / "client"
2619 command("feed", "install", args.keys, old_feed, args.arch, client, "--fakeroot", "vinix-accounts")
2720 etc = client / "root/etc"
@@ -32,16 +25,6 @@ def test(args):
3225 with path.open("a") as output:
3326 output.write(entry + "\n")
3427 edited[name] = path.read_bytes()
35- # Only the private test snapshot changes the packaged default group.
36- text = recipe.read_text()
37- start = " #:package, fn() {"
38- if text.count(start) != 1 or text.count("#:pkgrel, 1,") != 1:
39- raise ValueError("update fixture must match the original recipe")
40- text = text.replace("#:pkgrel, 1,", "#:pkgrel, 2,")
41- recipe.write_text(text.replace(start, start + '\n run("sed", "-i", "$a vendor:x:45001:", "group")'))
42- command("vpac", "--native-build", recipe, manifest)
43- new, = manifest.read_text().splitlines()
44- command("feed", "publish", args.keys, new_feed, args.arch, new)
4528 config = (client / "config.vile").read_text()
4629 if config.count("/old-feed/") != 1:
4730 raise ValueError("expected exactly one initial feed in client configuration")
@@ -53,17 +36,25 @@ def test(args):
5336 raise RuntimeError(f"local {name} entries changed on upgrade")
5437 if stat.S_IMODE((etc / "shadow").stat().st_mode) != 0o600:
5538 raise RuntimeError("installed shadow permissions changed")
56- if "vendor:x:45001:" not in (etc / "group.pacnew").read_text().splitlines():
57- raise RuntimeError("new packaged group defaults were not preserved for review")
39+ defaults = {
40+ "passwd": "nobody:x:65534:65534:Unprivileged user:/nonexistent:/bin/false",
41+ "group": "nobody:x:65534:",
42+ "shadow": "nobody:*:0:0:99999:7:::",
43+ }
44+ for name, entry in defaults.items():
45+ if entry not in (etc / (name + ".pacnew")).read_text().splitlines():
46+ raise RuntimeError(f"new {name} default was not preserved for review")
47+ if stat.S_IMODE((etc / "shadow.pacnew").stat().st_mode) != 0o600:
48+ raise RuntimeError("new shadow defaults are not private")
5849 db = client / "db/local"
5950 if not (db / "vinix-accounts-0.1.0-2").is_dir() or (db / "vinix-accounts-0.1.0-1").exists():
6051 raise RuntimeError("account seed version did not upgrade")
61- print("Account seed upgrade preserved local passwd, group, private shadow and the new group defaults.")
52+ print("Account seed upgrade preserved local passwd, group and private shadow with the new defaults.")
6253
6354
6455if __name__ == "__main__":
6556 parser = argparse.ArgumentParser(description=__doc__)
66- for name in ["recipe", "keys", "work"]:
57+ for name in ("old_package", "new_package", "keys", "work"):
6758 parser.add_argument(name, type=lambda path: Path(path).resolve())
6859 parser.add_argument("arch", choices=["x86_64", "aarch64"])
6960 test(parser.parse_args())
@@ -1,7 +1,7 @@
11defpkgbuild(vinix-accounts,
22 #:pkgname, "vinix-accounts",
33 #:pkgver, "0.1.0",
4- #:pkgrel, 1,
4+ #:pkgrel, 2,
55 #:pkgdesc, "Initial account databases from the Vinix account service",
66 #:arch, [#:any],
77 #:url, "https://github.com/vlang/vinix",
@@ -13,10 +13,19 @@ defpkgbuild(vinix-accounts,
1313 #:sha256sums, ["79492b90d473e2387338ef1518dfbceb9e3392ae5740235a6696621e42218efa",
1414 "7a696fcfba89a55a6d73fa1a03c7f071fad2141340027b17a25db249e26b9be8",
1515 "5dffe858d3df0b14106a1bae99da509d4820468fcbb134044627fced7c2534e7"],
16+ #:prepare, fn() {
17+ ; vpac uses this locked account for sandboxed downloads from first boot.
18+ run("sed", "-i", "$a nobody:x:65534:65534:Unprivileged user:/nonexistent:/bin/false", "passwd")
19+ run("sed", "-i", "$a nobody:x:65534:", "group")
20+ run("sed", "-i", "$a nobody:*:0:0:99999:7:::", "shadow")
21+ },
1622 #:check, fn() {
1723 run("grep", "-Fx", "root:x:0:0:root:/root:/bin/sh", "passwd")
1824 run("grep", "-Fx", "root:x:0:", "group")
1925 run("grep", "-Eq", "^root:[!*]", "shadow")
26+ run("grep", "-Fx", "nobody:x:65534:65534:Unprivileged user:/nonexistent:/bin/false", "passwd")
27+ run("grep", "-Fx", "nobody:x:65534:", "group")
28+ run("grep", "-Eq", "^nobody:[!*]", "shadow")
2029 },
2130 #:package, fn() {
2231 for-each(fn(file) {