summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimeon Simeonov2018-03-07 09:33:26 +0100
committerSimeon Simeonov2018-03-07 09:33:26 +0100
commita949a98e583436533e19e392486c7eca0ac2bab6 (patch)
tree621a6306546cd93dd5c148bf7dab010f37707af8
parent50ad277f9a7cbc3d2dc5b6b9ab80a49b88ea3d80 (diff)
Make some master password hash cleanups
-rw-r--r--libsylph/account.c77
1 files changed, 40 insertions, 37 deletions
diff --git a/libsylph/account.c b/libsylph/account.c
index 05d5871..e4cb5cc 100644
--- a/libsylph/account.c
+++ b/libsylph/account.c
@@ -55,49 +55,52 @@ void account_read_config_all(void)
55 gchar buf[PREFSBUFSIZE]; 55 gchar buf[PREFSBUFSIZE];
56 PrefsAccount *ac_prefs; 56 PrefsAccount *ac_prefs;
57#if USE_SSL 57#if USE_SSL
58 guint cnt; 58 guint cnt;
59 gchar *master_password, *master_password_confirm; 59 gchar *master_password, *master_password_confirm;
60 if (prefs_common.use_master_password) { 60 if (prefs_common.use_master_password) {
61 if (prefs_common.master_password_hash != NULL) { 61 if (prefs_common.master_password_hash != NULL) {
62 for (cnt = 0; cnt < 3; ++cnt) { 62 for (cnt = 0; cnt < 3; ++cnt) {
63 /* allow 3 attempts to enter the master password */ 63 /* allow 3 attempts to enter the master password */
64 master_password = input_query_password(_("Sylpheed"), 64 master_password = input_query_password(_("Sylpheed"),
65 _("Master password")); 65 _("Master password"));
66 if (check_password( 66 if (check_password(
67 master_password, 67 master_password,
68 prefs_common.master_password_hash) == RC_OK) { 68 prefs_common.master_password_hash) == RC_OK) {
69 break; 69 break;
70 } 70 }
71 debug_print(_("Wrong master password entered (%d)\n"), cnt); 71 debug_print(_("Wrong master password entered (%d)\n"), cnt);
72 g_free(master_password); 72 g_free(master_password);
73 master_password = NULL; 73 master_password = NULL;
74 } 74 }
75 /* TODO: Warning if password is NULL */
76 } else { 75 } else {
77 /* No master password set (no master_password_hash) */ 76 /* No master password set (no master_password_hash) */
78 for (cnt = 0; cnt < 3; ++cnt) { 77 for (cnt = 0; cnt < 3; ++cnt) {
79 master_password = input_query_password(_("Sylpheed"), 78 master_password = input_query_password(_("Sylpheed"),
80 _("Master password")); 79 _("Master password"));
81 master_password_confirm = input_query_password( 80 master_password_confirm = input_query_password(
82 _("Sylpheed"), 81 _("Sylpheed"),
83 _("Master password confirmation")); 82 _("Master password confirmation"));
84 if (strcmp(master_password, master_password_confirm) == 0) { 83 if (strcmp(master_password, master_password_confirm) == 0) {
85 /* The passwords match */ 84 /* The passwords match */
86 g_free(master_password_confirm); 85 g_free(master_password_confirm);
87 if (generate_password_hash( 86 if (generate_password_hash(
88 &prefs_common.master_password_hash, 87 &prefs_common.master_password_hash,
89 master_password, 88 master_password,
90 NULL) != RC_OK) { 89 NULL) != RC_OK) {
91 debug_print( 90 debug_print(
92 _("Could not generate master password hash")); 91 _("Could not generate master password hash"));
93 g_free(master_password); 92 g_free(master_password);
94 continue; 93 continue;
95 } 94 }
96 prefs_common_write_config(); 95 prefs_common_write_config();
97 break; 96 break;
98 } 97 }
99 } 98 g_free(master_password);
99 g_free(master_password_confirm);
100 master_password = NULL;
101 }
100 } 102 }
103 /* TODO: Warning if password is NULL */
101 } else { 104 } else {
102 master_password = NULL; 105 master_password = NULL;
103 } 106 }