ports/mail/dbmail/files/patch-0014-Refactor-deprecared-functions
Muhammad Moinur Rahman 9eff14e488 mail/dbmail: adopt latest fixes from git:
- login_disabled option before starttls for pop3
- fix compiler warnings for GCC5
- Fix IMAP mailbox maintanence
- prevent assertion in p_string_erase
- improve crypt authentication, also don't segfault when spasswd is empty
- simplify log_query_time duration logic
- Disconnect IMAP clients if only few free FDs left
- Add primary key constraint to dbmail_authlog
- Rework temporary connection failures
- Give sensible default for retry 120s
- Add retries for binding and searching
- Bump search timeout to 60s
- Increase ldap timeout to 600s 10 mins
- Refactor deprecated functions
- Get timeout from config
- Remove redundant event_assign
- Remove deprecated non functioning g_mem_profile
- Add definition for authldap_free
- Revert inadvertent event_assign removal
- Reduce failed LDAP connection for search to error
- Update LDAP to non deprecated search
- Clear the ldap connection
- Update ldap deprecated unbind
- Fix typo
- Update to ldap_unbind_ext_s and remove redundant sigaction
- Rebalance commit rollback
- Ensure mailbox2dbmail is using Python 2
- Tidy mailbox2dbmail man page
- Update description of pid file location in server man page
- Boundaries fixups ordering of parts do not add newline on
- Prepend headers during delivery
- Allow for systems that don't use proc

PR:		210274
Submitted by:	fluffy
2017-02-24 21:15:52 +00:00

123 lines
3.4 KiB
Text

From 30e4904b6baf5c3f00d4b096f5b51cfbb69958d0 Mon Sep 17 00:00:00 2001
From: Alan Hicks <ahicks@p-o.co.uk>
Date: Wed, 12 Oct 2016 16:56:22 +0100
Subject: [PATCH 14/33] Refactor deprecared functions
---
src/modules/authldap.c | 44 ++++++++++++++++++++------------------------
1 file changed, 20 insertions(+), 24 deletions(-)
diff --git src/modules/authldap.c src/modules/authldap.c
index 3f43a56..bbe553b 100644
--- src/modules/authldap.c
+++ src/modules/authldap.c
@@ -28,7 +28,23 @@
extern char configFile[PATH_MAX];
-GStaticPrivate ldap_conn_key;
+/*
+ signal-safe releasing of thread-local ldap connection
+*/
+static void authldap_free(gpointer data)
+{
+ LDAP *c = (LDAP *)data;
+ struct sigaction act, oldact;
+
+ memset(&act, 0, sizeof(act));
+ memset(&oldact, 0, sizeof(oldact));
+ act.sa_handler = SIG_IGN;
+ sigaction(SIGPIPE, &act, &oldact);
+ ldap_unbind(c);
+ sigaction(SIGPIPE, &oldact, 0);
+}
+
+static GPrivate ldap_conn_key = G_PRIVATE_INIT (authldap_free);
static GOnce ldap_conn_once = G_ONCE_INIT;
static int authldap_connect(void);
@@ -105,7 +121,6 @@ static void __auth_get_config(void)
*/
static gpointer authldap_once(gpointer UNUSED data)
{
- g_static_private_init(&ldap_conn_key);
__auth_get_config();
return (gpointer)NULL;
}
@@ -120,7 +135,7 @@ static gpointer authldap_once(gpointer UNUSED data)
*/
static LDAP * ldap_con_get(void)
{
- LDAP * ld = (LDAP *)g_static_private_get(&ldap_conn_key);
+ LDAP * ld = (LDAP *)g_private_get(&ldap_conn_key);
if (ld) {
TRACE(TRACE_DEBUG, "connection [%p]", ld);
return ld;
@@ -136,7 +151,7 @@ static LDAP * ldap_con_get(void)
switch (err) {
case LDAP_SUCCESS:
- ld = (LDAP *)g_static_private_get(&ldap_conn_key);
+ ld = (LDAP *)g_private_get(&ldap_conn_key);
TRACE(TRACE_DEBUG, "connection [%p]", ld);
break;
case LDAP_SERVER_DOWN:
@@ -144,7 +159,6 @@ static LDAP * ldap_con_get(void)
sleep(1); // reconnect failed. wait before trying again
break;
default:
- // Includes timeouts etc. Should probably refactor.
TRACE(TRACE_ERR, "LDAP error(%d): %s", err, ldap_err2string(err));
sleep(1);
break;
@@ -158,22 +172,6 @@ static LDAP * ldap_con_get(void)
}
/*
- signal-safe releasing of thread-local ldap connection
-*/
-static void authldap_free(gpointer data)
-{
- LDAP *c = (LDAP *)data;
- struct sigaction act, oldact;
-
- memset(&act, 0, sizeof(act));
- memset(&oldact, 0, sizeof(oldact));
- act.sa_handler = SIG_IGN;
- sigaction(SIGPIPE, &act, &oldact);
- ldap_unbind(c);
- sigaction(SIGPIPE, &oldact, 0);
-}
-
-/*
* auth_ldap_bind()
*
* Bind to server using config credentials
@@ -247,7 +245,7 @@ static int authldap_connect(void)
if (strncasecmp(_ldap_cfg.referrals, "no", 2) == 0)
ldap_set_option(_ldap_conn, LDAP_OPT_REFERRALS, 0);
- g_static_private_set(&ldap_conn_key, _ldap_conn, (GDestroyNotify)authldap_free);
+ g_private_replace(&ldap_conn_key, _ldap_conn);
return auth_ldap_bind();
}
@@ -289,7 +287,6 @@ static LDAPMessage * authldap_search(const gchar *query)
TRACE(TRACE_WARNING, "LDAP gone away: %s. Trying again(%d/%d).", ldap_err2string(err), c, c_tries);
break;
default:
- // Includes timeouts etc. Should probably refactor.
TRACE(TRACE_ERR, "LDAP error(%d): %s. Trying again (%d/%d).", err, ldap_err2string(err), c, c_tries);
break;
}
@@ -634,7 +631,6 @@ int auth_connect(void)
}
int auth_disconnect(void)
{
- g_static_private_free(&ldap_conn_key);
return 0;
}
--
2.10.1 (Apple Git-78)