When updating ports I'd find it helpful to have an easier way to check signatures from upstream. What does anyone think about the general idea or the specifics of this? List the signature file in SIGFILES, set CHECK_PGPSIG=Yes in mk.conf, and with the sample I've included for mutt in the patch below (if you already have the signer's public key in your keyring) it looks like this:
$ make checksum ===> Checking files for mutt-1.13.2v3 `/y/Download/ftp/pub/OpenBSD/distfiles/mutt-1.13.2.tar.gz' is up to date. `/y/Download/ftp/pub/OpenBSD/distfiles/mutt-1.13.2.tar.gz.asc' is up to date. >> (SHA256) mutt-1.13.2.tar.gz: OK >> (SHA256) mutt-1.13.2.tar.gz.asc: OK gpg: assuming signed data in `mutt-1.13.2.tar.gz' gpg: Signature made Wed Dec 18 22:23:48 2019 GMT using RSA key ID 80316BDA gpg: Good signature from "Kevin J. McCarthy <[email protected]>" gpg: WARNING: This key is not certified with a trusted signature! gpg: There is no indication that the signature belongs to the owner. Primary key fingerprint: 8975 A9B3 3AA3 7910 385C 5308 ADEF 7684 8031 6BDA I'm thinking of this as a ports maintainer tool only - I don't think it's useful for bulk builds as we already check hashes against the ports tree. Intentionally not switching uid because that will make it tricky to manage public keys. Thoughts? Index: infrastructure/mk/bsd.port.mk =================================================================== RCS file: /cvs/ports/infrastructure/mk/bsd.port.mk,v retrieving revision 1.1514 diff -u -p -r1.1514 bsd.port.mk --- infrastructure/mk/bsd.port.mk 16 Dec 2019 09:18:27 -0000 1.1514 +++ infrastructure/mk/bsd.port.mk 20 Dec 2019 21:07:55 -0000 @@ -117,7 +117,7 @@ _ALL_VARIABLES_PER_ARCH = # consumers of (dump-vars) include sqlports generation and dpb # dpb doesn't need everything, those are speed optimizations .if ${DPB:L:Mfetch} || ${DPB:L:Mall} -_ALL_VARIABLES += DISTFILES PATCHFILES SUPDISTFILES DIST_SUBDIR MASTER_SITES \ +_ALL_VARIABLES += DISTFILES PATCHFILES SUPDISTFILES SIGFILES DIST_SUBDIR MASTER_SITES \ MASTER_SITES0 MASTER_SITES1 MASTER_SITES2 MASTER_SITES3 MASTER_SITES4 \ MASTER_SITES5 MASTER_SITES6 MASTER_SITES7 MASTER_SITES8 MASTER_SITES9 \ CHECKSUM_FILE FETCH_MANUALLY MISSING_FILES PERMIT_DISTFILES @@ -1289,6 +1289,11 @@ DISTFILES ?= ${DISTNAME}${EXTRACT_SUFX} PATCHFILES ?= SUPDISTFILES ?= +SIGFILES ?= +CHECK_PGPSIG ?= No +.if ${CHECK_PGPSIG:L} == yes +BUILD_DEPENDS += security/gnupg +.endif # the following loop "parses" DISTFILES-style files # _PATH_x contains filenames with SUBDIR prepended when necessary @@ -1300,10 +1305,10 @@ SUPDISTFILES ?= # # _FILES is used to de-duplicates names # the order matters: DISTFILES PATCHFILES SUPDISTFILES -# - we never have the same names in DISTFILES and PATCHFILES +# - we never have the same names in DISTFILES and PATCHFILES or SIGFILES # - SUPDISTFILES has to happen later _FILES= -.for v in DISTFILES PATCHFILES SUPDISTFILES +.for v in DISTFILES PATCHFILES SIGFILES SUPDISTFILES . if !empty($v) . for e in ${$v} . for f m u in ${e:C/:[0-9]$//:C/(.*)\{.*\}(.*)/\1\2/} MASTER_SITES${e:M*\:[0-9]:C/.*:([0-9])/\1/} ${e:C/:[0-9]$//:C/.*\{(.*)\}(.*)/\1\2/} @@ -1327,7 +1332,7 @@ _LIST_$v = .endfor _FULL_FETCHLIST ?= -CHECKSUMFILES = ${_PATH_DISTFILES} ${_PATH_PATCHFILES} +CHECKSUMFILES = ${_PATH_DISTFILES} ${_PATH_PATCHFILES} ${_PATH_SIGFILES} MAKESUMFILES = ${CHECKSUMFILES} ${_PATH_SUPDISTFILES} # This is what is actually going to be extracted, and is overridable @@ -2491,6 +2496,16 @@ _internal-checksum: _internal-fetch fi; \ fi . endif +. endif +. if !empty(SIGFILES) && ${CHECK_PGPSIG:L} == yes + @cd ${DISTDIR}; OK=true; \ + for file in ${SIGFILES}; do \ + gpg --verify $$file || OK=false; \ + done; \ + if ! $$OK; then \ + echo "GPG signature invalid."; \ + exit 1; \ + fi . endif Index: mail/mutt/Makefile =================================================================== RCS file: /cvs/ports/mail/mutt/Makefile,v retrieving revision 1.126 diff -u -p -r1.126 Makefile --- mail/mutt/Makefile 19 Dec 2019 13:49:44 -0000 1.126 +++ mail/mutt/Makefile 20 Dec 2019 21:07:55 -0000 @@ -3,6 +3,7 @@ COMMENT= tty-based e-mail client DISTNAME= mutt-1.13.2 +SIGFILES= mutt-1.13.2${EXTRACT_SUFX}.asc EPOCH= 3 CATEGORIES= mail Index: mail/mutt/distinfo =================================================================== RCS file: /cvs/ports/mail/mutt/distinfo,v retrieving revision 1.37 diff -u -p -r1.37 distinfo --- mail/mutt/distinfo 19 Dec 2019 13:49:44 -0000 1.37 +++ mail/mutt/distinfo 20 Dec 2019 21:07:55 -0000 @@ -1,2 +1,4 @@ SHA256 (mutt-1.13.2.tar.gz) = L3OTG/9AjvZLgp9ZWw2vg6yBjRVEWJUgQLcEguZ2nnQ= +SHA256 (mutt-1.13.2.tar.gz.asc) = 1qBz5va7E+IPbGTj4alZGpSQxXIv/JZZimgP1Rqs3Do= SIZE (mutt-1.13.2.tar.gz) = 4895334 +SIZE (mutt-1.13.2.tar.gz.asc) = 833
