diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2016-12-21 10:19:25 -0200 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2016-12-21 10:19:25 -0200 |
commit | e597eb9acfab30157abefe6317387f6297d3e869 (patch) | |
tree | 2bc0beb9fb4d903a8f80d3cdef98af2b51443ae2 /lib/keyringer/functions | |
parent | e8b1c968d9f1ddd2b10b7a6e584b0f1329debea9 (diff) | |
parent | ea9326628e6e872798a96063fccd76d964a75583 (diff) | |
download | keyringer-e597eb9acfab30157abefe6317387f6297d3e869.tar.gz keyringer-e597eb9acfab30157abefe6317387f6297d3e869.tar.bz2 |
Merge branch 'develop'
Diffstat (limited to 'lib/keyringer/functions')
-rwxr-xr-x | lib/keyringer/functions | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/keyringer/functions b/lib/keyringer/functions index 09b004d..bd87fd6 100755 --- a/lib/keyringer/functions +++ b/lib/keyringer/functions @@ -703,7 +703,7 @@ function keyringer_check_expiration { seconds="`date +%s`" # Check the main key - expiry="`gpg --with-colons --fixed-list-mode --list-keys "$recipient" | grep ^pub | cut -d : -f 7`" + expiry="`gpg --with-colons --fixed-list-mode --list-keys "$recipient" | grep ^pub | head -n1 | cut -d : -f 7`" # TODO: Time to expire can be configured via repository options. ahead="$((86400 * 30 + $seconds))" @@ -722,8 +722,14 @@ 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 + fi + if [[ "$seconds" -lt "$expiry" ]]; then not_expired="1" @@ -734,7 +740,7 @@ function keyringer_check_expiration { 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 |