From c12b5c6c7eccb8e0922ff034bb3690774e12998c Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Mon, 19 Dec 2016 12:27:22 -0200 Subject: Make keyringer_check_expiration not fail on subkeys which do not have an expiration date --- lib/keyringer/functions | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/keyringer/functions b/lib/keyringer/functions index 09b004d..fd0176b 100755 --- a/lib/keyringer/functions +++ b/lib/keyringer/functions @@ -722,19 +722,25 @@ function keyringer_check_expiration { fi # Check the subkeys - expiry="" - for expiry in `gpg --with-colons --fixed-list-mode --list-keys "$recipient" | grep ^sub | cut -d : -f 7`; do + local subkey="" + for subkey in $(gpg --with-colons --fixed-list-mode --list-keys "$recipient" | grep ^sub); do + local expiry=$(cut -d : -f 7 <<< "$subkey") + if [[ -z "$expiry" ]]; then + not_expired=1 + break + fi if [[ "$seconds" -lt "$expiry" ]]; then not_expired="1" if [[ "$ahead" -gt "$expiry" ]] && [ "$BASENAME" == "check" ]; then echo "Warning: subkey from $recipient will expire soon, on `date --date="@$expiry"`" fi + break fi done # All subkeys are expired - if [ ! -z "$expiry" ] && [ "$not_expired" != "1" ]; then + if [ ! -z "$subkey" ] && [ "$not_expired" != "1" ]; then echo "Fatal: key $recipient has no keys suitable for encryption: all subkeys expired." exit 1 fi -- cgit v1.2.3