signify: sign the release automatically, verify it before an upgrade
- make sourcesets signs RELEASEDIR/source/sets/SHA512 inside the build lock
when SIGNIFY_SECKEY is set (tools/sign-release.sh auto); a build without
the key says so and stays unsigned.
- make iso signs the package summary first; tools/cd3.sh puts
pkg_summary.gz.sig next to the summary on the DVD and on every package CD.
- tools/cd-source.sh carries SHA512.sig on the source DVD and the README
names the two verification commands.
- tools/upgrade-verify.sh: verifies root key -> release key -> SHA512 and
then the SHA512 of the set files; the upgrade command (tasksd t0055) calls
it before sysupgrade/pkg_add run as root.
Measured 2026-11-16: the source SHA512 signed with the release key verifies
through the chain ("signed by the root key", "good signature"), the copy
extracted from the source DVD too, the package summary verifies, and
upgrade-verify checks src.tgz (5.8 GB) against SHA512. `make iso` itself
was not run to the end: a commit in another session changed src/ during the
release, so build-stamp refused the packaging
(build/logs/release-iso-2026-11-16-signed.log).
This commit is contained in:
1 parent
3cc41e183f
commit
6d0c92ae38
6 files changed
+127
-5
No files matched your search
@@ -68,7 +68,7 @@ release:
|
||||
# It only packages what `make release' built, so it checks that nothing has
|
||||
# changed since (tools/build-stamp.sh -c) instead of discarding the release.
|
||||
iso:
|
||||
@tools/build-lock.sh 'tools/build-stamp.sh -c && tools/cd3.sh stage && $(BUILD_SH) iso-image && tools/cd2.sh && tools/cd3.sh'
|
||||
@tools/build-lock.sh 'tools/build-stamp.sh -c && tools/sign-release.sh auto $(TOP)/build/packages/amd64/All/pkg_summary.gz && tools/cd3.sh stage && $(BUILD_SH) iso-image && tools/cd2.sh && tools/cd3.sh'
|
||||
|
||||
# the bootable installation image for a USB stick (GPT and EFI, also bootable
|
||||
# on BIOS through gptmbr), built from what `make release' made:
|
||||
@@ -106,7 +106,7 @@ test:
|
||||
# sets; there is no /usr/xsrc and no /usr/msrc any more. Needs the distfiles
|
||||
# (tools/makronix-distfiles.sh fetch).
|
||||
sourcesets:
|
||||
@tools/build-lock.sh 'tools/makronix-pins.sh check && tools/makronix-distfiles.sh verify && tools/makronix-distfiles.sh check && tools/srctree-stage.sh $(SRCSTAGE) && $(BUILD_SH) -V MAKROSRCDIR=$(SRCSTAGE) sourcesets'
|
||||
@tools/build-lock.sh 'tools/makronix-pins.sh check && tools/makronix-distfiles.sh verify && tools/makronix-distfiles.sh check && tools/srctree-stage.sh $(SRCSTAGE) && $(BUILD_SH) -V MAKROSRCDIR=$(SRCSTAGE) sourcesets && tools/sign-release.sh auto $(OBJ)/releasedir/source/sets/SHA512'
|
||||
|
||||
# The source DVD on its own: source/sets/src.tgz, MD5, SHA512 and a README
|
||||
# (tools/cd-source.sh). The install DVD and the CDs carry no sources; the
|
||||
|
||||
@@ -70,7 +70,14 @@ log)
|
||||
### Measured 2026-11-16: the source DVD installs
|
||||
|
||||
- `make isosrc` writes the source DVD as ISO 9660 with the set in parts
|
||||
(`source/sets/src.tgz.aa`, `.ab`, `.ac`: 2 GiB, 2 GiB, 1.5 GiB).
|
||||
(`source/sets/src.tgz.aa`, `.ab`, `.ac`: 2 GiB, 2 GiB, 1.5 GiB), and
|
||||
`source/sets/SHA512.sig` next to the hashes.
|
||||
- The signature is a chain: `/etc/signify/makronix-root.pub` signs
|
||||
`/etc/signify/makronix-0.99.pub` (`.pub.sig`), the release key signs
|
||||
`SHA512` (`tools/sign-release.sh`). Measured 2026-11-16: the SHA512
|
||||
extracted from the source DVD verifies through the chain, and
|
||||
`tools/upgrade-verify.sh build/obj/releasedir/source/sets src.tgz` checks
|
||||
the chain and the 5.8 GB file's SHA512.
|
||||
- `tools/install-simple.sh -S` (BIOS, the full profile): the installer asks
|
||||
for the source DVD, the disc is swapped in, the parts are extracted to
|
||||
`/usr/src`, the install DVD comes back for the makronix set, and the
|
||||
|
||||
+9
-1
@@ -47,6 +47,9 @@ mkdir -p "$STAGE/source/sets"
|
||||
# README says how to do it by hand.
|
||||
split -b 2000m "$SETS/src.tgz" "$STAGE/source/sets/src.tgz."
|
||||
cp -p "$SETS/MD5" "$SETS/SHA512" "$STAGE/source/sets/"
|
||||
if [ -f "$SETS/SHA512.sig" ]; then
|
||||
cp -p "$SETS/SHA512.sig" "$STAGE/source/sets/"
|
||||
fi
|
||||
|
||||
cat > "$STAGE/README" <<EOF
|
||||
The Makronix source set, version $VER
|
||||
@@ -71,7 +74,12 @@ The set is root:wsrc; the user that builds is in the wsrc group. Then:
|
||||
export MAKRONIX_TOP=/usr/src
|
||||
make release ARCH=amd64
|
||||
|
||||
Size and hashes: source/sets/MD5, source/sets/SHA512.
|
||||
Size and hashes: source/sets/MD5, source/sets/SHA512. The SHA512 is signed
|
||||
(root key -> release key, signify); check it before you unpack:
|
||||
|
||||
signify -V -p /etc/signify/makronix-root.pub -m /etc/signify/makronix-0.99.pub -x /etc/signify/makronix-0.99.pub.sig
|
||||
signify -V -p /etc/signify/makronix-0.99.pub -m /mnt/source/sets/SHA512 -x /mnt/source/sets/SHA512.sig
|
||||
|
||||
The install DVD carries the system and the programs, not the sources; this
|
||||
DVD is the one that does.
|
||||
EOF
|
||||
|
||||
@@ -142,6 +142,12 @@ zcat "$summary" | awk -v b="$bin" '
|
||||
link "$PKGS/$f" "$STAGE/amd64/packages/All/$f"
|
||||
done
|
||||
link "$PKGS/pkg_summary.gz" "$STAGE/amd64/packages/All/pkg_summary.gz"
|
||||
# the signify signature of the package list signs the repository (make iso,
|
||||
# tools/sign-release.sh); it travels next to the summary
|
||||
if [ -f "$PKGS/pkg_summary.gz.sig" ]; then
|
||||
link "$PKGS/pkg_summary.gz.sig" \
|
||||
"$STAGE/amd64/packages/All/pkg_summary.gz.sig"
|
||||
fi
|
||||
lists "$STAGE/amd64/packages"
|
||||
echo "1 1" > "$STAGE/amd64/packages/disc"
|
||||
|
||||
@@ -209,6 +215,9 @@ while [ $i -le "$ncd" ]; do
|
||||
link "$f" "$d/amd64/packages/All/${f##*/}"
|
||||
done
|
||||
link "$summary" "$d/amd64/packages/All/pkg_summary.gz"
|
||||
if [ -f "$summary.sig" ]; then
|
||||
link "$summary.sig" "$d/amd64/packages/All/pkg_summary.gz.sig"
|
||||
fi
|
||||
lists "$d/amd64/packages"
|
||||
echo "$i $ncd" > "$d/amd64/packages/disc"
|
||||
cdno=$((FIRSTCD + i - 1))
|
||||
|
||||
+20
-1
@@ -3,6 +3,7 @@
|
||||
# sign-release.sh -- the signify signature of a release, in a chain.
|
||||
#
|
||||
# usage: sign-release.sh sign FILE...
|
||||
# sign-release.sh auto FILE... (sign what exists, if a key is set)
|
||||
# sign-release.sh verify FILE...
|
||||
# sign-release.sh sign-key RELEASE-PUBKEY
|
||||
#
|
||||
@@ -34,7 +35,7 @@ die()
|
||||
SIGNIFY=$(command -v signify 2>/dev/null || command -v signify-openbsd 2>/dev/null) \
|
||||
|| die "no signify (security/signify)"
|
||||
|
||||
[ $# -ge 2 ] || die "usage: $0 sign|verify|sign-key ARG..."
|
||||
[ $# -ge 2 ] || die "usage: $0 sign|auto|verify|sign-key ARG..."
|
||||
cmd=$1
|
||||
shift
|
||||
|
||||
@@ -49,6 +50,24 @@ sign)
|
||||
echo "sign-release: $f.sig"
|
||||
done
|
||||
;;
|
||||
auto)
|
||||
# For a build: sign the files that exist when the release key is
|
||||
# there, say so when it is not. A developer build has no key.
|
||||
if [ -z "${SIGNIFY_SECKEY:-}" ]; then
|
||||
echo "sign-release: not signed (SIGNIFY_SECKEY is not set)" >&2
|
||||
exit 0
|
||||
fi
|
||||
[ -r "$SIGNIFY_SECKEY" ] || die "cannot read $SIGNIFY_SECKEY"
|
||||
for f in "$@"; do
|
||||
if [ ! -f "$f" ]; then
|
||||
echo "sign-release: $f: not there, nothing to sign" >&2
|
||||
continue
|
||||
fi
|
||||
"$SIGNIFY" -S -s "$SIGNIFY_SECKEY" -m "$f" -x "$f.sig" \
|
||||
|| die "signing $f failed"
|
||||
echo "sign-release: $f.sig"
|
||||
done
|
||||
;;
|
||||
sign-key)
|
||||
[ $# -eq 1 ] || die "usage: $0 sign-key RELEASE-PUBKEY"
|
||||
[ -n "${SIGNIFY_ROOT_SECKEY:-}" ] || die "SIGNIFY_ROOT_SECKEY is not set"
|
||||
|
||||
Executable
+79
@@ -0,0 +1,79 @@
|
||||
#!/bin/sh
|
||||
# License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree.
|
||||
# upgrade-verify.sh -- verify a release's SHA512 before it is used as root.
|
||||
#
|
||||
# usage: upgrade-verify.sh SOURCE [FILE...]
|
||||
#
|
||||
# SOURCE is a directory or a file:/// URL that holds the release's SHA512,
|
||||
# SHA512.sig and the set files. The chain is checked first (the root key in
|
||||
# /etc/signify/makronix-root.pub signs the release key
|
||||
# /etc/signify/makronix-0.99.pub, the release key signs SHA512), then each
|
||||
# FILE with its line in SHA512 (all lines when no FILE is given).
|
||||
#
|
||||
# SIGNIFY_ROOT_PUBKEY, SIGNIFY_PUBKEY and SIGNIFY override the paths and the
|
||||
# program; the upgrade command calls this before sysupgrade or pkg_add run as
|
||||
# root (tasksd t0055, t0078).
|
||||
#
|
||||
# signify is not in the NetBSD base: the target needs security/signify (or
|
||||
# the same program under another name); SIGNIFY names it.
|
||||
|
||||
set -eu
|
||||
|
||||
die()
|
||||
{
|
||||
echo "upgrade-verify: $*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
[ $# -ge 1 ] || die "usage: $0 SOURCE [FILE...]"
|
||||
src=$1
|
||||
shift
|
||||
case $src in
|
||||
file://*) src=${src#file://} ;;
|
||||
esac
|
||||
[ -d "$src" ] || die "$src is not a directory"
|
||||
|
||||
SIGNIFY=${SIGNIFY:-$(command -v signify 2>/dev/null || command -v signify-openbsd 2>/dev/null)} \
|
||||
|| die "no signify (security/signify)"
|
||||
ROOT=${SIGNIFY_ROOT_PUBKEY:-/etc/signify/makronix-root.pub}
|
||||
PUB=${SIGNIFY_PUBKEY:-/etc/signify/makronix-0.99.pub}
|
||||
|
||||
[ -f "$src/SHA512" ] || die "no $src/SHA512"
|
||||
[ -f "$src/SHA512.sig" ] || die "no $src/SHA512.sig"
|
||||
[ -r "$ROOT" ] || die "no root key $ROOT"
|
||||
[ -r "$PUB" ] || die "no release key $PUB"
|
||||
[ -r "$PUB.sig" ] || die "no signature of the release key $PUB.sig"
|
||||
|
||||
"$SIGNIFY" -V -p "$ROOT" -m "$PUB" -x "$PUB.sig" \
|
||||
|| die "the release key is not signed by the root key"
|
||||
"$SIGNIFY" -V -p "$PUB" -m "$src/SHA512" -x "$src/SHA512.sig" \
|
||||
|| die "SHA512 is not signed by the release key"
|
||||
|
||||
# The hashes in SHA512 are "SHA512 (name) = hex"; check the named files.
|
||||
check_one()
|
||||
{
|
||||
name=$1
|
||||
line=$(awk -v n="$name" '$1 == "SHA512" && $2 == "(" n ")" { print $NF; exit }' "$src/SHA512")
|
||||
[ -n "$line" ] || die "$name is not in $src/SHA512"
|
||||
[ -f "$src/$name" ] || die "no $src/$name"
|
||||
got=$(if command -v sha512 >/dev/null 2>&1; then
|
||||
sha512 -q "$src/$name"
|
||||
elif command -v sha512sum >/dev/null 2>&1; then
|
||||
sha512sum "$src/$name" | awk '{print $1}'
|
||||
else
|
||||
cksum -a sha512 "$src/$name" | awk '{print $NF}'
|
||||
fi)
|
||||
[ "$got" = "$line" ] || die "$name: SHA512 does not match"
|
||||
echo "upgrade-verify: $name: SHA512 matches"
|
||||
}
|
||||
|
||||
if [ $# -gt 0 ]; then
|
||||
for f in "$@"; do
|
||||
check_one "${f##*/}"
|
||||
done
|
||||
else
|
||||
awk '$1 == "SHA512" { sub(/^\(/, "", $2); sub(/\)$/, "", $2); print $2 }' \
|
||||
"$src/SHA512" | while read -r name; do
|
||||
check_one "$name"
|
||||
done
|
||||
fi
|
||||
Reference in new issue
Block a user