From 772e7ee50725b2d00bdacc141c5b4b606c053138 Mon Sep 17 00:00:00 2001 From: Nich Date: Tue, 5 Apr 2016 19:04:38 -0400 Subject: [PATCH] Fixed error when user fails to enter correct password Pappy would raise exceptions and continued project in clear-text when the user failed to enter the correct decryption password. Added a boolean status variable to config `crypt_success` that gets set to true when project decrypts correctly, otherwise it is set to false. --- pappyproxy/config.py | 1 + pappyproxy/crypto.py | 2 ++ pappyproxy/pappy.py | 8 +++++--- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pappyproxy/config.py b/pappyproxy/config.py index f2b71a6..ed29e8a 100644 --- a/pappyproxy/config.py +++ b/pappyproxy/config.py @@ -170,6 +170,7 @@ class PappyConfig(object): self.crypt_dir = 'crypt' self.crypt_file = 'project.crypt' self.crypt_session = False + self.crypt_success = False self.salt_file = 'project.salt' def get_default_config(self): diff --git a/pappyproxy/crypto.py b/pappyproxy/crypto.py index 40359b2..a8c16cd 100644 --- a/pappyproxy/crypto.py +++ b/pappyproxy/crypto.py @@ -90,6 +90,7 @@ class Crypto(object): # Quit pappy if user doesn't retry # or if all retries exhuasted if not self.confirm_password_retry() or retries <= 0: + self.config.crypt_success = False return False else: self.password = None @@ -106,6 +107,7 @@ class Crypto(object): self.delete_crypt_files() os.chdir(self.config.crypt_dir) + self.config.crypt_success = True return True def confirm_password_retry(self): diff --git a/pappyproxy/pappy.py b/pappyproxy/pappy.py index 0fb3678..0f248c9 100755 --- a/pappyproxy/pappy.py +++ b/pappyproxy/pappy.py @@ -72,9 +72,11 @@ class PappySession(object): if self.config.crypt_session: self.decrypt() - self.config.load_from_file('./config.json') - self.config.global_load_from_file() - self.delete_data_on_quit = False + + if self.config.crypt_success: + self.config.load_from_file('./config.json') + self.config.global_load_from_file() + self.delete_data_on_quit = False # If the data file doesn't exist, create it with restricted permissions if not os.path.isfile(self.config.datafile):