#!/bin/bash # author: Petteri Räty # Released under GPL-2. See ${PORTDIR}/licenses/GPL-2 # See http://bugs.gentoo.org/show_bug.cgi?id=164523 for reasons to this script. # This wrapper should be removed when everything works with gnupg-2* info="${GPG_AGENT_INFO}" args="" # Emulate behaviour from gpg-1 for((i=1; i<= $#; i++)); do if [[ ${!i} = --gpg-agent-info ]]; then ((i++)) [[ -z ${info} ]] && info="${!i}" else args="${args} ${!i}" fi done if [[ -z ${info} ]]; then info_file="${HOME}/.gnupg/.gpg-agent-info" [[ -e "${info_file}" ]] && source "${info_file}" info="${GPG_AGENT_INFO}" fi # This is were for example app-crypt/seahorse saves it if [[ -z ${info} ]]; then info_file="${HOME}/.gnupg/gpg.conf" [[ -e "${info_file}" ]] && info="$(awk '/^\s*gpg-agent-info/{print $2}' ~/.gnupg/gpg.conf "${info_file}")" fi bin=/usr/bin/gpg2 if [[ $info ]]; then echo DATE: `date` PARENT: $PPID AGENT: ${info} >> /tmp/gpg-wrapper-debug GPG_AGENT_INFO="${info}" ${bin} ${args} else echo DATE: `date` PARENT: $PPID NO AGENT! >> /tmp/gpg-wrapper-debug ${bin} ${args} fi