aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xshare/keyringer/decrypt3
-rwxr-xr-xshare/keyringer/recrypt10
2 files changed, 13 insertions, 0 deletions
diff --git a/share/keyringer/decrypt b/share/keyringer/decrypt
index adc1134..bab9b34 100755
--- a/share/keyringer/decrypt
+++ b/share/keyringer/decrypt
@@ -12,3 +12,6 @@ keyringer_get_file "$2"
# Decrypt
$GPG --quiet --use-agent -d "$KEYDIR/$FILE"
+
+# Exit
+exit "$?"
diff --git a/share/keyringer/recrypt b/share/keyringer/recrypt
index cbf1af9..fc16603 100755
--- a/share/keyringer/recrypt
+++ b/share/keyringer/recrypt
@@ -14,6 +14,16 @@ function keyringer_recrypt {
# Set recipients file
keyringer_set_recipients "$FILE"
+ # Test decryption
+ $GPG --use-agent -d "$KEYDIR/$FILE" > /dev/null
+
+ err="$?"
+
+ if [ "$err" != "0" ]; then
+ echo "$BASENAME: decryption failed. Can't recrypt."
+ exit "$err"
+ fi
+
# Recrypt
$GPG --use-agent -d "$KEYDIR/$FILE" | $GPG --use-agent --armor -e -s $(keyringer_recipients "$RECIPIENTS_FILE") > "$KEYDIR/$FILE"