diff options
Diffstat (limited to 'libsylph/masterpassword.c')
| -rw-r--r-- | libsylph/masterpassword.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/libsylph/masterpassword.c b/libsylph/masterpassword.c index 950b79a..8174def 100644 --- a/libsylph/masterpassword.c +++ b/libsylph/masterpassword.c | |||
| @@ -26,6 +26,7 @@ | |||
| 26 | #include "prefs_common.h" | 26 | #include "prefs_common.h" |
| 27 | #include "ssl.h" | 27 | #include "ssl.h" |
| 28 | #include "utils.h" | 28 | #include "utils.h" |
| 29 | #include "masterpassword.h" | ||
| 29 | 30 | ||
| 30 | 31 | ||
| 31 | gchar *master_password; | 32 | gchar *master_password; |
| @@ -84,9 +85,18 @@ gchar *decrypt_with_master_password(const gchar *str) { | |||
| 84 | gchar *new_str; | 85 | gchar *new_str; |
| 85 | gint str_prefix; | 86 | gint str_prefix; |
| 86 | 87 | ||
| 87 | if ((!str) || (!master_password_active())) | 88 | if ((!str) || (!prefs_common.use_master_password)) |
| 88 | return g_strdup(str); | 89 | return g_strdup(str); |
| 89 | 90 | ||
| 91 | if (master_password == NULL) { | ||
| 92 | /* we have empty or auto unloaded master password */ | ||
| 93 | if ((!prefs_common.auto_unload_master_password) || | ||
| 94 | (check_master_password_interactively(3) != RC_OK)) { | ||
| 95 | return g_strdup(str); | ||
| 96 | } | ||
| 97 | debug_print("Reloaded master password\n"); | ||
| 98 | } | ||
| 99 | |||
| 90 | str_prefix = mpes_string_prefix(str); | 100 | str_prefix = mpes_string_prefix(str); |
| 91 | if (!str_prefix) | 101 | if (!str_prefix) |
| 92 | return g_strdup(str); | 102 | return g_strdup(str); |
| @@ -113,9 +123,18 @@ gchar *encrypt_with_master_password(const gchar *str) { | |||
| 113 | gchar *new_str, *mpes1_str; | 123 | gchar *new_str, *mpes1_str; |
| 114 | gint length_encrypted; | 124 | gint length_encrypted; |
| 115 | 125 | ||
| 116 | if ((!str) || (!master_password_active())) | 126 | if ((!str) || (!prefs_common.use_master_password)) |
| 117 | return g_strdup(str); | 127 | return g_strdup(str); |
| 118 | 128 | ||
| 129 | if (master_password == NULL) { | ||
| 130 | /* we have empty or auto unloaded master password */ | ||
| 131 | if ((!prefs_common.auto_unload_master_password) || | ||
| 132 | (check_master_password_interactively(3) != RC_OK)) { | ||
| 133 | return g_strdup(str); | ||
| 134 | } | ||
| 135 | debug_print("Reloaded master password\n"); | ||
| 136 | } | ||
| 137 | |||
| 119 | if (encrypt_data(&new_str, | 138 | if (encrypt_data(&new_str, |
| 120 | &length_encrypted, | 139 | &length_encrypted, |
| 121 | str, | 140 | str, |
