From 377af1466cc4e85cf655d4bd9f76a5ef123154aa Mon Sep 17 00:00:00 2001 From: Roman Zeyde Date: Sat, 7 Oct 2017 20:43:59 +0300 Subject: [PATCH] gpg: detect installed GnuPG binary --- libagent/gpg/keyring.py | 2 +- scripts/gpg-init | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/libagent/gpg/keyring.py b/libagent/gpg/keyring.py index 7feb8bf..234a8c8 100644 --- a/libagent/gpg/keyring.py +++ b/libagent/gpg/keyring.py @@ -179,7 +179,7 @@ def get_gnupg_binary(sp=subprocess): """Starting GnuPG 2.2.x, the default installation uses `gpg`.""" for cmd in ['gpg2', 'gpg']: try: - return sp.check_output(args=['which', cmd]).strip() + return sp.check_output(args=['which', cmd]).strip().decode('ascii') except subprocess.CalledProcessError: log.debug('%r not found', cmd) continue diff --git a/scripts/gpg-init b/scripts/gpg-init index 1df787a..4d629a2 100755 --- a/scripts/gpg-init +++ b/scripts/gpg-init @@ -5,9 +5,10 @@ USER_ID="${1}" DEVICE=${DEVICE:="trezor"} # or "ledger" CURVE=${CURVE:="nist256p1"} # or "ed25519" TIMESTAMP=${TIMESTAMP:=`date +%s`} # key creation timestamp -GPG_BINARY=${GPG_BINARY:="gpg2"} # starting from GnuPG 2.2, gpg2 -> gpg HOMEDIR=~/.gnupg/${DEVICE} + # NOTE: starting from GnuPG 2.2, gpg2 -> gpg +GPG_BINARY=$(python -c "import libagent.gpg.keyring as k; print(k.get_gnupg_binary())") ${GPG_BINARY} --version # verify that GnuPG 2.1+ is installed # Prepare new GPG home directory for hardware-based identity