summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2013-03-18 18:16:51 -0300
committerSilvio Rhatto <rhatto@riseup.net>2013-03-18 18:16:51 -0300
commit76cde135667b52ebb3b16de230370296fae660da (patch)
tree1cab8599fbf179fe1b9b8803aad2742cda5c0e11
parent7423fcdcbbe586d2e6b6b675dbaff8a7a7bf7d0f (diff)
downloadkeyringer-76cde135667b52ebb3b16de230370296fae660da.tar.gz
keyringer-76cde135667b52ebb3b16de230370296fae660da.tar.bz2
Decrypt/encrypt approach (#6)
-rwxr-xr-xshare/keyringer/recrypt15
1 files changed, 11 insertions, 4 deletions
diff --git a/share/keyringer/recrypt b/share/keyringer/recrypt
index 695e789..9153456 100755
--- a/share/keyringer/recrypt
+++ b/share/keyringer/recrypt
@@ -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