Use $GNUPGHOME in GPG agent startup

Use the value of $GNUPGHOME, to facilitate moving GPG's home.

This lets users who keep their GPG keyring on external devices or alternate
folders use the gpg-agent autostarting, even if $HOME/.gnupg does not exist.
This commit is contained in:
neersighted 2013-01-21 17:35:59 -08:00 committed by Sorin Ionescu
parent 6fd00449a6
commit d198c08db5

View file

@ -4,6 +4,7 @@
# Authors: # Authors:
# Florian Walch <florian.walch@gmx.at> # Florian Walch <florian.walch@gmx.at>
# Sorin Ionescu <sorin.ionescu@gmail.com> # Sorin Ionescu <sorin.ionescu@gmail.com>
# neersighted <neersighted@myopera.com>
# #
# Return if requirements are not found. # Return if requirements are not found.
@ -11,7 +12,8 @@ if (( ! $+commands[gpg-agent] )); then
return 1 return 1
fi fi
_gpg_env="$HOME/.gnupg/gpg-agent.env" # Make sure to use the $GNUPGHOME first.
_gpg_env="${GNUPGHOME:-$HOME/.gnupg}/gpg-agent.env"
function _gpg-agent-start { function _gpg-agent-start {
local ssh_support local ssh_support
@ -20,7 +22,8 @@ function _gpg-agent-start {
|| ssh_support='' || ssh_support=''
gpg-agent \ gpg-agent \
--daemon ${ssh_support:+'--enable-ssh-support'} --daemon \
${ssh_support:+'--enable-ssh-support'} \
--write-env-file "${_gpg_env}" > /dev/null --write-env-file "${_gpg_env}" > /dev/null
chmod 600 "${_gpg_env}" chmod 600 "${_gpg_env}"
@ -41,4 +44,3 @@ export GPG_AGENT_INFO
export SSH_AUTH_SOCK export SSH_AUTH_SOCK
export SSH_AGENT_PID export SSH_AGENT_PID
export GPG_TTY="$(tty)" export GPG_TTY="$(tty)"