summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimeon Simeonov2018-04-13 15:24:01 +0200
committerSimeon Simeonov2018-04-13 15:24:01 +0200
commit46275eef3de4e025b5657e67e142fc58125779be (patch)
tree2c4e86aa5f7e286d64a74a35d749c5e381110cad /src
parent42772c59f490d54d9766e1853daa35c08298f985 (diff)
Add support for auto-unloading av the master password
Diffstat (limited to 'src')
-rw-r--r--src/main.c7
-rw-r--r--src/prefs_common_dialog.c15
-rw-r--r--src/prefs_ui.c19
3 files changed, 39 insertions, 2 deletions
diff --git a/src/main.c b/src/main.c
index c6bd812..3c87c70 100644
--- a/src/main.c
+++ b/src/main.c
@@ -412,6 +412,13 @@ int main(int argc, char *argv[])
412 412
413 remote_command_exec(); 413 remote_command_exec();
414 414
415#if USE_SSL
416 if (prefs_common.auto_unload_master_password && master_password_active()) {
417 debug_print("Auto unloading master password\n");
418 unload_master_password();
419 }
420#endif
421
415#if USE_UPDATE_CHECK 422#if USE_UPDATE_CHECK
416 if (prefs_common.auto_update_check) 423 if (prefs_common.auto_update_check)
417 update_check(FALSE); 424 update_check(FALSE);
diff --git a/src/prefs_common_dialog.c b/src/prefs_common_dialog.c
index 41fdb24..119a056 100644
--- a/src/prefs_common_dialog.c
+++ b/src/prefs_common_dialog.c
@@ -219,6 +219,7 @@ static struct Privacy {
219#if USE_SSL 219#if USE_SSL
220static struct MasterPassword { 220static struct MasterPassword {
221 GtkWidget *checkbtn_use_master_password; 221 GtkWidget *checkbtn_use_master_password;
222 GtkWidget *checkbtn_auto_unload_master_password;
222 GtkWidget *spinbtn_encrypted_password_min_length; 223 GtkWidget *spinbtn_encrypted_password_min_length;
223} master_password; 224} master_password;
224#endif 225#endif
@@ -573,6 +574,9 @@ static PrefsUIData ui_data[] = {
573#if USE_SSL 574#if USE_SSL
574 {"use_master_password", &master_password.checkbtn_use_master_password, 575 {"use_master_password", &master_password.checkbtn_use_master_password,
575 prefs_set_data_from_toggle, prefs_set_toggle}, 576 prefs_set_data_from_toggle, prefs_set_toggle},
577 {"auto_unload_master_password",
578 &master_password.checkbtn_auto_unload_master_password,
579 prefs_set_data_from_toggle, prefs_set_toggle},
576 {"encrypted_password_min_length", 580 {"encrypted_password_min_length",
577 &master_password.spinbtn_encrypted_password_min_length, 581 &master_password.spinbtn_encrypted_password_min_length,
578 prefs_set_data_from_spinbtn, 582 prefs_set_data_from_spinbtn,
@@ -2681,6 +2685,7 @@ static void prefs_master_password_create(void)
2681 GtkWidget *hbox_spc; 2685 GtkWidget *hbox_spc;
2682 GtkWidget *label; 2686 GtkWidget *label;
2683 GtkWidget *checkbtn_use_master_password; 2687 GtkWidget *checkbtn_use_master_password;
2688 GtkWidget *checkbtn_auto_unload_master_password;
2684 GtkWidget *spinbtn_encrypted_password_min_length; 2689 GtkWidget *spinbtn_encrypted_password_min_length;
2685 GtkObject *spinbtn_encrypted_password_min_length_adj; 2690 GtkObject *spinbtn_encrypted_password_min_length_adj;
2686 2691
@@ -2706,6 +2711,11 @@ static void prefs_master_password_create(void)
2706 FALSE, 2711 FALSE,
2707 0); 2712 0);
2708 2713
2714 PACK_CHECK_BUTTON (vbox_master_password_suboptions,
2715 checkbtn_auto_unload_master_password,
2716 _("Automatically unload master password "
2717 "after session initialization"));
2718
2709 hbox1 = gtk_hbox_new (FALSE, 8); 2719 hbox1 = gtk_hbox_new (FALSE, 8);
2710 gtk_widget_show (hbox1); 2720 gtk_widget_show (hbox1);
2711 gtk_box_pack_start (GTK_BOX (vbox_master_password_suboptions), 2721 gtk_box_pack_start (GTK_BOX (vbox_master_password_suboptions),
@@ -2740,10 +2750,13 @@ static void prefs_master_password_create(void)
2740 64, 2750 64,
2741 -1); 2751 -1);
2742 2752
2743 SET_TOGGLE_SENSITIVITY (checkbtn_use_master_password, hbox1); 2753 SET_TOGGLE_SENSITIVITY (checkbtn_use_master_password,
2754 vbox_master_password_suboptions);
2744 2755
2745 master_password.checkbtn_use_master_password 2756 master_password.checkbtn_use_master_password
2746 = checkbtn_use_master_password; 2757 = checkbtn_use_master_password;
2758 master_password.checkbtn_auto_unload_master_password
2759 = checkbtn_auto_unload_master_password;
2747 master_password.spinbtn_encrypted_password_min_length 2760 master_password.spinbtn_encrypted_password_min_length
2748 = spinbtn_encrypted_password_min_length; 2761 = spinbtn_encrypted_password_min_length;
2749} 2762}
diff --git a/src/prefs_ui.c b/src/prefs_ui.c
index 5539f4a..051a058 100644
--- a/src/prefs_ui.c
+++ b/src/prefs_ui.c
@@ -31,6 +31,7 @@
31#include <errno.h> 31#include <errno.h>
32 32
33#include "prefs.h" 33#include "prefs.h"
34#include "prefs_common.h"
34#include "prefs_ui.h" 35#include "prefs_ui.h"
35#include "menu.h" 36#include "menu.h"
36#include "codeconv.h" 37#include "codeconv.h"
@@ -276,9 +277,25 @@ void prefs_set_data_from_epass_entry(PrefParam *pparam)
276 gchar **str; 277 gchar **str;
277 const gchar *entry_str; 278 const gchar *entry_str;
278 279
279 if (!master_password_active()) { 280 /* This is where decrypted passwords are encrypted and stored again */
281
282 /* TODO: A potential exploit is disabling master password and then forcing
283 * Sylpheed to store the password
284 */
285
286 /* master_password == NULL for any of the following reasons:
287 * - use_master_password is not enabled (we just save without encrypting)
288 * - master_password is auto unloaded (let the encrypt function handle it)
289 * - undefined reason (refure to store the password)
290 */
291 if (!prefs_common.use_master_password) {
280 prefs_set_data_from_entry(pparam); 292 prefs_set_data_from_entry(pparam);
281 return; 293 return;
294 } else if ((master_password == NULL) &&
295 (!prefs_common.auto_unload_master_password)) {
296 debug_print("Master password enabled, but not loaded for no "
297 "apparent reason. Not storing\n");
298 return;
282 } 299 }
283 300
284 ui_data = (PrefsUIData *)pparam->ui_data; 301 ui_data = (PrefsUIData *)pparam->ui_data;