Merge pull request #61 from quarkslab/fix-support_filenames-with-space

Modify several scripts to support or improve support for filenames with space
This commit is contained in:
Tom Limoncelli
2015-03-19 14:21:29 -07:00
6 changed files with 39 additions and 21 deletions

View File

@@ -181,7 +181,7 @@ function decrypt_file() {
encrypted="$1" encrypted="$1"
unencrypted="$2" unencrypted="$2"
echo "========== EXTRACTING $unencrypted" echo '========== EXTRACTING ''"'$unencrypted'"'
old_umask=$(umask) old_umask=$(umask)
umask "$DECRYPT_UMASK" umask "$DECRYPT_UMASK"

View File

@@ -10,8 +10,8 @@ source "${blackbox_home}/_blackbox_common.sh"
unencrypted_file=$(get_unencrypted_filename "$1") unencrypted_file=$(get_unencrypted_filename "$1")
encrypted_file=$(get_encrypted_filename "$1") encrypted_file=$(get_encrypted_filename "$1")
echo ========== PLAINFILE "$unencrypted_file" echo ========== PLAINFILE '"'$unencrypted_file'"'
echo ========== ENCRYPTED "$encrypted_file" echo ========== ENCRYPTED '"'$encrypted_file'"'
fail_if_not_on_cryptlist "$unencrypted_file" fail_if_not_on_cryptlist "$unencrypted_file"
fail_if_not_exists "$unencrypted_file" "No unencrypted version to encrypt!" fail_if_not_exists "$unencrypted_file" "No unencrypted version to encrypt!"
@@ -22,6 +22,6 @@ shred_file "$unencrypted_file"
_determine_vcs_base_and_type _determine_vcs_base_and_type
echo "========== UPDATED ${encrypted_file}" echo ========== UPDATED '"'$encrypted_file'"'
echo "Likely next step:" echo "Likely next step:"
echo " $VCS_TYPE commit -m\"${encrypted_file} updated\" $encrypted_file" echo " $VCS_TYPE commit -m\"${encrypted_file} updated\" \"$encrypted_file\""

View File

@@ -11,7 +11,7 @@ source "${blackbox_home}/_blackbox_common.sh"
for param in """$@""" ; do for param in """$@""" ; do
unencrypted_file=$(get_unencrypted_filename "$param") unencrypted_file=$(get_unencrypted_filename "$param")
encrypted_file=$(get_encrypted_filename "$param") encrypted_file=$(get_encrypted_filename "$param")
echo ========== PLAINFILE "$unencrypted_file" echo ========== PLAINFILE '"'$unencrypted_file'"'
fail_if_not_on_cryptlist "$unencrypted_file" fail_if_not_on_cryptlist "$unencrypted_file"
fail_if_not_exists "$encrypted_file" "This should not happen." fail_if_not_exists "$encrypted_file" "This should not happen."

View File

@@ -26,6 +26,8 @@ fi
change_to_vcs_root change_to_vcs_root
prepare_keychain prepare_keychain
OLDIFS=$IFS
# Decrypt: # Decrypt:
echo '========== Decrypting new/changed files: START' echo '========== Decrypting new/changed files: START'
while IFS= read <&99 -r unencrypted_file; do while IFS= read <&99 -r unencrypted_file; do
@@ -36,4 +38,7 @@ while IFS= read <&99 -r unencrypted_file; do
chgrp "$FILE_GROUP" "$unencrypted_file" chgrp "$FILE_GROUP" "$unencrypted_file"
fi fi
done 99<"$BB_FILES" done 99<"$BB_FILES"
IFS=$OLDIFS
echo '========== Decrypting new/changed files: DONE' echo '========== Decrypting new/changed files: DONE'

View File

@@ -21,14 +21,18 @@ source "${blackbox_home}/_blackbox_common.sh"
change_to_vcs_root change_to_vcs_root
OLDIFS=$IFS
echo '========== FILES BEING SHREDDED:' echo '========== FILES BEING SHREDDED:'
for i in $(<"$BB_FILES") ; do while IFS= read <&99 -r unencrypted_file; do
unencrypted_file=$(get_unencrypted_filename "$i") unencrypted_file=$(get_unencrypted_filename "$unencrypted_file")
encrypted_file=$(get_encrypted_filename "$i") encrypted_file=$(get_encrypted_filename "$unencrypted_file")
if [[ -f "$unencrypted_file" ]]; then if [[ -f "$unencrypted_file" ]]; then
echo " $unencrypted_file" echo " $unencrypted_file"
shred_file "$unencrypted_file" shred_file "$unencrypted_file"
fi fi
done done 99<"$BB_FILES"
IFS=$OLDIFS
echo '========== DONE.' echo '========== DONE.'

View File

@@ -18,19 +18,23 @@ fi
disclose_admins disclose_admins
prepare_keychain prepare_keychain
OLDIFS=$IFS
echo '========== ENCRYPTED FILES TO BE RE-ENCRYPTED:' echo '========== ENCRYPTED FILES TO BE RE-ENCRYPTED:'
awk <"$BB_FILES" '{ print " " $1 ".gpg" }' while IFS= read <&99 -r unencrypted_file; do
echo " $unencrypted_file.gpg"
done 99<"$BB_FILES"
echo '========== FILES IN THE WAY:' echo '========== FILES IN THE WAY:'
need_warning=false need_warning=false
for i in $(<"$BB_FILES") ; do while IFS= read <&99 -r unencrypted_file; do
unencrypted_file=$(get_unencrypted_filename "$i") unencrypted_file=$(get_unencrypted_filename "$unencrypted_file")
encrypted_file=$(get_encrypted_filename "$i") encrypted_file=$(get_encrypted_filename "$unencrypted_file")
if [[ -f "$unencrypted_file" ]]; then if [[ -f "$unencrypted_file" ]]; then
need_warning=true need_warning=true
echo " $unencrypted_file" echo " $unencrypted_file"
fi fi
done done 99<"$BB_FILES"
if "$need_warning" ; then if "$need_warning" ; then
echo echo
echo 'WARNING: This will overwrite any unencrypted files laying about.' echo 'WARNING: This will overwrite any unencrypted files laying about.'
@@ -40,20 +44,25 @@ else
fi fi
echo '========== RE-ENCRYPTING FILES:' echo '========== RE-ENCRYPTING FILES:'
for i in $(<"$BB_FILES") ; do while IFS= read <&99 -r unencrypted_file; do
unencrypted_file=$(get_unencrypted_filename "$i") unencrypted_file=$(get_unencrypted_filename "$unencrypted_file")
encrypted_file=$(get_encrypted_filename "$i") encrypted_file=$(get_encrypted_filename "$unencrypted_file")
echo ========== PROCESSING "$unencrypted_file" echo ========== PROCESSING '"'$unencrypted_file'"'
fail_if_not_on_cryptlist "$unencrypted_file" fail_if_not_on_cryptlist "$unencrypted_file"
decrypt_file_overwrite "$encrypted_file" "$unencrypted_file" decrypt_file_overwrite "$encrypted_file" "$unencrypted_file"
encrypt_file "$unencrypted_file" "$encrypted_file" encrypt_file "$unencrypted_file" "$encrypted_file"
shred_file "$unencrypted_file" shred_file "$unencrypted_file"
done done 99<"$BB_FILES"
fail_if_keychain_has_secrets fail_if_keychain_has_secrets
echo '========== COMMITING TO VCS:' echo '========== COMMITING TO VCS:'
vcs_commit 'Re-encrypted keys' $(awk <"$BB_FILES" '{ print $1 ".gpg" }' ) while IFS= read <&99 -r unencrypted_file; do
vcs_add "$unencrypted_file.gpg"
done 99<"$BB_FILES"
vcs_commit 'Re-encrypted keys'
IFS=$OLDIFS
VCSCMD=$(which_vcs) VCSCMD=$(which_vcs)
echo '========== DONE.' echo '========== DONE.'