[Commits] [SCM] claws branch, master, updated. 3.13.2-18-gf181179

ticho at claws-mail.org ticho at claws-mail.org
Sun Feb 7 20:07:29 CET 2016


The branch, master has been updated
       via  f1811794160f215211d17ed164d8d25822545a23 (commit)
       via  fb564a461e8d8f343ed7e4eb1f8bcaa1cd1f48e3 (commit)
      from  b7477fbe534b8d1712b27a737d55b82c2a294b97 (commit)

Summary of changes:
 src/mainwindow.c |   21 ++++++++++++++++++++-
 src/mainwindow.h |    1 +
 src/password.c   |   28 +++++++++++++++++++++-------
 src/password.h   |    2 ++
 4 files changed, 44 insertions(+), 8 deletions(-)


- Log -----------------------------------------------------------------
commit f1811794160f215211d17ed164d8d25822545a23
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Sun Feb 7 20:07:03 2016 +0100

    Added "Forget master password" mainwindow menu entry.

diff --git a/src/mainwindow.c b/src/mainwindow.c
index 6f8c19b..07f9639 100644
--- a/src/mainwindow.c
+++ b/src/mainwindow.c
@@ -46,6 +46,7 @@
 #include "import.h"
 #include "export.h"
 #include "edittags.h"
+#include "password.h"
 #include "prefs_common.h"
 #include "prefs_actions.h"
 #include "prefs_filtering.h"
@@ -428,6 +429,8 @@ static void sync_cb		 ( GtkAction	*action,
 
 static void forget_session_passwords_cb	(GtkAction	*action,
 					 gpointer	 data );
+static void forget_master_password_cb	(GtkAction	*action,
+					 gpointer	 data );
 
 static gboolean mainwindow_focus_in_event	(GtkWidget	*widget, 
 						 GdkEventFocus	*focus,
@@ -776,6 +779,7 @@ static GtkActionEntry mainwin_entries[] =
 	{"Tools/NetworkLog",			NULL, N_("Network _Log"), "<shift><control>L", NULL, G_CALLBACK(log_window_show_cb) }, 
 	/* {"Tools/---",			NULL, "---", NULL, NULL, NULL }, */
 	{"Tools/ForgetSessionPasswords",		NULL, N_("_Forget all session passwords"), NULL, NULL, G_CALLBACK(forget_session_passwords_cb) }, 
+	{"Tools/ForgetMasterPassword",		NULL, N_("Forget _master password"), NULL, NULL, G_CALLBACK(forget_master_password_cb) },
 
 /* Configuration menu */	
 	{"Configuration/ChangeAccount",		NULL, N_("C_hange current account") },
@@ -1850,6 +1854,7 @@ MainWindow *main_window_create()
 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "NetworkLog", "Tools/NetworkLog", GTK_UI_MANAGER_MENUITEM)
 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "Separator8", "Tools/---", GTK_UI_MANAGER_SEPARATOR)
 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "ForgetSessionPasswords", "Tools/ForgetSessionPasswords", GTK_UI_MANAGER_MENUITEM)
+	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "ForgetMasterPassword", "Tools/ForgetMasterPassword", GTK_UI_MANAGER_MENUITEM)
 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "Separator9", "Tools/---", GTK_UI_MANAGER_SEPARATOR)
 
 /* Configuration menu */
@@ -3091,6 +3096,10 @@ SensitiveCondMask main_window_get_current_state(MainWindow *mainwin)
 			break;
 		}
 	}
+
+	if (master_password_is_entered()) {
+		UPDATE_STATE(M_MASTER_PASSWORD);
+	}
 #undef UPDATE_STATE
 
 	return state;
@@ -3131,7 +3140,7 @@ void main_window_set_menu_sensitive(MainWindow *mainwin)
 	gint i;
 	gboolean mimepart_selected = FALSE;
 
-#define N_ENTRIES 84
+#define N_ENTRIES 85
 	static struct {
 		const gchar *entry;
 		SensitiveCondMask cond;
@@ -3224,6 +3233,7 @@ do { \
 	FILL_TABLE("Menu/Tools/Execute", M_DELAY_EXEC);
 	FILL_TABLE("Menu/Tools/Expunge", M_DELETED_EXISTS);
 	FILL_TABLE("Menu/Tools/ForgetSessionPasswords", M_SESSION_PASSWORDS);
+	FILL_TABLE("Menu/Tools/ForgetMasterPassword", M_MASTER_PASSWORD);
 	FILL_TABLE("Menu/Tools/DeleteDuplicates/SelFolder", M_MSG_EXIST, M_ALLOW_DELETE);
 
 	FILL_TABLE("Menu/Configuration", M_UNLOCKED);
@@ -5320,6 +5330,15 @@ static void forget_session_passwords_cb(GtkAction *action, gpointer data)
 				   fgtn), fgtn, accs);	
 }
 
+static void forget_master_password_cb(GtkAction *action, gpointer data)
+{
+	MainWindow *mainwin = (MainWindow *)data;
+
+	main_window_lock(mainwin);
+	master_password_forget();
+	main_window_unlock(mainwin);
+}
+
 void mainwindow_learn (MainWindow *mainwin, gboolean is_spam)
 {
 	summary_mark_as_spam(mainwin->summaryview, is_spam, NULL);
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 6579f9e..6c924bf 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -64,6 +64,7 @@ typedef enum
 	M_HAVE_MULTI_ACCOUNT,
 	M_FOLDER_SELECTED,
 	M_SESSION_PASSWORDS,
+	M_MASTER_PASSWORD,
 	M_DELETED_EXISTS,
 	M_NOT_TRASH,
 	M_HIDE_READ_THREADS,
diff --git a/src/password.c b/src/password.c
index 69d8c01..dba5ef2 100644
--- a/src/password.c
+++ b/src/password.c
@@ -117,6 +117,11 @@ const gboolean master_password_is_correct(const gchar *input)
 	return FALSE;
 }
 
+gboolean master_password_is_entered()
+{
+	return (_master_password == NULL) ? FALSE : TRUE;
+}
+
 void master_password_forget()
 {
 	/* If master password is currently in memory (entered by user),
diff --git a/src/password.h b/src/password.h
index e0126ff..4123f5a 100644
--- a/src/password.h
+++ b/src/password.h
@@ -29,6 +29,7 @@
 #ifndef PASSWORD_CRYPTO_OLD
 const gboolean master_password_is_set();
 const gboolean master_password_is_correct(const gchar *input);
+gboolean master_password_is_entered();
 void master_password_forget();
 void master_password_change(const gchar *newp);
 #endif

commit fb564a461e8d8f343ed7e4eb1f8bcaa1cd1f48e3
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Sun Feb 7 19:51:20 2016 +0100

    Forget entered master password before trying to change it.
    
    This makes sure the user always has to input current master
    password before he is allowed to change it.

diff --git a/src/password.c b/src/password.c
index 180f6f4..69d8c01 100644
--- a/src/password.c
+++ b/src/password.c
@@ -117,6 +117,17 @@ const gboolean master_password_is_correct(const gchar *input)
 	return FALSE;
 }
 
+void master_password_forget()
+{
+	/* If master password is currently in memory (entered by user),
+	 * get rid of it. User will have to enter the new one again. */
+	if (_master_password != NULL) {
+		memset(_master_password, 0, strlen(_master_password));
+		g_free(_master_password);
+	}
+	_master_password = NULL;
+}
+
 void master_password_change(const gchar *newp)
 {
 	gchar *pwd, *newpwd;
@@ -124,6 +135,10 @@ void master_password_change(const gchar *newp)
 	GList *cur;
 	PrefsAccount *acc;
 
+	/* Make sure the user has to enter the master password before
+	 * being able to change it. */
+	master_password_forget();
+
 	oldp = master_password();
 	g_return_if_fail(oldp != NULL);
 
@@ -190,13 +205,7 @@ void master_password_change(const gchar *newp)
 		}
 	}
 
-	/* If master password is currently in memory (entered by user),
-	 * get rid of it. User will have to enter the new one again. */
-	if (_master_password != NULL) {
-		memset(_master_password, 0, strlen(_master_password));
-		g_free(_master_password);
-	}
-	_master_password = NULL;
+	master_password_forget();
 }
 #endif
 
diff --git a/src/password.h b/src/password.h
index df18e34..e0126ff 100644
--- a/src/password.h
+++ b/src/password.h
@@ -29,6 +29,7 @@
 #ifndef PASSWORD_CRYPTO_OLD
 const gboolean master_password_is_set();
 const gboolean master_password_is_correct(const gchar *input);
+void master_password_forget();
 void master_password_change(const gchar *newp);
 #endif
 

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list