[Commits] [SCM] claws branch, master, updated. 3.15.0-194-ge0f4140

mones at claws-mail.org mones at claws-mail.org
Sun Dec 10 18:13:54 CET 2017


The branch, master has been updated
       via  e0f41407ce397eed880ba0360d9b5725f9176ed8 (commit)
       via  48f72c22f91fbe0d6e872e89bd4dce9d39090e81 (commit)
       via  d954a01de48f90a726e79995f4daeed3e9fee11b (commit)
      from  e5e9653deef1b688faf866b64d25e817f45b6666 (commit)

Summary of changes:
 src/addressbook.c |   20 ++++++++++++++++++++
 src/addrindex.c   |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 src/addrindex.h   |    5 +++++
 src/compose.c     |   35 ++++++++++++++++++++++++++++++++++-
 src/compose.h     |    6 ++++++
 src/password.c    |    2 +-
 src/password.h    |    4 ++++
 7 files changed, 116 insertions(+), 2 deletions(-)


- Log -----------------------------------------------------------------
commit e0f41407ce397eed880ba0360d9b5725f9176ed8
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Sun Dec 10 10:49:02 2017 +0100

    Fix bug 3931: segfault searching server with master password
    
    Request master passphrase earlier and inhibit search if no master
    passphrase is available.

diff --git a/src/addressbook.c b/src/addressbook.c
index 5b76120..fef1ee1 100644
--- a/src/addressbook.c
+++ b/src/addressbook.c
@@ -49,6 +49,7 @@
 #include "codeconv.h"
 #include "about.h"
 #include "addr_compl.h"
+#include "password.h"
 
 #include "mgutils.h"
 #include "addressitem.h"
@@ -4695,6 +4696,10 @@ static void addressbook_lup_clicked( GtkButton *button, gpointer data ) {
 	AddressInterface *iface;
 	gchar *searchTerm;
 	GtkCMCTreeNode *node, *parentNode;
+#ifdef USE_LDAP
+	LdapServer *ldap_server;
+	LdapControl *ldap_ctl;
+#endif
 
 	node = addrbook.treeSelected;
 	if( ! node ) return;
@@ -4720,6 +4725,21 @@ static void addressbook_lup_clicked( GtkButton *button, gpointer data ) {
 	if( ! iface->haveLibrary ) return;
 	if( ! iface->externalQuery ) return;
 
+#ifdef USE_LDAP
+	if (iface->type == ADDR_IF_LDAP) {
+		ldap_server = ds->rawDataSource;
+		ldap_ctl = ldap_server->control;
+		if (ldap_ctl != NULL &&
+				ldap_ctl->bindDN != NULL && strlen(ldap_ctl->bindDN) > 0) {
+			/* LDAP server is password-protected. */
+			if (master_passphrase() == NULL) {
+				/* User did not enter master passphrase, do not start a search. */
+				return;
+			}
+		}
+	}
+#endif
+
 	searchTerm =
 		gtk_editable_get_chars( GTK_EDITABLE(addrbook.entry), 0, -1 );
 	g_strchomp( searchTerm );

commit 48f72c22f91fbe0d6e872e89bd4dce9d39090e81
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Sun Dec 10 10:49:01 2017 +0100

    Fix bug 3793: segfault when autocompletion asks for master passphrase
    
    This is done by checking early if any ldap server is password-protected,
    and asking for master passphrase when compose window appears.  If user
    cancels the dialog (does not enter the passphrase), we temporarily
    disable the password-protected LDAP servers, just for that particular
    compose window. We reenable them in compose_destroy().

diff --git a/src/addrindex.c b/src/addrindex.c
index d11e210..282281f 100644
--- a/src/addrindex.c
+++ b/src/addrindex.c
@@ -3200,6 +3200,52 @@ gchar *addrindex_get_picture_file(const gchar *emailaddr)
 	return filename;
 }
 
+#ifdef USE_LDAP
+GSList *addrindex_get_password_protected_ldap_servers()
+{
+	AddressInterface *iface;
+	AddressDataSource *ds;
+	GList *nodeIf;
+	GList *nodeDS;
+	GSList *list = NULL;
+	LdapServer *server;
+	LdapControl *ctl;
+
+	nodeIf = _addressIndex_->searchOrder;
+	while (nodeIf) {
+		iface = nodeIf->data;
+		nodeIf = g_list_next(nodeIf);
+
+		if (!iface->useInterface)
+			continue;
+		if (!iface->externalQuery)
+			continue;
+		if (iface->type != ADDR_IF_LDAP)
+			continue;
+
+		nodeDS = iface->listSource;
+		while (nodeDS) {
+			ds = nodeDS->data;
+			nodeDS = g_list_next(nodeDS);
+			server = ds->rawDataSource;
+			if (!server->searchFlag)
+				continue;
+
+			ctl = server->control;
+
+			if (!ctl)
+				continue;
+
+			if (ctl->bindDN != NULL && strlen(ctl->bindDN)) {
+				list = g_slist_append(list, server);
+			}
+		}
+	}
+
+	return list;
+}
+#endif /* USE_LDAP */
+
 /*
  * End of Source.
  */
diff --git a/src/addrindex.h b/src/addrindex.h
index b5b9e9a..2db902a 100644
--- a/src/addrindex.h
+++ b/src/addrindex.h
@@ -180,6 +180,11 @@ gboolean addrindex_load_person_attribute( const gchar *attr,
 gboolean addrindex_load_person_ds( gint (*callBackFunc)
 			( ItemPerson *, AddressDataSource * ) );
 gchar *addrindex_get_picture_file(const gchar *emailaddr);		
+
+#ifdef USE_LDAP
+GSList *addrindex_get_password_protected_ldap_servers();
+#endif
+
 #endif /* __ADDRINDEX_H__ */
 
 /*
diff --git a/src/compose.c b/src/compose.c
index e60d178..e52f467 100644
--- a/src/compose.c
+++ b/src/compose.c
@@ -107,6 +107,10 @@
 #include "autofaces.h"
 #include "spell_entry.h"
 #include "headers.h"
+#ifdef USE_LDAP
+#include "password.h"
+#include "ldapserver.h"
+#endif
 
 enum
 {
@@ -7091,6 +7095,15 @@ extra_headers_done:
 	g_slist_foreach(extra_headers, (GFunc)compose_add_extra_header, (gpointer)model);
 }
 
+static void _ldap_srv_func(gpointer data, gpointer user_data)
+{
+	LdapServer *server = (LdapServer *)data;
+	gboolean *enable = (gboolean *)user_data;
+
+	debug_print("%s server '%s'\n", (*enable == TRUE ? "enabling" : "disabling"), server->control->hostName);
+	server->searchFlag = *enable;
+}
+
 static void compose_create_header_entry(Compose *compose) 
 {
 	gchar *headers[] = {"To:", "Cc:", "Bcc:", "Newsgroups:", "Reply-To:", "Followup-To:", NULL};
@@ -7229,7 +7242,22 @@ static void compose_create_header_entry(Compose *compose)
 	g_signal_connect(G_OBJECT(entry), "populate-popup",
 			 G_CALLBACK(compose_entry_popup_extend),
 			 NULL);
-	
+
+#ifdef USE_LDAP
+	GSList *pwd_servers = addrindex_get_password_protected_ldap_servers();
+	if (pwd_servers != NULL && master_passphrase() == NULL) {
+		gboolean enable = FALSE;
+		debug_print("Master passphrase not available, disabling password-protected LDAP servers for this compose window.\n");
+		/* Temporarily disable password-protected LDAP servers,
+		 * because user did not provide a master passphrase.
+		 * We can safely enable searchFlag on all servers in this list
+		 * later, since addrindex_get_password_protected_ldap_servers()
+		 * includes servers which have it enabled initially. */
+		g_slist_foreach(pwd_servers, _ldap_srv_func, &enable);
+		compose->passworded_ldap_servers = pwd_servers;
+	}
+#endif
+
 	address_completion_register_entry(GTK_ENTRY(entry), TRUE);
 
         headerentry->compose = compose;
@@ -9070,6 +9098,11 @@ static void compose_destroy(Compose *compose)
 
 	compose_list = g_list_remove(compose_list, compose);
 
+	gboolean enable = TRUE;
+	g_slist_foreach(compose->passworded_ldap_servers,
+			_ldap_srv_func, &enable);
+	g_slist_free(compose->passworded_ldap_servers);
+
 	if (compose->updating) {
 		debug_print("danger, not destroying anything now\n");
 		compose->deferred_destroy = TRUE;
diff --git a/src/compose.h b/src/compose.h
index 5fe65a3..fee1956 100644
--- a/src/compose.h
+++ b/src/compose.h
@@ -252,6 +252,12 @@ struct _Compose
         GtkAspell *gtkaspell;
 	GtkWidget *aspell_options_menu;
 #endif
+
+#ifdef USE_LDAP
+	/* List of addressbook ifaces which we disabled, and will
+	 * enable in compose_destroy. */
+	GSList *passworded_ldap_servers;
+#endif
 };
 
 struct _AttachInfo

commit d954a01de48f90a726e79995f4daeed3e9fee11b
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Sun Dec 10 10:49:00 2017 +0100

    Add public call to get master password

diff --git a/src/password.c b/src/password.c
index f19560f..8c17aaf 100644
--- a/src/password.c
+++ b/src/password.c
@@ -110,7 +110,7 @@ static guchar *_make_key_deriv(const gchar *passphrase, guint rounds,
 	return NULL;
 }
 
-static const gchar *master_passphrase()
+const gchar *master_passphrase()
 {
 	gchar *input;
 	gboolean end = FALSE;
diff --git a/src/password.h b/src/password.h
index 7890d74..4480a5e 100644
--- a/src/password.h
+++ b/src/password.h
@@ -27,6 +27,10 @@
 #include <glib.h>
 
 #ifndef PASSWORD_CRYPTO_OLD
+/* Returns a pointer to master passphrase, asking the user
+ * if necessary. Do not free the return value. */
+const gchar *master_passphrase();
+
 /* Returns TRUE if there is a master passphrase set in preferences. */
 gboolean master_passphrase_is_set();
 /* Returns TRUE if input contains correct master passphrase, as set

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


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list