From: Peter Palfrader Date: Thu, 18 Sep 2008 22:02:40 +0000 (+0200) Subject: Ask before re-encrypting if nothing changed. Make the default to abort if decrypting... X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=38f54fc9d21b8de6dc71737e3bfae933f3ae4ee2;p=pwstore Ask before re-encrypting if nothing changed. Make the default to abort if decrypting was weird --- diff --git a/pws b/pws index a4a947a..a2c8c40 100755 --- a/pws +++ b/pws @@ -315,7 +315,7 @@ class EncryptedFile def decrypt (outtxt, stderrtxt, statustxt, exitstatus) = GnuPG.gpgcall(@encrypted_content, %w{--decrypt}) if !@new and exitstatus != 0 - proceed = read_input("Warning: gpg returned non-zero exit status #{exitstatus} when decrypting #{@filename}. Proceed?") + proceed = read_input("Warning: gpg returned non-zero exit status #{exitstatus} when decrypting #{@filename}. Proceed?", false) exit(0) unless proceed elsif !@new and outtxt.length == 0 proceed = read_input("Warning: #{@filename} decrypted to an empty file. Proceed?") @@ -460,6 +460,7 @@ class Ed end content = encrypted_file.decrypt + original_content = content while true oldsize = content.length tempfile = Tempfile.open('pws') @@ -488,6 +489,11 @@ class Ed exit(0) unless proceed end + if (original_content == content) + proceed = read_input("Nothing changed. Re-encrypt anyway?", false) + exit(0) unless proceed + end + success = encrypted_file.write_back(content) break if success end