]> gitweb.fluxo.info Git - keyringer.git/commitdiff
Decrypt/encrypt approach (#6)
authorSilvio Rhatto <rhatto@riseup.net>
Mon, 18 Mar 2013 21:16:51 +0000 (18:16 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Mon, 18 Mar 2013 21:16:51 +0000 (18:16 -0300)
share/keyringer/recrypt

index 695e789d5aab2d5ac2db3682d04272ff2aec6045..9153456963d2a4a40c877efaa54ffadaffd654bf 100755 (executable)
@@ -14,16 +14,23 @@ function keyringer_recrypt {
   # Set recipients file
   keyringer_set_recipients "$FILE"
 
-  # Set pipefail so we can detect decryption failures
-  set -o pipefail
+  # Decrypt
+  decrypted="$($GPG --use-agent -d "$KEYDIR/$FILE" 2> /dev/null)"
+
+  if [ "$?" != "0" ]; then
+    echo "Decryption error."
+    exit 1
+  fi
 
   # Recrypt
-  $GPG --use-agent -d "$KEYDIR/$FILE" | \
-  $GPG --use-agent --armor -e -s $(keyringer_recipients "$RECIPIENTS_FILE") > "$KEYDIR/$FILE"
+  echo "$decrypted" | $GPG --use-agent --armor -e -s $(keyringer_recipients "$RECIPIENTS_FILE") > "$KEYDIR/$FILE"
 
   if [ "$?" != "0" ]; then
+    echo "Recryption error."
     exit 1
   fi
+
+  unset decrypted
 }
 
 if [ ! -z "$2" ]; then