summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2020-05-10 10:18:11 +0200
committerErich Eckner <git@eckner.net>2020-05-10 10:26:04 +0200
commitd414dda2cc62bdb6cba459d5530b27cb578568c1 (patch)
tree49953c4ea78a94033ffca2c9628bb26f4a2b082b
parentcb188cb4b5e313b3e3c15908bff4f70d2f839269 (diff)
downloadcrypt-expiry-check-d414dda2cc62bdb6cba459d5530b27cb578568c1.tar.xz
crypt-expiry-check: put parameters into variables
-rwxr-xr-xcrypt-expiry-check.in19
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}