]> gitweb.fluxo.info Git - keyringer.git/commitdiff
Make keyringer_check_expiration not fail on subkeys which do not have an expiration...
authorSilvio Rhatto <rhatto@riseup.net>
Mon, 19 Dec 2016 14:27:22 +0000 (12:27 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Mon, 19 Dec 2016 14:27:22 +0000 (12:27 -0200)
lib/keyringer/functions

index 09b004d72b99e7c9e3d351c351e7ce981a6b0bc1..fd0176b3e231422767c5c1817fd9c71158a672ed 100755 (executable)
@@ -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