diff options
Diffstat (limited to 'libsylph')
| -rw-r--r-- | libsylph/masterpassword.c | 23 | ||||
| -rw-r--r-- | libsylph/prefs_account.c | 2 | ||||
| -rw-r--r-- | libsylph/prefs_common.c | 3 | ||||
| -rw-r--r-- | libsylph/prefs_common.h | 3 |
4 files changed, 28 insertions, 3 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, |
diff --git a/libsylph/prefs_account.c b/libsylph/prefs_account.c index fc4d8f1..54cbc89 100644 --- a/libsylph/prefs_account.c +++ b/libsylph/prefs_account.c | |||
| @@ -239,6 +239,7 @@ void prefs_account_read_config(PrefsAccount *ac_prefs, const gchar *label) | |||
| 239 | label); | 239 | label); |
| 240 | tmp_str = ac_prefs->passwd; | 240 | tmp_str = ac_prefs->passwd; |
| 241 | ac_prefs->passwd = encrypt_with_master_password(ac_prefs->passwd); | 241 | ac_prefs->passwd = encrypt_with_master_password(ac_prefs->passwd); |
| 242 | cleanse_buffer(tmp_str, strlen(tmp_str)); | ||
| 242 | g_free(tmp_str); | 243 | g_free(tmp_str); |
| 243 | } | 244 | } |
| 244 | 245 | ||
| @@ -251,6 +252,7 @@ void prefs_account_read_config(PrefsAccount *ac_prefs, const gchar *label) | |||
| 251 | tmp_str = ac_prefs->smtp_passwd; | 252 | tmp_str = ac_prefs->smtp_passwd; |
| 252 | ac_prefs->smtp_passwd = encrypt_with_master_password( | 253 | ac_prefs->smtp_passwd = encrypt_with_master_password( |
| 253 | ac_prefs->smtp_passwd); | 254 | ac_prefs->smtp_passwd); |
| 255 | cleanse_buffer(tmp_str, strlen(tmp_str)); | ||
| 254 | g_free(tmp_str); | 256 | g_free(tmp_str); |
| 255 | } | 257 | } |
| 256 | 258 | ||
diff --git a/libsylph/prefs_common.c b/libsylph/prefs_common.c index dda4a0f..192964e 100644 --- a/libsylph/prefs_common.c +++ b/libsylph/prefs_common.c | |||
| @@ -425,6 +425,9 @@ static PrefParam param[] = { | |||
| 425 | P_STRING}, | 425 | P_STRING}, |
| 426 | {"encrypted_password_min_length", "32", | 426 | {"encrypted_password_min_length", "32", |
| 427 | &prefs_common.encrypted_password_min_length, P_INT}, | 427 | &prefs_common.encrypted_password_min_length, P_INT}, |
| 428 | {"auto_unload_master_password", "FALSE", | ||
| 429 | &prefs_common.auto_unload_master_password, | ||
| 430 | P_BOOL}, | ||
| 428 | 431 | ||
| 429 | /* Interface */ | 432 | /* Interface */ |
| 430 | {"separate_folder", "FALSE", &prefs_common.sep_folder, P_BOOL}, | 433 | {"separate_folder", "FALSE", &prefs_common.sep_folder, P_BOOL}, |
diff --git a/libsylph/prefs_common.h b/libsylph/prefs_common.h index 92333aa..6f9c364 100644 --- a/libsylph/prefs_common.h +++ b/libsylph/prefs_common.h | |||
| @@ -252,7 +252,8 @@ struct _PrefsCommon | |||
| 252 | /* Master password */ | 252 | /* Master password */ |
| 253 | gboolean use_master_password; | 253 | gboolean use_master_password; |
| 254 | gchar *master_password_hash; | 254 | gchar *master_password_hash; |
| 255 | guint encrypted_password_min_length; | 255 | guint encrypted_password_min_length; |
| 256 | gboolean auto_unload_master_password; | ||
| 256 | 257 | ||
| 257 | /* Interface */ | 258 | /* Interface */ |
| 258 | gboolean sep_folder; | 259 | gboolean sep_folder; |
