summaryrefslogtreecommitdiff
path: root/libsylph/account.c
diff options
context:
space:
mode:
authorSimeon Simeonov2018-03-08 15:01:45 +0100
committerSimeon Simeonov2018-03-08 15:01:45 +0100
commit57944f6147f077ccf4d84b9d2659f4e8645e8858 (patch)
treeb5a4f7af257058fb602d36590568ffd06681f6cd /libsylph/account.c
parent9bcc1f9650eb2d9dff7a78c632dcc14dfcfac9ee (diff)
Reastructure master password functionality
Diffstat (limited to 'libsylph/account.c')
-rw-r--r--libsylph/account.c49
1 files changed, 8 insertions, 41 deletions
diff --git a/libsylph/account.c b/libsylph/account.c
index e4cb5cc..7440434 100644
--- a/libsylph/account.c
+++ b/libsylph/account.c
@@ -37,7 +37,7 @@
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" 40#include "masterpassword.h"
41 41
42 42
43PrefsAccount *cur_account; 43PrefsAccount *cur_account;
@@ -55,50 +55,17 @@ 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;
59 gchar *master_password, *master_password_confirm;
60 if (prefs_common.use_master_password) { 58 if (prefs_common.use_master_password) {
61 if (prefs_common.master_password_hash != NULL) { 59 if (prefs_common.master_password_hash != NULL) {
62 for (cnt = 0; cnt < 3; ++cnt) { 60 /* allow 3 attempts to enter the master password */
63 /* allow 3 attempts to enter the master password */ 61 if (check_master_password_interactively(3) != 0) {
64 master_password = input_query_password(_("Sylpheed"), 62 /* master password does not match the hash */
65 _("Master password")); 63 g_free(master_password);
66 if (check_password( 64 master_password = NULL;
67 master_password, 65 }
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 } else { 66 } else {
76 /* No master password set (no master_password_hash) */ 67 /* No master password set (no master_password_hash) */
77 for (cnt = 0; cnt < 3; ++cnt) { 68 set_master_password_interactively(3);
78 master_password = input_query_password(_("Sylpheed"),
79 _("Master password"));
80 master_password_confirm = input_query_password(
81 _("Sylpheed"),
82 _("Master password confirmation"));
83 if (strcmp(master_password, master_password_confirm) == 0) {
84 /* The passwords match */
85 g_free(master_password_confirm);
86 if (generate_password_hash(
87 &prefs_common.master_password_hash,
88 master_password,
89 NULL) != RC_OK) {
90 debug_print(
91 _("Could not generate master password hash"));
92 g_free(master_password);
93 continue;
94 }
95 prefs_common_write_config();
96 break;
97 }
98 g_free(master_password);
99 g_free(master_password_confirm);
100 master_password = NULL;
101 }
102 } 69 }
103 /* TODO: Warning if password is NULL */ 70 /* TODO: Warning if password is NULL */
104 } else { 71 } else {