diff options
| author | user <user@clank> | 2026-08-29 15:57:54 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-08-29 15:57:54 +0200 |
| commit | 05529c90ff835248f599605f356d679b515eae84 (patch) | |
| tree | 820ad1c8ec4b95059bc775420fa35e7fc1efe4c9 | |
| parent | arch: a self-hosted pacman repository, since the AUR is shut (diff) | |
| download | slosh-05529c90ff835248f599605f356d679b515eae84.tar.gz slosh-05529c90ff835248f599605f356d679b515eae84.tar.xz slosh-05529c90ff835248f599605f356d679b515eae84.zip | |
arch: sign the packages and the database, and say whose key
An ed25519 key made for exactly this -- slosh package signing
<slosh@slosh.foo>, 0F67C909938CFFA8A76B59FD8D69B55A0E9056B9 -- signs every
package and both indexes. The public half travels two ways that would both
have to lie: contrib/arch/slosh.asc in git, and /arch/slosh.asc on the
website; the READMEs walk through pacman-key --add and --lsign-key, and the
[slosh] stanza loses its SigLevel override because pacman's default demands
signatures and now gets them.
contrib/arch-repo pins the fingerprint, refuses to run without the secret
key (an unsigned update would make every enrolled pacman refuse the repo),
and now regenerates the index from the directory every time: repo-add skips
an entry whose version it already has, so after a same-version rebuild an
incremental add left the db describing the previous bytes -- a checksum
mismatch for every client. An index rebuilt from disk cannot disagree with
disk. Verified end to end with a scratch pacman keyring: enrolled key
syncs and downloads under Required DatabaseRequired, unenrolled key is
refused at the database.
| -rw-r--r-- | README.md | 16 | ||||
| -rwxr-xr-x | contrib/arch-repo | 46 | ||||
| -rw-r--r-- | contrib/arch/README.md | 37 | ||||
| -rw-r--r-- | contrib/arch/slosh.asc | 10 | ||||
| -rw-r--r-- | web/index.html | 4 |
5 files changed, 90 insertions, 23 deletions
@@ -31,15 +31,25 @@ sudo make install # optional: /usr/local/bin/slosh (The source build works on a mac too; Homebrew is simply the shorter road there.) -On Arch, a pacman repository serves built packages — in `/etc/pacman.conf`: +On Arch, a pacman repository serves built, signed packages. Enroll the +signing key (fingerprint `0F67C909938CFFA8A76B59FD8D69B55A0E9056B9`; the +same key is [contrib/arch/slosh.asc](contrib/arch/slosh.asc) in git, so the +two copies can be compared): + +```sh +curl -fsSLO https://slosh.foo/arch/slosh.asc +sudo pacman-key --add slosh.asc +sudo pacman-key --lsign-key 0F67C909938CFFA8A76B59FD8D69B55A0E9056B9 +``` + +then, in `/etc/pacman.conf`: ```ini [slosh] -SigLevel = Optional TrustAll Server = https://slosh.foo/arch/$arch ``` -then `pacman -Sy slosh`. Details, and the PKGBUILD for building it yourself: +and `pacman -Sy slosh`. Details, and the PKGBUILD for building it yourself: [contrib/arch](contrib/arch/README.md). ### Windows diff --git a/contrib/arch-repo b/contrib/arch-repo index ca7ceb3..e9f2131 100755 --- a/contrib/arch-repo +++ b/contrib/arch-repo @@ -4,14 +4,21 @@ # so the repo is self-hosted: the same PKGBUILD, published two ways -- as a # file people can makepkg themselves, and as built packages pacman can sync. # -# contrib/arch-repo # build + index for this machine's arch +# contrib/arch-repo # build + sign + index for this arch # ZIG=/path/to/zig contrib/arch-repo # where zig is not /usr/bin/zig # -# The output is dist/arch/<carch>/: the package, and the slosh.db / -# slosh.files indexes repo-add maintains. Publishing is uploading that -# directory to /opt/slosh/arch/<carch>/ on the box (the script prints the -# rsync). makepkg does not cross-compile, so the aarch64 leg of the repo is -# made by running this on an aarch64 machine. +# The output is dist/arch/<carch>/: the package and its .sig, and the +# slosh.db / slosh.files indexes repo-add maintains, also signed. +# Publishing is uploading that directory to /opt/slosh/arch/<carch>/ on the +# box (the script prints the rsync). makepkg does not cross-compile, so the +# aarch64 leg of the repo is made by running this on an aarch64 machine. +# +# Everything is signed with the key below -- the one whose public half is +# contrib/arch/slosh.asc, served at https://slosh.foo/arch/slosh.asc, and +# whose fingerprint the README tells users to check. Pinned by fingerprint +# here so a machine with other keys in its ring cannot sign with the wrong +# one by default. +KEY="${SLOSH_GPG_KEY:-0F67C909938CFFA8A76B59FD8D69B55A0E9056B9}" set -eu root="$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)" @@ -21,6 +28,10 @@ fail() { printf 'arch-repo: %s\n' "$*" >&2; exit 1; } command -v makepkg >/dev/null 2>&1 || fail "makepkg not found -- this runs on an Arch machine" command -v repo-add >/dev/null 2>&1 || fail "repo-add not found (pacman ships it)" +gpg --list-secret-keys "$KEY" >/dev/null 2>&1 \ + || fail "no secret key $KEY in this keyring -- the repo is signed, and an + unsigned update would make every enrolled pacman refuse it. Import the + signing key, or SLOSH_GPG_KEY=<fingerprint> for a successor key." carch="$(uname -m)" out="$root/dist/arch/$carch" @@ -37,15 +48,24 @@ cp contrib/arch/PKGBUILD "$work/" # check would object, and the build itself knows what it needs. depflag="" [ -x /usr/bin/zig ] || { [ -n "${ZIG:-}" ] && depflag="-d"; } -( cd "$work" && PKGDEST="$out" makepkg -f $depflag ) +( cd "$work" && PKGDEST="$out" makepkg -f $depflag --sign --key "$KEY" ) + +# The index is regenerated from what is actually in the directory, every +# time. repo-add refuses to touch an entry whose version it already has -- +# so after a same-version rebuild (new bytes, new signature) an incremental +# add would leave the db describing the *previous* package, and every +# client would see a checksum mismatch. Rebuilding the index from disk +# cannot disagree with disk. --verify checks the package signatures just +# made; --sign signs the db, so a tampered index is as loud as a tampered +# package. +rm -f "$out"/slosh.db* "$out"/slosh.files* +repo-add --verify --sign --key "$KEY" "$out/slosh.db.tar.gz" "$out"/*.pkg.tar.zst -# Index exactly what this build produced; repo-add updates entries in place, -# so re-running for the same version is harmless. -pkgs="$(cd "$work" && PKGDEST="$out" makepkg --packagelist)" -# repo-add locks the db itself; --new keeps an older file from replacing a -# newer entry if two builds race. -repo-add --new "$out/slosh.db.tar.gz" $pkgs +# The public half rides along at the repo root, so the enrollment the README +# describes has a URL to fetch, and the file in git to compare it against. +cp contrib/arch/slosh.asc "$root/dist/arch/slosh.asc" echo "" echo "arch-repo: $out is the repository. To publish:" echo " rsync -av --delete --chown=root:root $out/ root@sl0p.foo:/opt/slosh/arch/$carch/" +echo " rsync -a --chown=root:root $root/dist/arch/slosh.asc root@sl0p.foo:/opt/slosh/arch/slosh.asc" diff --git a/contrib/arch/README.md b/contrib/arch/README.md index 559ec0d..dd0b975 100644 --- a/contrib/arch/README.md +++ b/contrib/arch/README.md @@ -8,17 +8,30 @@ where the AUR would have handed every user a rebuild. Two ways in, both fed by the PKGBUILD in this directory: **The repository** — binary packages, updated with `pacman -Syu` like -anything else. In `/etc/pacman.conf`: +anything else. Packages and the database are signed, so first enroll the +signing key: + +```sh +curl -fsSLO https://slosh.foo/arch/slosh.asc +sudo pacman-key --add slosh.asc +sudo pacman-key --lsign-key 0F67C909938CFFA8A76B59FD8D69B55A0E9056B9 +``` + +That fingerprint is the thing to check before the `--lsign-key`: the same +key is `contrib/arch/slosh.asc` in git, so the file fetched from the +website can be compared against the one in the source — two channels that +would both have to lie. Then, in `/etc/pacman.conf`: ```ini [slosh] -SigLevel = Optional TrustAll Server = https://slosh.foo/arch/$arch ``` -then `pacman -Sy slosh`. (`SigLevel` spelled out because pacman's default -demands signatures, and these packages are not signed — yet. x86_64 today; -aarch64 when a build machine of that shape exists.) +and `pacman -Sy slosh`. No `SigLevel` override: pacman's default demands +package signatures, and now gets them. The database is signed too, so +`SigLevel = Required DatabaseRequired` also works, if that is your +temperament. (x86_64 today; aarch64 when a build machine of that shape +exists.) **The PKGBUILD itself** — cgit serves it raw, for anyone who would rather build than trust: @@ -34,6 +47,20 @@ dependency in the vendored core's `build.zig.zon` is lazy and unused by the VT-only build — `zig build` fetches nothing (verified against a cold `ZIG_GLOBAL_CACHE_DIR`). zig 0.16 comes from `extra/zig`. +## The signing key + +ed25519, sign-only, made for exactly this — `slosh package signing +<slosh@slosh.foo>`, fingerprint +`0F67C909938CFFA8A76B59FD8D69B55A0E9056B9`, expires 2028-08-28. The private +half lives in the release machine's GnuPG keyring and nowhere else; +`contrib/arch-repo` refuses to build the repo without it, because an +unsigned update would make every enrolled pacman refuse the repo. Before +the expiry: `gpg --quick-set-expire <fpr> 2y`, re-export +`contrib/arch/slosh.asc`, commit, republish — enrolled users pick the +extension up with `pacman-key --add` of the refreshed file (worth a note in +release notes when it happens). If the key is ever replaced rather than +extended, ship the successor the same two ways and say so loudly. + ## Updating on a release After `contrib/release X.Y.Z` (which prints this as a reminder): diff --git a/contrib/arch/slosh.asc b/contrib/arch/slosh.asc new file mode 100644 index 0000000..2410120 --- /dev/null +++ b/contrib/arch/slosh.asc @@ -0,0 +1,10 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- + +mDMEapLkKxYJKwYBBAHaRw8BAQdAv4fnKUWlro7fJgEGtZUBWdO8sRLnCe+iJT2Z +NcNWmfO0J3Nsb3NoIHBhY2thZ2Ugc2lnbmluZyA8c2xvc2hAc2xvc2guZm9vPoiW +BBMWCgA+FiEED2fJCZOM/6ina1n9jWm1Wg6QVrkFAmqS5CsCGwMFCQPCZwAFCwkI +BwIGFQoJCAsCBBYCAwECHgECF4AACgkQjWm1Wg6QVrmHNgD9FJSrU99eDtFALat3 +uTa1PkF1wf3uQKtqgXnUFkXMxOMA/15QEJ4vVKAF/oInyzNy1MU1YNWc1IjNjjzH +xhg8jLYG +=Nd0k +-----END PGP PUBLIC KEY BLOCK----- diff --git a/web/index.html b/web/index.html index 7111fd4..298f4b1 100644 --- a/web/index.html +++ b/web/index.html @@ -63,8 +63,8 @@ </div> <p class="aside">On Arch there is a <a href="arch/">pacman repository</a> - with built packages — the <code>[slosh]</code> stanza to add, and the - PKGBUILD for building it yourself, are in + with built, signed packages — the <code>[slosh]</code> stanza, the + signing key to enroll, and the PKGBUILD for building it yourself are in <a href="https://git.sl0p.foo/slosh.git/tree/contrib/arch">contrib/arch</a>.</p> <p class="aside">On Windows it is the same one binary: <code>slosh.exe</code>, |
