Permalink
Browse files

Merge pull request #2 from DeeNewcum/master

Remove unencrypted temp if original isn't writable
  • Loading branch information...
ptarjan committed Aug 7, 2012
2 parents d8edf7a + 6bcb8a7 commit cc679ebf938f490545c600839bc26a863f470a19
Showing with 6 additions and 2 deletions.
  1. +6 −2 viencrypt
View
@@ -11,7 +11,7 @@ else
fi
# more security for vi
-if [ $editor == "vi" -o $editor == "vim" ]
+if [ $editor = "vi" -o $editor = "vim" ]
then
# -n is for noswap and -i NONE is for no .viminfo
editor="$editor -n -i NONE"
@@ -72,8 +72,12 @@ fi
$editor $tmp
# write changes back out
-if [ -w $filename -o ! -f $filename ]
+if [ -e $filename -a ! -w $filename ]
then
+ # the original file is unwritable, and can't be updated
+ chmod +w $tmp
+ $rm $tmp
+else
echo "$passw" | gpg -q -c --batch --passphrase-fd 0 --output $filename --yes --force-mdc $tmp
$rm $tmp
if [ $? != 0 ]; then

0 comments on commit cc679eb

Please sign in to comment.