diff options
-rwxr-xr-x | lib/keyringer/functions | 12 |
1 files changed, 9 insertions, 3 deletions
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 |