From 9fe1a235c16be2e5e8a17641e362881ca8da5d8c Mon Sep 17 00:00:00 2001 From: Roman Zeyde Date: Fri, 2 Dec 2016 13:10:33 +0200 Subject: [PATCH] gpg: check that the configuration is in place --- scripts/gpg-shell | 7 +++++++ trezor_agent/gpg/__main__.py | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/scripts/gpg-shell b/scripts/gpg-shell index 07f593d..fbbf046 100755 --- a/scripts/gpg-shell +++ b/scripts/gpg-shell @@ -5,6 +5,13 @@ gpg2 --version >/dev/null # verify that GnuPG 2 is installed export GNUPGHOME=~/.gnupg/trezor +CONFIG_PATH="${GNUPGHOME}/gpg-agent.conf" +if [ ! -f ${CONFIG_PATH} ] +then + echo "No configuration found: ${CONFIG_PATH}" + exit 1 +fi + # Make sure that the device is unlocked before starting the shell trezor-gpg-unlock diff --git a/trezor_agent/gpg/__main__.py b/trezor_agent/gpg/__main__.py index 9c39b62..81f015e 100755 --- a/trezor_agent/gpg/__main__.py +++ b/trezor_agent/gpg/__main__.py @@ -92,6 +92,10 @@ def main_agent(): """Run a simple GPG-agent server.""" home_dir = os.environ.get('GNUPGHOME', os.path.expanduser('~/.gnupg/trezor')) config_file = os.path.join(home_dir, 'gpg-agent.conf') + if not os.path.exists(config_file): + msg = 'No configuration file found: {}'.format(config_file) + raise IOError(msg) + lines = (line.strip() for line in open(config_file)) lines = (line for line in lines if line and not line.startswith('#')) config = dict(line.split(' ', 1) for line in lines)