diff options
Diffstat (limited to 'libsylph/account.c')
| -rw-r--r-- | libsylph/account.c | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/libsylph/account.c b/libsylph/account.c index 95d19fc..05d5871 100644 --- a/libsylph/account.c +++ b/libsylph/account.c | |||
| @@ -37,6 +37,8 @@ | |||
| 37 | #include "utils.h" | 37 | #include "utils.h" |
| 38 | #include "sylmain.h" | 38 | #include "sylmain.h" |
| 39 | #include "prefs_common.h" | 39 | #include "prefs_common.h" |
| 40 | #include "ssl.h" | ||
| 41 | |||
| 40 | 42 | ||
| 41 | PrefsAccount *cur_account; | 43 | PrefsAccount *cur_account; |
| 42 | 44 | ||
| @@ -53,9 +55,49 @@ void account_read_config_all(void) | |||
| 53 | gchar buf[PREFSBUFSIZE]; | 55 | gchar buf[PREFSBUFSIZE]; |
| 54 | PrefsAccount *ac_prefs; | 56 | PrefsAccount *ac_prefs; |
| 55 | #if USE_SSL | 57 | #if USE_SSL |
| 56 | gchar *master_password; | 58 | guint cnt; |
| 59 | gchar *master_password, *master_password_confirm; | ||
| 57 | if (prefs_common.use_master_password) { | 60 | if (prefs_common.use_master_password) { |
| 58 | master_password = input_query_password("Sylpheed", "Master password"); | 61 | if (prefs_common.master_password_hash != NULL) { |
| 62 | for (cnt = 0; cnt < 3; ++cnt) { | ||
| 63 | /* allow 3 attempts to enter the master password */ | ||
| 64 | master_password = input_query_password(_("Sylpheed"), | ||
| 65 | _("Master password")); | ||
| 66 | if (check_password( | ||
| 67 | master_password, | ||
| 68 | prefs_common.master_password_hash) == RC_OK) { | ||
| 69 | break; | ||
| 70 | } | ||
| 71 | debug_print(_("Wrong master password entered (%d)\n"), cnt); | ||
| 72 | g_free(master_password); | ||
| 73 | master_password = NULL; | ||
| 74 | } | ||
| 75 | /* TODO: Warning if password is NULL */ | ||
| 76 | } else { | ||
| 77 | /* No master password set (no master_password_hash) */ | ||
| 78 | for (cnt = 0; cnt < 3; ++cnt) { | ||
| 79 | master_password = input_query_password(_("Sylpheed"), | ||
| 80 | _("Master password")); | ||
| 81 | master_password_confirm = input_query_password( | ||
| 82 | _("Sylpheed"), | ||
| 83 | _("Master password confirmation")); | ||
| 84 | if (strcmp(master_password, master_password_confirm) == 0) { | ||
| 85 | /* The passwords match */ | ||
| 86 | g_free(master_password_confirm); | ||
| 87 | if (generate_password_hash( | ||
| 88 | &prefs_common.master_password_hash, | ||
| 89 | master_password, | ||
| 90 | NULL) != RC_OK) { | ||
| 91 | debug_print( | ||
| 92 | _("Could not generate master password hash")); | ||
| 93 | g_free(master_password); | ||
| 94 | continue; | ||
| 95 | } | ||
| 96 | prefs_common_write_config(); | ||
| 97 | break; | ||
| 98 | } | ||
| 99 | } | ||
| 100 | } | ||
| 59 | } else { | 101 | } else { |
| 60 | master_password = NULL; | 102 | master_password = NULL; |
| 61 | } | 103 | } |
