diff options
| author | Simeon Simeonov | 2018-04-15 21:58:06 +0200 |
|---|---|---|
| committer | Simeon Simeonov | 2018-04-15 21:58:06 +0200 |
| commit | 7f2064ed526db2e54b3ebde04e58beaffbb397ed (patch) | |
| tree | 5aac51841b582d89489c37e6b2a303840e7cfb87 | |
| parent | a651d4876f775a2b00f88df49ead47557c6cc18e (diff) | |
Finish master password unload issue. Fix an old bug reintroduced by the magic of copy & paste
| -rw-r--r-- | libsylph/masterpassword.c | 6 | ||||
| -rw-r--r-- | src/inputdialog.c | 17 | ||||
| -rw-r--r-- | src/main.c | 3 |
3 files changed, 18 insertions, 8 deletions
diff --git a/libsylph/masterpassword.c b/libsylph/masterpassword.c index bac49c4..3d7af94 100644 --- a/libsylph/masterpassword.c +++ b/libsylph/masterpassword.c | |||
| @@ -50,6 +50,7 @@ void cleanse_buffer(void *buf, size_t len) { | |||
| 50 | 50 | ||
| 51 | void unload_master_password(void) { | 51 | void unload_master_password(void) { |
| 52 | 52 | ||
| 53 | debug_print("Unloading master password\n"); | ||
| 53 | if (master_password == NULL) { | 54 | if (master_password == NULL) { |
| 54 | /* not loaded / already unloaded */ | 55 | /* not loaded / already unloaded */ |
| 55 | return; | 56 | return; |
| @@ -57,6 +58,7 @@ void unload_master_password(void) { | |||
| 57 | cleanse_buffer(master_password, strlen(master_password)); | 58 | cleanse_buffer(master_password, strlen(master_password)); |
| 58 | g_free(master_password); | 59 | g_free(master_password); |
| 59 | master_password = NULL; | 60 | master_password = NULL; |
| 61 | debug_print("Master password unloaded\n"); | ||
| 60 | 62 | ||
| 61 | } | 63 | } |
| 62 | 64 | ||
| @@ -105,7 +107,7 @@ gchar *decrypt_with_master_password(const gchar *str) { | |||
| 105 | if (decrypt_data(&new_str, | 107 | if (decrypt_data(&new_str, |
| 106 | str + str_prefix, | 108 | str + str_prefix, |
| 107 | master_password, | 109 | master_password, |
| 108 | strlen(str) - str_prefix) != MP_RC_OK) { | 110 | strlen(str) + 1 - str_prefix) != MP_RC_OK) { |
| 109 | OPENSSL_cleanse(new_str, strlen(new_str)); | 111 | OPENSSL_cleanse(new_str, strlen(new_str)); |
| 110 | g_free(new_str); | 112 | g_free(new_str); |
| 111 | return g_strdup(str); | 113 | return g_strdup(str); |
| @@ -136,7 +138,7 @@ gchar *encrypt_with_master_password(const gchar *str) { | |||
| 136 | &length_encrypted, | 138 | &length_encrypted, |
| 137 | str, | 139 | str, |
| 138 | master_password, | 140 | master_password, |
| 139 | strlen(str), | 141 | strlen(str) + 1, |
| 140 | prefs_common.encrypted_password_min_length, | 142 | prefs_common.encrypted_password_min_length, |
| 141 | TRUE) != MP_RC_OK) { | 143 | TRUE) != MP_RC_OK) { |
| 142 | g_free(new_str); | 144 | g_free(new_str); |
diff --git a/src/inputdialog.c b/src/inputdialog.c index 2510bbb..cdfb997 100644 --- a/src/inputdialog.c +++ b/src/inputdialog.c | |||
| @@ -159,9 +159,20 @@ gchar *input_dialog_query_password(const gchar *server, const gchar *user) | |||
| 159 | 159 | ||
| 160 | gchar *input_dialog_query_master_password(void) | 160 | gchar *input_dialog_query_master_password(void) |
| 161 | { | 161 | { |
| 162 | return input_dialog_with_invisible(_("Input password"), | 162 | gchar *mp_input; |
| 163 | _("Master password"), | 163 | |
| 164 | NULL); | 164 | mp_input = input_dialog_with_invisible(_("Input password"), |
| 165 | _("Master password"), | ||
| 166 | NULL); | ||
| 167 | |||
| 168 | if (prefs_common.use_master_password && | ||
| 169 | prefs_common.auto_unload_master_password) | ||
| 170 | { | ||
| 171 | g_timeout_add(1000 * 30, unload_master_password, NULL); | ||
| 172 | debug_print("Master password to be unloaded in 30 seconds\n"); | ||
| 173 | } | ||
| 174 | |||
| 175 | return mp_input; | ||
| 165 | } | 176 | } |
| 166 | 177 | ||
| 167 | gchar *input_dialog_set_new_password(guint max_attempts) | 178 | gchar *input_dialog_set_new_password(guint max_attempts) |
| @@ -426,9 +426,6 @@ int main(int argc, char *argv[]) | |||
| 426 | if (prefs_common.auto_unload_master_password && master_password_active()) { | 426 | if (prefs_common.auto_unload_master_password && master_password_active()) { |
| 427 | debug_print("Auto unloading master password\n"); | 427 | debug_print("Auto unloading master password\n"); |
| 428 | unload_master_password(); | 428 | unload_master_password(); |
| 429 | /* call this function every 10th minute in case a reload took place */ | ||
| 430 | /* TODO: Perhaps a more elegant solution could be developed */ | ||
| 431 | g_timeout_add(1000 * 60 * 10, unload_master_password, NULL); | ||
| 432 | } | 429 | } |
| 433 | #endif | 430 | #endif |
| 434 | 431 | ||
