diff options
| author | Simeon Simeonov | 2018-02-28 23:51:46 +0100 |
|---|---|---|
| committer | Simeon Simeonov | 2018-02-28 23:51:46 +0100 |
| commit | 8de2d887916cbdd3c2d756e77116585babd026f2 (patch) | |
| tree | 15728a8be1602f176ac7d92b09a9eae57b354657 | |
| parent | 1bb2a9d33e8cd193c21f9995fb7852c7562cafcf (diff) | |
prefs_common.use_master_password added
| -rw-r--r-- | libsylph/imap.c | 23 | ||||
| -rw-r--r-- | libsylph/prefs_common.c | 6 | ||||
| -rw-r--r-- | libsylph/prefs_common.h | 3 | ||||
| -rw-r--r-- | src/prefs_common_dialog.c | 47 | ||||
| -rw-r--r-- | src/send_message.c | 25 |
5 files changed, 79 insertions, 25 deletions
diff --git a/libsylph/imap.c b/libsylph/imap.c index a61dc2b..0cd4409 100644 --- a/libsylph/imap.c +++ b/libsylph/imap.c | |||
| @@ -707,17 +707,17 @@ static gint imap_session_connect(IMAPSession *session) | |||
| 707 | log_message(_("creating IMAP4 connection to %s:%d ...\n"), | 707 | log_message(_("creating IMAP4 connection to %s:%d ...\n"), |
| 708 | SESSION(session)->server, SESSION(session)->port); | 708 | SESSION(session)->server, SESSION(session)->port); |
| 709 | 709 | ||
| 710 | if (account->master_password != NULL) { | 710 | if (prefs_common.use_master_password && account->master_password != NULL) { |
| 711 | if (decrypt_data(&pass, | 711 | if (decrypt_data(&pass, |
| 712 | account->passwd, | 712 | account->passwd, |
| 713 | account->master_password, | 713 | account->master_password, |
| 714 | strlen(account->passwd)) != RC_OK) { | 714 | strlen(account->passwd) + 1) != RC_OK) { |
| 715 | session_destroy(session); | 715 | session_destroy(session); |
| 716 | return -1; | 716 | return -1; |
| 717 | } | 717 | } |
| 718 | } else { | 718 | } else { |
| 719 | pass = account->passwd; | 719 | pass = account->passwd; |
| 720 | } | 720 | } |
| 721 | if (!pass) | 721 | if (!pass) |
| 722 | pass = account->tmp_pass; | 722 | pass = account->tmp_pass; |
| 723 | if (!pass) { | 723 | if (!pass) { |
| @@ -731,7 +731,6 @@ static gint imap_session_connect(IMAPSession *session) | |||
| 731 | account->tmp_pass = tmp_pass; | 731 | account->tmp_pass = tmp_pass; |
| 732 | pass = account->tmp_pass; | 732 | pass = account->tmp_pass; |
| 733 | } | 733 | } |
| 734 | |||
| 735 | if (account->use_socks && account->use_socks_for_recv && | 734 | if (account->use_socks && account->use_socks_for_recv && |
| 736 | account->proxy_host) { | 735 | account->proxy_host) { |
| 737 | socks_info = socks_info_new(account->socks_type, account->proxy_host, account->proxy_port, account->use_proxy_auth ? account->proxy_name : NULL, account->use_proxy_auth ? account->proxy_pass : NULL); | 736 | socks_info = socks_info_new(account->socks_type, account->proxy_host, account->proxy_port, account->use_proxy_auth ? account->proxy_name : NULL, account->use_proxy_auth ? account->proxy_pass : NULL); |
diff --git a/libsylph/prefs_common.c b/libsylph/prefs_common.c index 91814fd..68f72fa 100644 --- a/libsylph/prefs_common.c +++ b/libsylph/prefs_common.c | |||
| @@ -415,9 +415,13 @@ static PrefParam param[] = { | |||
| 415 | #ifdef G_OS_WIN32 | 415 | #ifdef G_OS_WIN32 |
| 416 | {"show_gpg_warning", "FALSE", &prefs_common.gpg_warning, P_BOOL}, | 416 | {"show_gpg_warning", "FALSE", &prefs_common.gpg_warning, P_BOOL}, |
| 417 | #else | 417 | #else |
| 418 | {"show_gpg_warning", "TRUE", &prefs_common.gpg_warning, P_BOOL}, | 418 | {"show_gpg_warning", "TRUE", &prefs_common.gpg_warning, P_BOOL}, |
| 419 | #endif | 419 | #endif |
| 420 | 420 | ||
| 421 | /* Master password */ | ||
| 422 | {"use_master_password", "FALSE", &prefs_common.use_master_password, | ||
| 423 | P_BOOL}, | ||
| 424 | |||
| 421 | /* Interface */ | 425 | /* Interface */ |
| 422 | {"separate_folder", "FALSE", &prefs_common.sep_folder, P_BOOL}, | 426 | {"separate_folder", "FALSE", &prefs_common.sep_folder, P_BOOL}, |
| 423 | {"separate_message", "FALSE", &prefs_common.sep_msg, P_BOOL}, | 427 | {"separate_message", "FALSE", &prefs_common.sep_msg, P_BOOL}, |
diff --git a/libsylph/prefs_common.h b/libsylph/prefs_common.h index 910f370..ef5bb9b 100644 --- a/libsylph/prefs_common.h +++ b/libsylph/prefs_common.h | |||
| @@ -249,6 +249,9 @@ struct _PrefsCommon | |||
| 249 | gboolean passphrase_grab; | 249 | gboolean passphrase_grab; |
| 250 | gboolean gpg_warning; | 250 | gboolean gpg_warning; |
| 251 | 251 | ||
| 252 | /* Master password */ | ||
| 253 | gboolean use_master_password; | ||
| 254 | |||
| 252 | /* Interface */ | 255 | /* Interface */ |
| 253 | gboolean sep_folder; | 256 | gboolean sep_folder; |
| 254 | gboolean sep_msg; | 257 | gboolean sep_msg; |
diff --git a/src/prefs_common_dialog.c b/src/prefs_common_dialog.c index fa4be4e..dada1b1 100644 --- a/src/prefs_common_dialog.c +++ b/src/prefs_common_dialog.c | |||
| @@ -216,6 +216,12 @@ static struct Privacy { | |||
| 216 | } privacy; | 216 | } privacy; |
| 217 | #endif | 217 | #endif |
| 218 | 218 | ||
| 219 | #if USE_SSL | ||
| 220 | static struct MasterPassword { | ||
| 221 | GtkWidget *checkbtn_use_master_password; | ||
| 222 | } master_password; | ||
| 223 | #endif | ||
| 224 | |||
| 219 | static struct Interface { | 225 | static struct Interface { |
| 220 | GtkWidget *checkbtn_always_show_msg; | 226 | GtkWidget *checkbtn_always_show_msg; |
| 221 | GtkWidget *checkbtn_always_mark_read; | 227 | GtkWidget *checkbtn_always_mark_read; |
| @@ -563,6 +569,11 @@ static PrefsUIData ui_data[] = { | |||
| 563 | prefs_set_data_from_toggle, prefs_set_toggle}, | 569 | prefs_set_data_from_toggle, prefs_set_toggle}, |
| 564 | #endif /* USE_GPGME */ | 570 | #endif /* USE_GPGME */ |
| 565 | 571 | ||
| 572 | #if USE_SSL | ||
| 573 | {"use_master_password", &master_password.checkbtn_use_master_password, | ||
| 574 | prefs_set_data_from_toggle, prefs_set_toggle}, | ||
| 575 | #endif | ||
| 576 | |||
| 566 | /* Interface */ | 577 | /* Interface */ |
| 567 | {"always_show_message_when_selected", | 578 | {"always_show_message_when_selected", |
| 568 | &iface.checkbtn_always_show_msg, | 579 | &iface.checkbtn_always_show_msg, |
| @@ -693,6 +704,9 @@ static void prefs_junk_create (void); | |||
| 693 | #if USE_GPGME | 704 | #if USE_GPGME |
| 694 | static void prefs_privacy_create (void); | 705 | static void prefs_privacy_create (void); |
| 695 | #endif | 706 | #endif |
| 707 | #if USE_SSL | ||
| 708 | static void prefs_master_password_create (void); | ||
| 709 | #endif | ||
| 696 | static void prefs_details_create (void); | 710 | static void prefs_details_create (void); |
| 697 | static GtkWidget *prefs_other_create (void); | 711 | static GtkWidget *prefs_other_create (void); |
| 698 | static GtkWidget *prefs_extcmd_create (void); | 712 | static GtkWidget *prefs_extcmd_create (void); |
| @@ -853,6 +867,10 @@ static void prefs_common_create(void) | |||
| 853 | prefs_privacy_create(); | 867 | prefs_privacy_create(); |
| 854 | SET_NOTEBOOK_LABEL(dialog.notebook, _("Privacy"), page++); | 868 | SET_NOTEBOOK_LABEL(dialog.notebook, _("Privacy"), page++); |
| 855 | #endif | 869 | #endif |
| 870 | #if USE_SSL | ||
| 871 | prefs_master_password_create(); | ||
| 872 | SET_NOTEBOOK_LABEL(dialog.notebook, _("Master password"), page++); | ||
| 873 | #endif | ||
| 856 | prefs_details_create(); | 874 | prefs_details_create(); |
| 857 | SET_NOTEBOOK_LABEL(dialog.notebook, _("Details"), page++); | 875 | SET_NOTEBOOK_LABEL(dialog.notebook, _("Details"), page++); |
| 858 | 876 | ||
| @@ -2648,6 +2666,35 @@ static void prefs_privacy_create(void) | |||
| 2648 | } | 2666 | } |
| 2649 | #endif /* USE_GPGME */ | 2667 | #endif /* USE_GPGME */ |
| 2650 | 2668 | ||
| 2669 | #if USE_SSL | ||
| 2670 | static void prefs_master_password_create(void) | ||
| 2671 | { | ||
| 2672 | GtkWidget *vbox1; | ||
| 2673 | GtkWidget *vbox2; | ||
| 2674 | GtkWidget *hbox1; | ||
| 2675 | GtkWidget *checkbtn_use_master_password; | ||
| 2676 | |||
| 2677 | vbox1 = gtk_vbox_new (FALSE, VSPACING); | ||
| 2678 | gtk_widget_show (vbox1); | ||
| 2679 | gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1); | ||
| 2680 | gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER); | ||
| 2681 | |||
| 2682 | vbox2 = gtk_vbox_new (FALSE, 0); | ||
| 2683 | gtk_widget_show (vbox2); | ||
| 2684 | gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0); | ||
| 2685 | |||
| 2686 | PACK_CHECK_BUTTON (vbox2, checkbtn_use_master_password, | ||
| 2687 | _("Use master password")); | ||
| 2688 | |||
| 2689 | hbox1 = gtk_hbox_new (FALSE, 8); | ||
| 2690 | gtk_widget_show (hbox1); | ||
| 2691 | gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0); | ||
| 2692 | |||
| 2693 | master_password.checkbtn_use_master_password | ||
| 2694 | = checkbtn_use_master_password; | ||
| 2695 | } | ||
| 2696 | #endif /* USE_SSL */ | ||
| 2697 | |||
| 2651 | static void prefs_details_create(void) | 2698 | static void prefs_details_create(void) |
| 2652 | { | 2699 | { |
| 2653 | GtkWidget *vbox1; | 2700 | GtkWidget *vbox1; |
diff --git a/src/send_message.c b/src/send_message.c index 695246a..7b66423 100644 --- a/src/send_message.c +++ b/src/send_message.c | |||
| @@ -649,18 +649,19 @@ static gint send_message_smtp(PrefsAccount *ac_prefs, GSList *to_list, FILE *fp) | |||
| 649 | if (ac_prefs->smtp_userid) { | 649 | if (ac_prefs->smtp_userid) { |
| 650 | smtp_session->user = g_strdup(ac_prefs->smtp_userid); | 650 | smtp_session->user = g_strdup(ac_prefs->smtp_userid); |
| 651 | if (ac_prefs->smtp_passwd) { | 651 | if (ac_prefs->smtp_passwd) { |
| 652 | if(ac_prefs->master_password != NULL) { | 652 | if(prefs_common.use_master_password && |
| 653 | if (decrypt_data(&(smtp_session->pass), | 653 | ac_prefs->master_password != NULL) { |
| 654 | ac_prefs->smtp_passwd, | 654 | if (decrypt_data(&(smtp_session->pass), |
| 655 | ac_prefs->master_password, | 655 | ac_prefs->smtp_passwd, |
| 656 | strlen(ac_prefs->smtp_passwd)) != RC_OK) { | 656 | ac_prefs->master_password, |
| 657 | session_destroy(session); | 657 | strlen(ac_prefs->smtp_passwd) + 1) != RC_OK) { |
| 658 | return -1; | 658 | session_destroy(session); |
| 659 | } | 659 | return -1; |
| 660 | } else { | 660 | } |
| 661 | smtp_session->pass = | 661 | } else { |
| 662 | g_strdup(ac_prefs->smtp_passwd); | 662 | smtp_session->pass = |
| 663 | } | 663 | g_strdup(ac_prefs->smtp_passwd); |
| 664 | } | ||
| 664 | } else if (ac_prefs->tmp_smtp_pass) { | 665 | } else if (ac_prefs->tmp_smtp_pass) { |
| 665 | smtp_session->pass = | 666 | smtp_session->pass = |
| 666 | g_strdup(ac_prefs->tmp_smtp_pass); | 667 | g_strdup(ac_prefs->tmp_smtp_pass); |
