From 8f2e8150b5b6a1b58a549fc0324eed9d5b88792d Mon Sep 17 00:00:00 2001 From: harrison Date: Thu, 6 Nov 2014 00:17:59 -0800 Subject: [PATCH 1/3] Created blackbox_cat: Decrypt a file, cat it, shred it --- bin/blackbox_cat | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100755 bin/blackbox_cat diff --git a/bin/blackbox_cat b/bin/blackbox_cat new file mode 100755 index 0000000..141399d --- /dev/null +++ b/bin/blackbox_cat @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +# +# blackbox_cat.sh -- Decrypt a file, cat it, shred it +# +set -e +. _blackbox_common.sh + +for param in """$@""" ; do + unencrypted_file=$(get_unencrypted_filename "$param") + blackbox_edit_start "$param" + cat $unencrypted_file + shred_file "$unencrypted_file" +done From 26ec9319e32dd1f7c4288216b9c305133635d800 Mon Sep 17 00:00:00 2001 From: harrison Date: Thu, 6 Nov 2014 00:28:53 -0800 Subject: [PATCH 2/3] blackbox_shred_all_files now changes to root dir before running. Moved similar code from blackbox_postdeploy into _blackbox_common.sh as change_to_root function. --- bin/_blackbox_common.sh | 14 ++++++++++++++ bin/blackbox_postdeploy | 13 +------------ bin/blackbox_shred_all_files | 2 ++ 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/bin/_blackbox_common.sh b/bin/_blackbox_common.sh index 4e9ecf5..eaf4bd3 100755 --- a/bin/_blackbox_common.sh +++ b/bin/_blackbox_common.sh @@ -390,3 +390,17 @@ function vcs_remove_git() { function vcs_remove_svn() { svn delete """$@""" } + +function change_to_root() { + # If BASEDIR is not set, use REPOBASE. + if [[ "$BASEDIR" = "" ]]; then + BASEDIR="$REPOBASE" + fi + + if [[ "$BASEDIR" = "/dev/null" ]]; then + echo 'WARNING: Not in a VCS repo. Not changing directory.' + else + echo "CDing to $BASEDIR" + cd "$BASEDIR" + fi +} diff --git a/bin/blackbox_postdeploy b/bin/blackbox_postdeploy index 8e285ae..18c9fe1 100755 --- a/bin/blackbox_postdeploy +++ b/bin/blackbox_postdeploy @@ -22,18 +22,7 @@ else FILE_GROUP="$1" fi -# If BASEDIR is not set, use REPOBASE. -if [[ "$BASEDIR" = "" ]]; then - BASEDIR="$REPOBASE" -fi - -if [[ "$BASEDIR" = "/dev/null" ]]; then - echo 'WARNING: Not in a VCS repo. Not changing directory.' -else - echo "CDing to $BASEDIR" - cd "$BASEDIR" -fi - +change_to_root prepare_keychain # Decrypt: diff --git a/bin/blackbox_shred_all_files b/bin/blackbox_shred_all_files index 636633c..74bbfc7 100755 --- a/bin/blackbox_shred_all_files +++ b/bin/blackbox_shred_all_files @@ -18,6 +18,8 @@ set -e . _blackbox_common.sh +change_to_root + echo '========== FILES BEING SHREDDED:' for i in $(<$BB_FILES) ; do unencrypted_file=$(get_unencrypted_filename "$i") From b8575b9c7b6134076c765c64b192f8936133dc84 Mon Sep 17 00:00:00 2001 From: harrison Date: Wed, 12 Nov 2014 00:56:28 -0800 Subject: [PATCH 3/3] Made changes as per tlimoncelli --- bin/blackbox_cat | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bin/blackbox_cat b/bin/blackbox_cat index 141399d..e8893be 100755 --- a/bin/blackbox_cat +++ b/bin/blackbox_cat @@ -7,8 +7,14 @@ set -e . _blackbox_common.sh for param in """$@""" ; do + shreddable=0 unencrypted_file=$(get_unencrypted_filename "$param") - blackbox_edit_start "$param" - cat $unencrypted_file - shred_file "$unencrypted_file" + if [[ ! -e "$unencrypted_file" ]]; then + blackbox_edit_start "$param" + shreddable=1 + fi + cat "$unencrypted_file" + if [[ $shreddable = 1 ]]; then + shred_file "$unencrypted_file" + fi done