From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 6A4B715810D for ; Fri, 26 May 2023 01:33:16 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 42B02E0823; Fri, 26 May 2023 01:33:15 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 2976CE0823 for ; Fri, 26 May 2023 01:33:15 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 5CF29340F99 for ; Fri, 26 May 2023 01:33:14 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 91B8EA64 for ; Fri, 26 May 2023 01:33:12 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1685064783.b8ab8e1c850b773dd17e503a22902b52a2d3a868.sam@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: bin/ X-VCS-Repository: proj/portage X-VCS-Files: bin/emerge-webrsync X-VCS-Directories: bin/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: b8ab8e1c850b773dd17e503a22902b52a2d3a868 X-VCS-Branch: master Date: Fri, 26 May 2023 01:33:12 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 6a63e996-6a56-4796-b337-28e355a0b681 X-Archives-Hash: 9eb4f86ab6aa713560f60ded1a1e3ba6 commit: b8ab8e1c850b773dd17e503a22902b52a2d3a868 Author: Sam James gentoo org> AuthorDate: Sat May 20 08:13:29 2023 +0000 Commit: Sam James gentoo org> CommitDate: Fri May 26 01:33:03 2023 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=b8ab8e1c emerge-webrsync: create a new temporary dir for legacy gpg verification It's possible that we can't read /root/.gnupg and we shouldn't be poking around in there anyway. However, if the user is setting PORTAGE_GPG_DIR by themselves, it's their responsibility to handle the directory being in the right state (e.g. has the right keys imported). - If PORTAGE_GPG_DIR is unset, make a tmpdir w/ mktemp. - If we're using that temporary directory we just created, import PORTAGE_GPG_KEY, as before defaulting to /usr/share/openpgp-keys/gentoo-release.asc. Bug: https://bugs.gentoo.org/905868 Signed-off-by: Sam James gentoo.org> Closes: https://github.com/gentoo/portage/pull/1042 Signed-off-by: Sam James gentoo.org> bin/emerge-webrsync | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/bin/emerge-webrsync b/bin/emerge-webrsync index a84f68aa1..956e00e1f 100755 --- a/bin/emerge-webrsync +++ b/bin/emerge-webrsync @@ -314,7 +314,26 @@ check_file_signature_gpg_unwrapped() { local file="$2" if type -P gpg > /dev/null; then - if gnupg_status=$(gpg --homedir "${PORTAGE_GPG_DIR}" --batch \ + if [[ -n ${PORTAGE_GPG_KEY} ]] ; then + local key="${PORTAGE_GPG_KEY}" + else + local key="${EPREFIX:-/}"/usr/share/openpgp-keys/gentoo-release.asc + fi + + local gpgdir="${PORTAGE_GPG_DIR}" + if [[ -z ${gpgdir} ]] ; then + gpgdir=$(mktemp -d "${PORTAGE_TMPDIR}/portage/webrsync-XXXXXX") + if [[ ! -w ${gpgdir} ]] ; then + die "gpgdir is not writable: ${gpgdir}" + fi + + # If we're created our own temporary directory, it's okay for us + # to import the keyring by ourselves. But we'll avoid doing it + # if the user has set PORTAGE_GPG_DIR by themselves. + gpg --no-default-keyring --homedir "${gpgdir}" --batch --import "${key}" + fi + + if gnupg_status=$(gpg --no-default-keyring --homedir "${gpgdir}" --batch \ --status-fd 1 --verify "${signature}" "${file}"); then while read -r line; do if [[ ${line} == "[GNUPG:] GOODSIG"* ]]; then