public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Zac Medico" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: misc/
Date: Sat, 18 Aug 2012 01:28:16 +0000 (UTC)	[thread overview]
Message-ID: <1345250877.79674c13905962dc380ea4f951233d4cada32f5b.zmedico@gentoo> (raw)

commit:     79674c13905962dc380ea4f951233d4cada32f5b
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Aug 18 00:47:57 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Aug 18 00:47:57 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=79674c13

emerge-delta-webrsync: support gpg verification

This will fix bug #286373.

BUG: Signature verification will fail if the local bzip2 program does
not produce output that is perfectly identical to the bzip2 program
used to compress the signed tar file.

---
 misc/emerge-delta-webrsync |   62 +++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 59 insertions(+), 3 deletions(-)

diff --git a/misc/emerge-delta-webrsync b/misc/emerge-delta-webrsync
index 5df9658..2f73c90 100755
--- a/misc/emerge-delta-webrsync
+++ b/misc/emerge-delta-webrsync
@@ -4,6 +4,13 @@
 # Author: Brian Harring <ferringb@gentoo.org>, karltk@gentoo.org originally.
 # Rewritten from the old, Perl-based emerge-webrsync script
 
+#
+# gpg key import
+# KEY_ID=0x96D8BF6D
+# gpg --homedir /etc/portage/gnupg --keyserver subkeys.pgp.net --recv-keys $KEY_ID
+# gpg --homedir /etc/portage/gnupg --edit-key $KEY_ID trust
+#
+
 argv0=$0
 
 # error echos
@@ -80,6 +87,16 @@ if [[ ! -d $STATE_DIR ]]; then
 	exit -2
 fi
 
+if has webrsync-gpg ${FEATURES} ; then
+	WEBSYNC_VERIFY_SIGNATURE=1
+else
+	WEBSYNC_VERIFY_SIGNATURE=0
+fi
+if [ ${WEBSYNC_VERIFY_SIGNATURE} != 0 -a -z "${PORTAGE_GPG_DIR}" ]; then
+	eecho "please set PORTAGE_GPG_DIR in make.conf"
+	exit 1
+fi
+
 if [[ ! -d $DISTDIR ]] ; then
 	mkdir -p $DISTDIR
 fi
@@ -280,6 +297,27 @@ verify_md5_file() {
 	fi
 }
 
+check_file_signature() {
+	local signature="$1"
+	local file="$2"
+	local r=1
+
+	if [[ ${WEBSYNC_VERIFY_SIGNATURE} != 0 ]] ; then
+
+		vecho "Checking signature ..."
+
+		if type -P gpg > /dev/null; then
+			gpg --homedir "${PORTAGE_GPG_DIR}" --verify "$signature" "$file" && r=0
+		else
+			eecho "cannot check signature: gpg binary not found"
+			exit 1
+		fi
+	else
+		r=0
+	fi
+
+	return "${r}"
+}
 
 #--------------------
 #inline actual script
@@ -439,7 +477,14 @@ else
 		got_umd5=1
 	fi
 fi
-	
+
+if [[ ${WEBSYNC_VERIFY_SIGNATURE} == 1 && ! -e portage-${final_date}.tar.bz2.gpgsig ]] && \
+	! fetch_from_mirrors "/snapshots/portage-${final_date}.tar.bz2.gpgsig" "portage-${final_date}.tar.bz2.gpgsig" ; then
+	echo "warning... couldn't grab the gpgsig for ${final_date}.  which is odd"
+	echo "thus, bailing (sorry)"
+	exit 5
+fi
+
 # generate tmp dir.
 TEMPDIR=$(mktemp -d /tmp/delta-webrsync-XXXXXX)
 # got our patches.
@@ -465,7 +510,15 @@ unset need_last_sync
 if [ "$verified" == "1" ]; then
 	echo "recompressing. (backgrounding)"
 	need_last_sync="dar"
-	bzip2 -vk9 "${TEMPDIR}/portage-${final_date}.tar" &
+	if [[ ${WEBSYNC_VERIFY_SIGNATURE} == 1 ]] ; then
+		# BUG: Signature verification will fail if the local bzip2
+		# program does not produce output that is perfectly identical
+		# to the bzip2 program used to compress the signed tar file.
+		bzip2 -vk9 "${TEMPDIR}/portage-${final_date}.tar"
+		check_file_signature "${DISTDIR}/portage-${final_date}.tar.bz2.gpgsig" "${TEMPDIR}/portage-${final_date}.tar.bz2" || exit 1
+	else
+		bzip2 -vk9 "${TEMPDIR}/portage-${final_date}.tar" &
+	fi
 
 	echo "beginning update to the tree"
 	sync_local "${TEMPDIR}/portage-${final_date}.tar"
@@ -507,6 +560,9 @@ else
 fi
 
 if [ -z "${need_last_sync}" ]; then
+	if [[ ${WEBSYNC_VERIFY_SIGNATURE} == 1 ]] ; then
+		check_file_signature "${DISTDIR}/portage-${final_date}.tar.bz2.gpgsig" "${dfile}" || exit 1
+	fi
 	echo "beginning update to the tree"
 	sync_local "${dfile}"
 fi
@@ -515,7 +571,7 @@ if [[ -z $KEEP_OLDIES ]]; then
 	echo "cleansing"
 	for x in $potentials; do
 		echo "removing ${x}"
-		rm "${DISTDIR}/${x}" "${DISTDIR}/${x}.md5sum" "${DISTDIR}/${x}.umd5sum" &> /dev/null
+		rm -f "${DISTDIR}/${x}"{,.md5sum,.umd5sum,.gpgsig} &> /dev/null
 		rm "${STATE_DIR}/${x}" "${STATE_DIR}/${x}.md5sum" "${STATE_DIR}/${x}.umd5sum" &> /dev/null
 	done
 fi


             reply	other threads:[~2012-08-18  3:07 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-18  1:28 Zac Medico [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-01-29  1:22 [gentoo-commits] proj/portage:master commit in: misc/ Zac Medico
2023-11-11  7:24 Sam James
2023-08-19 15:42 Sam James
2023-08-19 15:03 Sam James
2023-08-19 15:03 Sam James
2023-08-19 13:35 Sam James
2019-12-30 21:36 Zac Medico
2019-12-09  9:30 Zac Medico
2018-07-28  6:20 Zac Medico
2018-07-28  6:12 Zac Medico
2018-02-01  6:18 Zac Medico
2015-11-06  5:31 Zac Medico
2014-10-19 17:19 Zac Medico
2013-07-10 20:16 Zac Medico
2013-06-22  6:14 Zac Medico
2013-06-22  5:54 Zac Medico
2013-01-28 21:45 Zac Medico
2012-09-14  7:26 Zac Medico
2012-08-19  5:44 Zac Medico
2012-08-19  5:21 Zac Medico
2012-08-18 22:51 Zac Medico
2012-08-18 20:51 Zac Medico
2012-08-18 20:32 Zac Medico
2012-08-18  1:45 Zac Medico
2012-08-18  1:28 Zac Medico
2012-08-18  1:28 Zac Medico
2012-08-18  1:28 Zac Medico
2012-08-18  1:28 Zac Medico
2012-08-18  1:28 Zac Medico
2012-08-18  1:28 Zac Medico
2012-08-18  0:09 Zac Medico

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1345250877.79674c13905962dc380ea4f951233d4cada32f5b.zmedico@gentoo \
    --to=zmedico@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox