diff options
-rwxr-xr-x | crypt-expiry-check.in | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/crypt-expiry-check.in b/crypt-expiry-check.in index 419222e..ae706eb 100755 --- a/crypt-expiry-check.in +++ b/crypt-expiry-check.in @@ -397,29 +397,32 @@ check_file_status() { ##################################################### ### Check the expiration status of a gpg-key ### Accepts one parameters: -### $1 -> E-mail address to check +### $1 -> gpg command to use +### $2 -> E-mail address to check ##################################################### check_gpg_key_status() { + GPG_COMMAND="${1}" + GPG_ADDRESS="${2}" + ### Check to make sure gpg is available - if [ ! -f "${1}" ] + if [ ! -f "${GPG_COMMAND}" ] then - >&2 echo "ERROR: The gnupg binary does not exist in ${1}." + >&2 echo "ERROR: The gnupg binary does not exist in ${GPG_COMMAND}." >&2 echo "FIX: Please modify the \${GPG} variable in the program header, provide alternative executable via -G or ommit testing of gpg-keys." exit 1 fi - GPG_ADDRESS="${2}" - KEY_INFO="$(${1} --list-secret-keys "${GPG_ADDRESS}" 2> /dev/null)" - [ -z "${KEY_INFO}" ] && KEY_INFO="$(${1} --list-keys "${GPG_ADDRESS}")" + KEY_INFO=$(${GPG_COMMAND} --list-secret-keys "${GPG_ADDRESS}" 2> /dev/null) + [ -z "${KEY_INFO}" ] && KEY_INFO=$(${GPG_COMMAND} --list-keys "${GPG_ADDRESS}") - KEY_DATE_STR="$( + KEY_DATE_STR=$( echo "${KEY_INFO}" | \ ${GREP} "\[\(expire[ds]\|verfallen\|verf..\?llt\):[^]]*]" | \ ${SED} "s#^.*\[\(expire[ds]\|verfallen\|verf..\?llt\):\s*\(\S[^]]*\)].*\$#\2#" | \ ${SORT} | \ ${TAIL} -n1 - )" + ) if [ -z "${KEY_DATE_STR}" ] then echo "No valid gpg-key found for ${GPG_ADDRESS}." | ${TEE} -a ${MAILOUT_TMP} >> ${STDOUT_TMP} |