diff options
| author | Simeon Simeonov | 2018-03-09 14:02:34 +0100 |
|---|---|---|
| committer | Simeon Simeonov | 2018-03-09 14:02:34 +0100 |
| commit | f1babd48f5259186cd1233288992f942d4b5b0bb (patch) | |
| tree | 54d740ef2201fceb3e54fac31272e80e65079ec7 /src | |
| parent | 57944f6147f077ccf4d84b9d2659f4e8645e8858 (diff) | |
Complete rewrite of the master password implementation
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.c | 28 | ||||
| -rw-r--r-- | src/send_message.c | 22 |
2 files changed, 36 insertions, 14 deletions
| @@ -87,6 +87,7 @@ | |||
| 87 | #include "foldersel.h" | 87 | #include "foldersel.h" |
| 88 | #include "update_check.h" | 88 | #include "update_check.h" |
| 89 | #include "colorlabel.h" | 89 | #include "colorlabel.h" |
| 90 | #include "masterpassword.h" | ||
| 90 | 91 | ||
| 91 | #if USE_GPGME | 92 | #if USE_GPGME |
| 92 | # include "rfc2015.h" | 93 | # include "rfc2015.h" |
| @@ -275,6 +276,32 @@ int main(int argc, char *argv[]) | |||
| 275 | CHDIR_EXIT_IF_FAIL(get_home_dir(), 1); | 276 | CHDIR_EXIT_IF_FAIL(get_home_dir(), 1); |
| 276 | 277 | ||
| 277 | prefs_common_read_config(); | 278 | prefs_common_read_config(); |
| 279 | set_master_password(NULL); | ||
| 280 | #if USE_SSL | ||
| 281 | if (prefs_common.use_master_password) { | ||
| 282 | if (prefs_common.master_password_hash != NULL) { | ||
| 283 | if (check_master_password_interactively(3)) { | ||
| 284 | if (alertpanel(_("Master password"), | ||
| 285 | _("Unable to set master password"), | ||
| 286 | GTK_STOCK_DISCARD, | ||
| 287 | GTK_STOCK_QUIT, | ||
| 288 | NULL) != G_ALERTDEFAULT) { | ||
| 289 | exit(1); | ||
| 290 | } | ||
| 291 | } | ||
| 292 | } else { | ||
| 293 | if (set_master_password_interactively(3) != 0) { | ||
| 294 | if (alertpanel(_("Master password"), | ||
| 295 | _("Unable to set master password"), | ||
| 296 | GTK_STOCK_DISCARD, | ||
| 297 | GTK_STOCK_QUIT, | ||
| 298 | NULL) != G_ALERTDEFAULT) { | ||
| 299 | exit(1); | ||
| 300 | } | ||
| 301 | } | ||
| 302 | } | ||
| 303 | } | ||
| 304 | #endif | ||
| 278 | filter_set_addressbook_func(addressbook_has_address); | 305 | filter_set_addressbook_func(addressbook_has_address); |
| 279 | filter_read_config(); | 306 | filter_read_config(); |
| 280 | prefs_actions_read_config(); | 307 | prefs_actions_read_config(); |
| @@ -995,6 +1022,7 @@ void app_will_exit(gboolean force) | |||
| 995 | 1022 | ||
| 996 | /* remove temporary files, close log file, socket cleanup */ | 1023 | /* remove temporary files, close log file, socket cleanup */ |
| 997 | #if USE_SSL | 1024 | #if USE_SSL |
| 1025 | unload_master_password(); | ||
| 998 | ssl_done(); | 1026 | ssl_done(); |
| 999 | #endif | 1027 | #endif |
| 1000 | syl_cleanup(); | 1028 | syl_cleanup(); |
diff --git a/src/send_message.c b/src/send_message.c index 7b66423..d5fc6e8 100644 --- a/src/send_message.c +++ b/src/send_message.c | |||
| @@ -58,6 +58,7 @@ | |||
| 58 | #include "inc.h" | 58 | #include "inc.h" |
| 59 | #include "mainwindow.h" | 59 | #include "mainwindow.h" |
| 60 | #include "summaryview.h" | 60 | #include "summaryview.h" |
| 61 | #include "masterpassword.h" | ||
| 61 | 62 | ||
| 62 | #define SMTP_PORT 25 | 63 | #define SMTP_PORT 25 |
| 63 | #if USE_SSL | 64 | #if USE_SSL |
| @@ -648,24 +649,17 @@ static gint send_message_smtp(PrefsAccount *ac_prefs, GSList *to_list, FILE *fp) | |||
| 648 | 649 | ||
| 649 | if (ac_prefs->smtp_userid) { | 650 | if (ac_prefs->smtp_userid) { |
| 650 | smtp_session->user = g_strdup(ac_prefs->smtp_userid); | 651 | smtp_session->user = g_strdup(ac_prefs->smtp_userid); |
| 651 | if (ac_prefs->smtp_passwd) { | 652 | if (ac_prefs->smtp_passwd) |
| 652 | if(prefs_common.use_master_password && | 653 | if (master_password_active()) { |
| 653 | ac_prefs->master_password != NULL) { | 654 | smtp_session->pass = decrypt_with_master_password( |
| 654 | if (decrypt_data(&(smtp_session->pass), | 655 | ac_prefs->smtp_passwd); |
| 655 | ac_prefs->smtp_passwd, | ||
| 656 | ac_prefs->master_password, | ||
| 657 | strlen(ac_prefs->smtp_passwd) + 1) != RC_OK) { | ||
| 658 | session_destroy(session); | ||
| 659 | return -1; | ||
| 660 | } | ||
| 661 | } else { | 656 | } else { |
| 662 | smtp_session->pass = | 657 | smtp_session->pass = g_strdup(ac_prefs->smtp_passwd); |
| 663 | g_strdup(ac_prefs->smtp_passwd); | ||
| 664 | } | 658 | } |
| 665 | } else if (ac_prefs->tmp_smtp_pass) { | 659 | else if (ac_prefs->tmp_smtp_pass) |
| 666 | smtp_session->pass = | 660 | smtp_session->pass = |
| 667 | g_strdup(ac_prefs->tmp_smtp_pass); | 661 | g_strdup(ac_prefs->tmp_smtp_pass); |
| 668 | } else { | 662 | else { |
| 669 | smtp_session->pass = | 663 | smtp_session->pass = |
| 670 | input_query_password | 664 | input_query_password |
| 671 | (ac_prefs->smtp_server, | 665 | (ac_prefs->smtp_server, |
