Fixed critical issues relating to encryption, including misplaced files

and failure to erase temporary files.
This commit is contained in:
Jon-William Lewis
2016-02-15 18:48:56 -06:00
parent 69bbd06948
commit 6105190e78
6 changed files with 11 additions and 8 deletions

View File

@@ -17,7 +17,7 @@ fi
# If encryption is enabled, decrypt $NOTE to a temp file, otherwise
# operate on the note directly.
if [ "$ENCRYPTION" == "TRUE" ]; then
cp "$NOTES_DIR/$NOTE" "$NOTES_DIR$/$NOTE".bk #Insurance
cp "$NOTES_DIR/$NOTE" "$NOTES_DIR/$NOTE.bk" #Insurance
TMP_NOTE="$TMP_DIR/$SESSION_ID"
decrypt > "$TMP_NOTE"
else
@@ -26,7 +26,7 @@ fi
# Write an ammendment header
if [ -z "$CREATE" ]; then
printf "\n%s\n" "edit - $(date $DATE_FMT)" >> "$TMP_NOTE"
printf "\n%s\n" "edit - $(date "$DATE_FMT")" >> "$TMP_NOTE"
printf "%s\n" "===================================" >> "$TMP_NOTE"
fi
@@ -36,9 +36,11 @@ printf " - %s\n" "editing ${NOTE%.*}"
# If the file was previously decrypted, encrypt it back
if [ "$ENCRYPTION" == "TRUE" ]; then
echo "reencrypting"
rm "$NOTES_DIR/$NOTE"
encrypt;
if [ ! -r "$NOTE" ]; then
rm "$TMP_NOTE"
if [ ! -r "$NOTES_DIR/$NOTE" ]; then
>&2 printf " $RED_COLOR!$RESET_COLOR %s\n" "error: note was not saved."
cp "$NOTES_DIR/$NOTE.bk" "$NOTES_DIR/$NOTE"
else