[pacman-dev] makepkg/repo-add: do not accept public-only keys for signing

Message ID 20200609020318.2097612-1-eschwartz@archlinux.org
State Accepted, archived
Headers show
Series [pacman-dev] makepkg/repo-add: do not accept public-only keys for signing | expand

Commit Message

Eli Schwartz June 9, 2020, 2:03 a.m. UTC
If it's not listed by --list-secret-key we don't care if it has been
imported into your keyring, it's unusable. And you might not have a
private key at all in the no-keyid-specified case.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
---

Overlaps previous patch to fix GPGKEY handling.

 scripts/makepkg.sh.in  | 2 +-
 scripts/repo-add.sh.in | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Patch

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index cc8de5aa..9e75ef17 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -1293,7 +1293,7 @@  fi
 # check if gpg signature is to be created and if signing key is valid
 if { [[ -z $SIGNPKG ]] && check_buildenv "sign" "y"; } || [[ $SIGNPKG == 'y' ]]; then
 	SIGNPKG='y'
-	if ! gpg --list-key ${GPGKEY:+"$GPGKEY"} &>/dev/null; then
+	if ! gpg --list-secret-key ${GPGKEY:+"$GPGKEY"} &>/dev/null; then
 		if [[ ! -z $GPGKEY ]]; then
 			error "$(gettext "The key %s does not exist in your keyring.")" "${GPGKEY}"
 		else
diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in
index 272d8d22..160fd93a 100644
--- a/scripts/repo-add.sh.in
+++ b/scripts/repo-add.sh.in
@@ -137,7 +137,7 @@  check_gpg() {
 	fi
 
 	if (( ! VERIFY )); then
-		if ! gpg --list-key ${GPGKEY:+"$GPGKEY"} &>/dev/null; then
+		if ! gpg --list-secret-key ${GPGKEY:+"$GPGKEY"} &>/dev/null; then
 			if [[ ! -z $GPGKEY ]]; then
 				error "$(gettext "The key ${GPGKEY} does not exist in your keyring.")"
 			elif (( ! KEY )); then