3ca7e96e38
* tests/gpg/start-stop-agent: New. * tests/gpg/initial.test: New. * tests/gpg/final.test: New. * tests/gpg/Makefile.am (c_tests): New. (TESTS): Move all to c_tests. Add initial.test, final.test, and c_tests. (TESTS_ENVIRONMENT): Add C_ALL=C (private_keys): New. (EXTRA_DIST): Add new files. (./private-keys-v1.d/gpg-sample.stamp): Copy private keys. (all-local): Depend on gpg-sample.stamp. * tests/gpg/13CBE3758AFE42B5E5E2AE4CED27AFA455E3F87F: New. * tests/gpg/13CD0F3BDF24BE53FE192D62F18737256FF6E4FD: New. * tests/gpg/76F7E2B35832976B50A27A282D9B87E44577EB66: New. * tests/gpg/7A030357C0F253A5BBCD282FFC4E521B37558F5C: New. * tests/gpg/A0747D5F9425E6664F4FFBEED20FBCA79FDED2BD: New. -- GnuPG 2.1 requires that the agent knows the private keys. Thus we need to install them. The code should still work with GnuPG < 2.1. To make the whole testing using a agent more robust, the way to start the agent has also be changed.
46 lines
1.3 KiB
Bash
Executable File
46 lines
1.3 KiB
Bash
Executable File
#!/bin/sh
|
|
# Copyright (C) 2013 g10 Code GmbH
|
|
#
|
|
# This file is free software; as a special exception the author gives
|
|
# unlimited permission to copy and/or distribute it, with or without
|
|
# modifications, as long as this notice is preserved. This file is
|
|
# distributed in the hope that it will be useful, but WITHOUT ANY
|
|
# WARRANTY, to the extent permitted by law; without even the implied
|
|
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
if [ -z "$(command -v gpg-connect-agent)" ]; then
|
|
echo "gpg-agent not installed and thus not started" >&2
|
|
exit 0;
|
|
fi
|
|
|
|
GPG_AGENT_INFO=
|
|
export GPG_AGENT_INFO
|
|
|
|
token=$(echo "gpgme-$(pwd)" | tr ' ' '_')
|
|
|
|
if [ "$1" = "--stop" ]; then
|
|
if [ "$(gpg-connect-agent getval\ $token /bye 2>/dev/null | head -1)" \
|
|
!= "D set" ]; then
|
|
echo "gpg-agent not running" >&2
|
|
exit 0
|
|
fi
|
|
echo "stopping gpg-agent " >&2
|
|
gpg-connect-agent KILLAGENT /bye >/dev/null 2>&1
|
|
exit 0
|
|
fi
|
|
|
|
if [ "$(gpg-connect-agent getval\ $token /bye 2>/dev/null | head -1)" \
|
|
= "D set" ]; then
|
|
echo "gpg-agent already running" >&2
|
|
exit 0
|
|
fi
|
|
|
|
echo "starting gpg-agent " >&2
|
|
gpg-connect-agent putval\ $token\ set /bye >/dev/null 2>&1
|
|
if [ "$(gpg-connect-agent getval\ $token /bye 2>/dev/null | head -1)" \
|
|
!= "D set" ]; then
|
|
echo "error starting gpg-agent" >&2
|
|
exit 1
|
|
fi
|
|
exit 0
|