From a7baaf2e8cdfae7f8607b4ddf30bfc38cea3ceac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20S=2E=20Magalh=C3=A3es?= Date: Thu, 4 Sep 2014 11:29:23 -0300 Subject: [PATCH 1/2] blackbox_edit created --- bin/blackbox_edit | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 bin/blackbox_edit diff --git a/bin/blackbox_edit b/bin/blackbox_edit new file mode 100755 index 0000000..94b5cc0 --- /dev/null +++ b/bin/blackbox_edit @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +# +# blackbox_edit.sh -- Decrypt a file temporarily for edition, then re-encrypts it again +# + +. _blackbox_common.sh + +for param in """$@""" ; do + unencrypted_file=$(mktemp) + encrypted_file=$(get_encrypted_filename "$param") + echo ========== PLAINFILE "$unencrypted_file" + + fail_if_not_on_cryptlist "$unencrypted_file" + fail_if_not_exists "$encrypted_file" "This should not happen." + if [[ ! -s "$unencrypted_file" ]]; then + rm -f "$unencrypted_file" + fi + if [[ -f "$unencrypted_file" ]]; then + echo SKIPPING: "$1" "Will not overwrite non-empty files." + continue + fi + + prepare_keychain + decrypt_file "$encrypted_file" "$unencrypted_file" + $EDITOR $unencrypted_file +done From 60b7206d8a23ce42b08097512cbcceb782f102b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20S=2E=20Magalh=C3=A3es?= Date: Thu, 4 Sep 2014 11:45:26 -0300 Subject: [PATCH 2/2] re-encrypt and shred after edit --- bin/blackbox_edit | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bin/blackbox_edit b/bin/blackbox_edit index 94b5cc0..9258e41 100755 --- a/bin/blackbox_edit +++ b/bin/blackbox_edit @@ -24,4 +24,11 @@ for param in """$@""" ; do prepare_keychain decrypt_file "$encrypted_file" "$unencrypted_file" $EDITOR $unencrypted_file + + encrypt_file "$unencrypted_file" "$encrypted_file" + shred_file "$unencrypted_file" + + echo "========== UPDATED ${encrypted_file}" + echo "Likely next step:" + echo " git commit -m\"${encrypted_file} updated\" $encrypted_file" done