diff options
| author | Simeon Simeonov | 2018-03-08 15:01:45 +0100 |
|---|---|---|
| committer | Simeon Simeonov | 2018-03-08 15:01:45 +0100 |
| commit | 57944f6147f077ccf4d84b9d2659f4e8645e8858 (patch) | |
| tree | b5a4f7af257058fb602d36590568ffd06681f6cd | |
| parent | 9bcc1f9650eb2d9dff7a78c632dcc14dfcfac9ee (diff) | |
Reastructure master password functionality
| -rwxr-xr-x | configure | 2 | ||||
| -rw-r--r-- | configure.ac | 2 | ||||
| -rw-r--r-- | libsylph/Makefile.am | 2 | ||||
| -rw-r--r-- | libsylph/Makefile.in | 7 | ||||
| -rw-r--r-- | libsylph/account.c | 49 | ||||
| -rw-r--r-- | libsylph/masterpassword.c | 100 | ||||
| -rw-r--r-- | libsylph/masterpassword.h | 38 | ||||
| -rw-r--r-- | libsylph/utils.c | 30 | ||||
| -rw-r--r-- | libsylph/utils.h | 7 | ||||
| -rw-r--r-- | src/inputdialog.c | 38 | ||||
| -rw-r--r-- | src/inputdialog.h | 3 | ||||
| -rw-r--r-- | src/main.c | 2 |
12 files changed, 233 insertions, 47 deletions
| @@ -2581,7 +2581,7 @@ MINOR_VERSION=7 | |||
| 2581 | MICRO_VERSION=0 | 2581 | MICRO_VERSION=0 |
| 2582 | INTERFACE_AGE=0 | 2582 | INTERFACE_AGE=0 |
| 2583 | BINARY_AGE=0 | 2583 | BINARY_AGE=0 |
| 2584 | EXTRA_VERSION=-sgs | 2584 | EXTRA_VERSION= |
| 2585 | BUILD_REVISION=1185 | 2585 | BUILD_REVISION=1185 |
| 2586 | VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION | 2586 | VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION |
| 2587 | 2587 | ||
diff --git a/configure.ac b/configure.ac index ae65343..090177d 100644 --- a/configure.ac +++ b/configure.ac | |||
| @@ -9,7 +9,7 @@ MINOR_VERSION=7 | |||
| 9 | MICRO_VERSION=0 | 9 | MICRO_VERSION=0 |
| 10 | INTERFACE_AGE=0 | 10 | INTERFACE_AGE=0 |
| 11 | BINARY_AGE=0 | 11 | BINARY_AGE=0 |
| 12 | EXTRA_VERSION=-sgs | 12 | EXTRA_VERSION= |
| 13 | BUILD_REVISION=1185 | 13 | BUILD_REVISION=1185 |
| 14 | VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION | 14 | VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION |
| 15 | 15 | ||
diff --git a/libsylph/Makefile.am b/libsylph/Makefile.am index 8f2b76b..40d26a9 100644 --- a/libsylph/Makefile.am +++ b/libsylph/Makefile.am | |||
| @@ -19,6 +19,7 @@ libsylph_0_la_SOURCES = \ | |||
| 19 | folder.c \ | 19 | folder.c \ |
| 20 | html.c \ | 20 | html.c \ |
| 21 | imap.c \ | 21 | imap.c \ |
| 22 | masterpassword.c \ | ||
| 22 | mbox.c \ | 23 | mbox.c \ |
| 23 | md5.c \ | 24 | md5.c \ |
| 24 | md5_hmac.c \ | 25 | md5_hmac.c \ |
| @@ -62,6 +63,7 @@ libsylph_0include_HEADERS = \ | |||
| 62 | folder.h \ | 63 | folder.h \ |
| 63 | html.h \ | 64 | html.h \ |
| 64 | imap.h \ | 65 | imap.h \ |
| 66 | masterpassword.h \ | ||
| 65 | mbox.h \ | 67 | mbox.h \ |
| 66 | md5.h \ | 68 | md5.h \ |
| 67 | md5_hmac.h \ | 69 | md5_hmac.h \ |
diff --git a/libsylph/Makefile.in b/libsylph/Makefile.in index 6e3c999..ac8fefd 100644 --- a/libsylph/Makefile.in +++ b/libsylph/Makefile.in | |||
| @@ -129,8 +129,8 @@ libsylph_0_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \ | |||
| 129 | $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) | 129 | $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) |
| 130 | am_libsylph_0_la_OBJECTS = account.lo base64.lo codeconv.lo \ | 130 | am_libsylph_0_la_OBJECTS = account.lo base64.lo codeconv.lo \ |
| 131 | customheader.lo displayheader.lo filter.lo folder.lo html.lo \ | 131 | customheader.lo displayheader.lo filter.lo folder.lo html.lo \ |
| 132 | imap.lo mbox.lo md5.lo md5_hmac.lo mh.lo news.lo nntp.lo \ | 132 | imap.lo masterpassword.lo mbox.lo md5.lo md5_hmac.lo mh.lo news.lo \ |
| 133 | pop.lo prefs.lo prefs_account.lo prefs_common.lo procheader.lo \ | 133 | nntp.lo pop.lo prefs.lo prefs_account.lo prefs_common.lo procheader.lo \ |
| 134 | procmime.lo procmsg.lo quoted-printable.lo recv.lo session.lo \ | 134 | procmime.lo procmsg.lo quoted-printable.lo recv.lo session.lo \ |
| 135 | smtp.lo socket.lo socks.lo ssl.lo ssl_hostname_validation.lo \ | 135 | smtp.lo socket.lo socks.lo ssl.lo ssl_hostname_validation.lo \ |
| 136 | stringtable.lo sylmain.lo unmime.lo utils.lo uuencode.lo \ | 136 | stringtable.lo sylmain.lo unmime.lo utils.lo uuencode.lo \ |
| @@ -402,6 +402,7 @@ libsylph_0_la_SOURCES = \ | |||
| 402 | folder.c \ | 402 | folder.c \ |
| 403 | html.c \ | 403 | html.c \ |
| 404 | imap.c \ | 404 | imap.c \ |
| 405 | masterpassword.c \ | ||
| 405 | mbox.c \ | 406 | mbox.c \ |
| 406 | md5.c \ | 407 | md5.c \ |
| 407 | md5_hmac.c \ | 408 | md5_hmac.c \ |
| @@ -445,6 +446,7 @@ libsylph_0include_HEADERS = \ | |||
| 445 | folder.h \ | 446 | folder.h \ |
| 446 | html.h \ | 447 | html.h \ |
| 447 | imap.h \ | 448 | imap.h \ |
| 449 | masterpassword.h \ | ||
| 448 | mbox.h \ | 450 | mbox.h \ |
| 449 | md5.h \ | 451 | md5.h \ |
| 450 | md5_hmac.h \ | 452 | md5_hmac.h \ |
| @@ -579,6 +581,7 @@ distclean-compile: | |||
| 579 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/folder.Plo@am__quote@ | 581 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/folder.Plo@am__quote@ |
| 580 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/html.Plo@am__quote@ | 582 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/html.Plo@am__quote@ |
| 581 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/imap.Plo@am__quote@ | 583 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/imap.Plo@am__quote@ |
| 584 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/masterpassword.Plo@am__quote@ | ||
| 582 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mbox.Plo@am__quote@ | 585 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mbox.Plo@am__quote@ |
| 583 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/md5.Plo@am__quote@ | 586 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/md5.Plo@am__quote@ |
| 584 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/md5_hmac.Plo@am__quote@ | 587 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/md5_hmac.Plo@am__quote@ |
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 | ||
| 43 | PrefsAccount *cur_account; | 43 | PrefsAccount *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 { |
diff --git a/libsylph/masterpassword.c b/libsylph/masterpassword.c new file mode 100644 index 0000000..ee443aa --- /dev/null +++ b/libsylph/masterpassword.c | |||
| @@ -0,0 +1,100 @@ | |||
| 1 | /* | ||
| 2 | * LibSylph -- E-Mail client library | ||
| 3 | * Copyright (C) 1999-2018 Hiroyuki Yamamoto | ||
| 4 | * | ||
| 5 | * This library is free software; you can redistribute it and/or | ||
| 6 | * modify it under the terms of the GNU Lesser General Public | ||
| 7 | * License as published by the Free Software Foundation; either | ||
| 8 | * version 2.1 of the License, or (at your option) any later version. | ||
| 9 | * | ||
| 10 | * This library is distributed in the hope that it will be useful, | ||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 13 | * Lesser General Public License for more details. | ||
| 14 | * | ||
| 15 | * You should have received a copy of the GNU Lesser General Public | ||
| 16 | * License along with this library; if not, write to the Free Software | ||
| 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 18 | */ | ||
| 19 | |||
| 20 | #ifdef HAVE_CONFIG_H | ||
| 21 | #include "config.h" | ||
| 22 | #endif | ||
| 23 | |||
| 24 | #include "prefs_common.h" | ||
| 25 | #include "ssl.h" | ||
| 26 | #include "utils.h" | ||
| 27 | |||
| 28 | |||
| 29 | gchar *master_password; | ||
| 30 | |||
| 31 | void set_master_password(const char *password) { | ||
| 32 | master_password = password; | ||
| 33 | } | ||
| 34 | |||
| 35 | gchar *get_master_password(void) { | ||
| 36 | return master_password; | ||
| 37 | } | ||
| 38 | |||
| 39 | #if USE_SSL | ||
| 40 | |||
| 41 | gint set_master_password_interactively(guint max_attempts) { | ||
| 42 | |||
| 43 | if (master_password != NULL) | ||
| 44 | return 0; /* master_password already set */ | ||
| 45 | |||
| 46 | master_password = input_set_new_password(max_attempts); | ||
| 47 | |||
| 48 | if (master_password == NULL) | ||
| 49 | return 1; | ||
| 50 | |||
| 51 | if (generate_password_hash( | ||
| 52 | &prefs_common.master_password_hash, | ||
| 53 | master_password, | ||
| 54 | NULL) != RC_OK) { | ||
| 55 | /* should not really happen unless buggy code / library */ | ||
| 56 | g_free(prefs_common.master_password_hash); | ||
| 57 | prefs_common.master_password_hash = NULL; | ||
| 58 | debug_print(_("Could not generate master password hash")); | ||
| 59 | return 1; | ||
| 60 | } | ||
| 61 | |||
| 62 | prefs_common_write_config(); | ||
| 63 | return 0; | ||
| 64 | |||
| 65 | } | ||
| 66 | |||
| 67 | gint check_master_password_interactively(guint max_attempts) { | ||
| 68 | |||
| 69 | guint cnt; | ||
| 70 | |||
| 71 | if (max_attempts < 1) | ||
| 72 | return 1; | ||
| 73 | |||
| 74 | if (prefs_common.master_password_hash != NULL) { | ||
| 75 | return 1; | ||
| 76 | } | ||
| 77 | |||
| 78 | if (master_password != NULL) { | ||
| 79 | /* password already cached */ | ||
| 80 | return check_password(master_password, | ||
| 81 | prefs_common.master_password_hash); | ||
| 82 | } | ||
| 83 | |||
| 84 | for (cnt = 0; cnt < max_attempts; ++cnt) { | ||
| 85 | master_password = input_query_master_password(); | ||
| 86 | if (check_password(master_password, | ||
| 87 | prefs_common.master_password_hash) == RC_OK) { | ||
| 88 | return RC_OK; /* match */ | ||
| 89 | } | ||
| 90 | debug_print(_("Wrong master password entered (%d)\n"), cnt); | ||
| 91 | /* TODO: clear before free? */ | ||
| 92 | g_free(master_password); | ||
| 93 | master_password = NULL; | ||
| 94 | } | ||
| 95 | |||
| 96 | return 1; /* no match */ | ||
| 97 | |||
| 98 | } | ||
| 99 | |||
| 100 | #endif /* USE_SSL */ | ||
diff --git a/libsylph/masterpassword.h b/libsylph/masterpassword.h new file mode 100644 index 0000000..b2798ce --- /dev/null +++ b/libsylph/masterpassword.h | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | /* | ||
| 2 | * LibSylph -- E-Mail client library | ||
| 3 | * Copyright (C) 1999-2006 Hiroyuki Yamamoto | ||
| 4 | * | ||
| 5 | * This library is free software; you can redistribute it and/or | ||
| 6 | * modify it under the terms of the GNU Lesser General Public | ||
| 7 | * License as published by the Free Software Foundation; either | ||
| 8 | * version 2.1 of the License, or (at your option) any later version. | ||
| 9 | * | ||
| 10 | * This library is distributed in the hope that it will be useful, | ||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 13 | * Lesser General Public License for more details. | ||
| 14 | * | ||
| 15 | * You should have received a copy of the GNU Lesser General Public | ||
| 16 | * License along with this library; if not, write to the Free Software | ||
| 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 18 | */ | ||
| 19 | |||
| 20 | #ifndef __MASTERPASSWORD_H__ | ||
| 21 | #define __MASTERPASSWORD_H__ | ||
| 22 | |||
| 23 | #ifdef HAVE_CONFIG_H | ||
| 24 | #include "config.h" | ||
| 25 | #endif | ||
| 26 | |||
| 27 | extern gchar *master_password; | ||
| 28 | void set_master_password(const char *password); | ||
| 29 | gchar *get_master_password(void); | ||
| 30 | |||
| 31 | #if USE_SSL | ||
| 32 | |||
| 33 | gint set_master_password_interactively(guint max_attempts); | ||
| 34 | gint check_master_password_interactively(guint max_attempts); | ||
| 35 | |||
| 36 | #endif /* USE_SSL */ | ||
| 37 | |||
| 38 | #endif /* __MASTERPASSWORD_H__ */ | ||
diff --git a/libsylph/utils.c b/libsylph/utils.c index 6ecf328..3bbcbcf 100644 --- a/libsylph/utils.c +++ b/libsylph/utils.c | |||
| @@ -4598,6 +4598,36 @@ gchar *input_query_password(const gchar *server, const gchar *user) | |||
| 4598 | return NULL; | 4598 | return NULL; |
| 4599 | } | 4599 | } |
| 4600 | 4600 | ||
| 4601 | static QueryMasterPasswordFunc query_master_password_func = NULL; | ||
| 4602 | |||
| 4603 | void set_input_query_master_password_func(QueryMasterPasswordFunc func) | ||
| 4604 | { | ||
| 4605 | query_master_password_func = func; | ||
| 4606 | } | ||
| 4607 | |||
| 4608 | gchar *input_query_master_password(void) | ||
| 4609 | { | ||
| 4610 | if (query_master_password_func) | ||
| 4611 | return query_master_password_func(); | ||
| 4612 | else | ||
| 4613 | return NULL; | ||
| 4614 | } | ||
| 4615 | |||
| 4616 | static SetNewPasswordFunc set_new_password_func = NULL; | ||
| 4617 | |||
| 4618 | void set_input_set_new_password_func(SetNewPasswordFunc func) | ||
| 4619 | { | ||
| 4620 | set_new_password_func = func; | ||
| 4621 | } | ||
| 4622 | |||
| 4623 | gchar *input_set_new_password(guint max_attempts) | ||
| 4624 | { | ||
| 4625 | if (set_new_password_func) | ||
| 4626 | return set_new_password_func(max_attempts); | ||
| 4627 | else | ||
| 4628 | return NULL; | ||
| 4629 | } | ||
| 4630 | |||
| 4601 | /* logging */ | 4631 | /* logging */ |
| 4602 | 4632 | ||
| 4603 | static FILE *log_fp = NULL; | 4633 | static FILE *log_fp = NULL; |
diff --git a/libsylph/utils.h b/libsylph/utils.h index 9ac65cf..ede55ff 100644 --- a/libsylph/utils.h +++ b/libsylph/utils.h | |||
| @@ -202,6 +202,8 @@ typedef void (*ProgressFunc) (gint cur, | |||
| 202 | gint total); | 202 | gint total); |
| 203 | typedef gchar * (*QueryPasswordFunc) (const gchar *server, | 203 | typedef gchar * (*QueryPasswordFunc) (const gchar *server, |
| 204 | const gchar *user); | 204 | const gchar *user); |
| 205 | typedef gchar * (*QueryMasterPasswordFunc) (void); | ||
| 206 | typedef gchar * (*SetNewPasswordFunc) (guint max_attempts); | ||
| 205 | typedef void (*LogFunc) (const gchar *str); | 207 | typedef void (*LogFunc) (const gchar *str); |
| 206 | typedef void (*LogFlushFunc) (void); | 208 | typedef void (*LogFlushFunc) (void); |
| 207 | 209 | ||
| @@ -560,9 +562,12 @@ void progress_show (gint cur, | |||
| 560 | 562 | ||
| 561 | /* user input */ | 563 | /* user input */ |
| 562 | void set_input_query_password_func (QueryPasswordFunc func); | 564 | void set_input_query_password_func (QueryPasswordFunc func); |
| 563 | |||
| 564 | gchar *input_query_password (const gchar *server, | 565 | gchar *input_query_password (const gchar *server, |
| 565 | const gchar *user); | 566 | const gchar *user); |
| 567 | void set_input_query_master_password_func(QueryMasterPasswordFunc func); | ||
| 568 | gchar *input_query_master_password(void); | ||
| 569 | void set_input_set_new_password_func(SetNewPasswordFunc func); | ||
| 570 | gchar *input_set_new_password(guint max_attempts); | ||
| 566 | 571 | ||
| 567 | /* logging */ | 572 | /* logging */ |
| 568 | void set_log_file (const gchar *filename); | 573 | void set_log_file (const gchar *filename); |
diff --git a/src/inputdialog.c b/src/inputdialog.c index a601085..d17b852 100644 --- a/src/inputdialog.c +++ b/src/inputdialog.c | |||
| @@ -156,6 +156,44 @@ gchar *input_dialog_query_password(const gchar *server, const gchar *user) | |||
| 156 | return pass; | 156 | return pass; |
| 157 | } | 157 | } |
| 158 | 158 | ||
| 159 | gchar *input_dialog_query_master_password(void) | ||
| 160 | { | ||
| 161 | return input_dialog_with_invisible(_("Input password"), | ||
| 162 | _("Master password"), | ||
| 163 | NULL); | ||
| 164 | } | ||
| 165 | |||
| 166 | gchar *input_dialog_set_new_password(guint max_attempts) | ||
| 167 | { | ||
| 168 | guint cnt; | ||
| 169 | gchar *pass1, *pass2; | ||
| 170 | |||
| 171 | if (max_attempts < 1) | ||
| 172 | return NULL; | ||
| 173 | |||
| 174 | for (cnt = 0; cnt < max_attempts; ++cnt) { | ||
| 175 | pass1 = input_dialog_with_invisible( | ||
| 176 | _("Input password"), | ||
| 177 | _("New password"), | ||
| 178 | NULL); | ||
| 179 | pass2 = input_dialog_with_invisible( | ||
| 180 | _("Input password"), | ||
| 181 | _("Confirm new password"), | ||
| 182 | NULL); | ||
| 183 | if (strcmp(pass1, pass2) == 0) { | ||
| 184 | /* TODO: clear before free? */ | ||
| 185 | g_free(pass2); | ||
| 186 | break; | ||
| 187 | } | ||
| 188 | /* TODO: clear before free? */ | ||
| 189 | g_free(pass2); | ||
| 190 | g_free(pass1); | ||
| 191 | pass1 = NULL; | ||
| 192 | } | ||
| 193 | |||
| 194 | return pass1; | ||
| 195 | } | ||
| 196 | |||
| 159 | gchar *input_dialog_with_filesel(const gchar *title, const gchar *message, | 197 | gchar *input_dialog_with_filesel(const gchar *title, const gchar *message, |
| 160 | const gchar *default_string, | 198 | const gchar *default_string, |
| 161 | GtkFileChooserAction action) | 199 | GtkFileChooserAction action) |
diff --git a/src/inputdialog.h b/src/inputdialog.h index 02bdda3..5364d1a 100644 --- a/src/inputdialog.h +++ b/src/inputdialog.h | |||
| @@ -36,7 +36,8 @@ gchar *input_dialog_combo (const gchar *title, | |||
| 36 | gboolean case_sensitive); | 36 | gboolean case_sensitive); |
| 37 | gchar *input_dialog_query_password (const gchar *server, | 37 | gchar *input_dialog_query_password (const gchar *server, |
| 38 | const gchar *user); | 38 | const gchar *user); |
| 39 | 39 | gchar *input_dialog_query_master_password(void); | |
| 40 | gchar *input_dialog_set_new_password(guint max_attempts); | ||
| 40 | gchar *input_dialog_with_filesel (const gchar *title, | 41 | gchar *input_dialog_with_filesel (const gchar *title, |
| 41 | const gchar *message, | 42 | const gchar *message, |
| 42 | const gchar *default_string, | 43 | const gchar *default_string, |
| @@ -265,9 +265,11 @@ int main(int argc, char *argv[]) | |||
| 265 | set_ui_update_func(gtkut_events_flush); | 265 | set_ui_update_func(gtkut_events_flush); |
| 266 | set_progress_func(main_window_progress_show); | 266 | set_progress_func(main_window_progress_show); |
| 267 | set_input_query_password_func(input_dialog_query_password); | 267 | set_input_query_password_func(input_dialog_query_password); |
| 268 | set_input_set_new_password_func(input_dialog_set_new_password); | ||
| 268 | #if USE_SSL | 269 | #if USE_SSL |
| 269 | ssl_init(); | 270 | ssl_init(); |
| 270 | ssl_set_verify_func(ssl_manager_verify_cert); | 271 | ssl_set_verify_func(ssl_manager_verify_cert); |
| 272 | set_input_query_master_password_func(input_dialog_query_master_password); | ||
| 271 | #endif | 273 | #endif |
| 272 | 274 | ||
| 273 | CHDIR_EXIT_IF_FAIL(get_home_dir(), 1); | 275 | CHDIR_EXIT_IF_FAIL(get_home_dir(), 1); |
