Verifying an update (sets and packages) -- saved documentation (t0078)
Read and measured 2026-11-14.  Sources: src/distrib/sets/makesums (v1.19),
src/external/bsd/pkg_install/dist/lib/pkg_install.conf.5.in,
src/external/bsd/pkg_install/dist/admin/pkg_admin.1, sysupgrade-1.5
(build/distfiles/sysupgrade-1.5.tar.gz, sysupgrade.sh), tools/pkg-binaries.sh,
the packages in build/packages/amd64/All.  The question: what does the system
check before an update runs as root (mcde_sys_update_apply, ext/src/mcde/lib/
McdeSys/netbsd.c)?  Companion: docs/reference/sysupgrade.txt (t0055).

1. signify(1) is NOT in the tree.
   `git ls-files src | grep -ci signify` -> 0.  pkgsrc has security/signify and
   security/asignify (ls pkgsrc/security), not the base system.  The plan in
   t0078 ("SHA512.sig mit signify pruefen") therefore needs signify on the
   target first (a package of the makronix set, installed before the first
   update) -- or the mechanism pkg_install already has (item 3).

2. Sets: nothing signs them, and sysupgrade checks nothing.
   - makesums, header: "two output files (MD5 and SHA512) are produced."  No
     signature; the files sit next to the sets (RELEASEDIR/binary/sets).
   - sysupgrade-1.5 sysupgrade.sh (505 lines): fetches with
     `ftp ${rflag} -o"${local_file}.tmp" "${url}"` (line 215) and unpacks with
     `progress -zf "${set_tgz}" tar -xp -C "${destdir}/" -f -` (line 177).
     `grep -i -E 'sha512|checksum|signify|verif|gpg|cksum'` over the script
     finds nothing: there is no verification step between fetch and unpack.
   - So with an http:// source anyone on the path replaces a set and it is
     unpacked as root; with https:// the server's TLS certificate is the only
     protection, and a file:// source (a stick) is as trusted as the stick.

3. Packages: pkg_install can verify, and the NetBSD packages are not signed.
   - pkg_install.conf(5), VERIFIED_INSTALLATION: "always -- Install package
     only if it has a valid X.509 or OpenPGP signature."  (default: never)
   - pkg_install.conf(5), CERTIFICATE_ANCHOR_PKGS: "Path to the file
     containing the certificates used for validating binary packages.  A
     package is trusted when a certificate chain ends in one of the
     certificates contained in this file.  The certificates must be
     PEM-encoded.  Required when VERIFIED_INSTALLATION is anything other than
     never."
   - pkg_admin(1): "x509-sign-package pkg spkg key cert -- Sign the binary
     package pkg using the key key and the certificate cert, using spkg as
     output file."  Also "gpg-sign-package pkg spkg" and "check-signature
     file ... -- Reports if file is a correctly signed package."
   - MEASURED: none of the 264 packages downloaded from the NetBSD CDN
     (build/packages/amd64/All, tools/pkg-binaries.sh) has a +PKG_HASH,
     +PKG_GPG_SIGNATURE or +PKG_SIGNATURE member (`tar tzf | head -30 | grep`
     over the first 300 archives: 0 hits; first members are +CONTENTS
     +COMMENT +DESC).  Nor do the 128 in build/packages/All.  The repository
     directory https://cdn.netbsd.org/pub/pkgsrc/packages/NetBSD/x86_64/
     11.0_2026Q3/All/ answers 200 for pkg_summary.gz and 404 for SHA512.bz2,
     SHA512.gz, pkg_summary.gz.sig and SHA512.sig (the four names tried; not
     a listing).
   - tools/pkg-binaries.sh says so itself: "The archives are checked against
     FILE_SIZE of the summary (it carries no checksum for them)."  The only
     protection of those downloads is TLS to cdn.netbsd.org plus the size.
   => VERIFIED_INSTALLATION=always cannot be turned on for the NetBSD packages
      as they are.  It can be for packages Makronix signs itself
      (pkg_admin x509-sign-package, a key and certificate of ours).

4. What is settled by this, what is open.
   - Settled: no check exists today (items 2, 3); signify is not in the base
     (item 1); the mechanism for packages is pkg_install's X.509/OpenPGP.
   - Step 4 of the task ("bis dahin http:// verweigern") needs no decision and
     is done in McdeSys: only file:// (and an absolute path) and https://.
   - Open, for Konrad (step 2 of the task): (a) who holds the private key --
     never in the repository, never in a log; (b) sets: signify (then a
     package in the makronix set) or something that is in the base; (c)
     packages: sign the ones we ship with our own X.509 key, or accept TLS to
     the NetBSD CDN for the unmodified binary packages and sign only our own.
   - Not done: step 3 (check before sysupgrade), because the upgrade command
     it hooks into (t0055) is still being built and the signing key is open.
