rpms/autofs/F-10 autofs-5.0.3-fix-memory-leak-reading-ldap-master.patch, NONE, 1.1 autofs-5.0.3-renew-sasl-creds-upon-reconnect-fail.patch, NONE, 1.1 autofs-5.0.3-uris-list-locking-final.patch, NONE, 1.1 autofs-5.0.4-add-lsb-init-script-parameter-block.patch, NONE, 1.1 autofs.spec, 1.261, 1.262 autofs-5.0.3-add-missing-uris-list-locking.patch, 1.1, NONE

Ian Kent iankent at fedoraproject.org
Mon May 4 06:58:57 UTC 2009


Author: iankent

Update of /cvs/pkgs/rpms/autofs/F-10
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv21414

Modified Files:
	autofs.spec 
Added Files:
	autofs-5.0.3-fix-memory-leak-reading-ldap-master.patch 
	autofs-5.0.3-renew-sasl-creds-upon-reconnect-fail.patch 
	autofs-5.0.3-uris-list-locking-final.patch 
	autofs-5.0.4-add-lsb-init-script-parameter-block.patch 
Removed Files:
	autofs-5.0.3-add-missing-uris-list-locking.patch 
Log Message:
* Mon May 4 2009 Ian Kent <ikent at redhat.com> - 5.0.4-43
- update uris list lcoking patch.
- renew sasl creds upon reconnect fail.
- fix memory leak reading ldap master map.
- add LSB init script block.


autofs-5.0.3-fix-memory-leak-reading-ldap-master.patch:

--- NEW FILE autofs-5.0.3-fix-memory-leak-reading-ldap-master.patch ---
autofs-5.0.3 - fix memory leak reading ldap master map

From: Ian Kent <raven at themaw.net>

When reading the master map the storage allocated by getting the location
value is not freed after use.
---

 modules/lookup_ldap.c |    2 ++
 1 file changed, 2 insertions(+)


--- autofs-5.0.3.orig/modules/lookup_ldap.c
+++ autofs-5.0.3/modules/lookup_ldap.c
@@ -1544,6 +1544,8 @@ int lookup_read_master(struct master *ma
 		strcat(buf, " ");
 		strcat(buf, *values);
 
+		ldap_value_free(values);
+
 		master_parse_entry(buf, timeout, logging, age);
 next:
 		ldap_value_free(keyValue);

autofs-5.0.3-renew-sasl-creds-upon-reconnect-fail.patch:

--- NEW FILE autofs-5.0.3-renew-sasl-creds-upon-reconnect-fail.patch ---
autofs-5.0.3 - renew sasl creds upon reconnect fail

From: Ian Kent <raven at themaw.net>

If a server re-connect fails it could be due to the authentication
credentail having timed out. So we need to dispose of this and retry
the connection including refreshing re-authenticating.
---

 modules/lookup_ldap.c |   17 +++++++++++++++++
 1 file changed, 17 insertions(+)


--- autofs-5.0.3.orig/modules/lookup_ldap.c
+++ autofs-5.0.3/modules/lookup_ldap.c
@@ -675,6 +675,13 @@ static LDAP *do_reconnect(unsigned logop
 
 	if (ctxt->server || !ctxt->uris) {
 		ldap = do_connect(logopt, ctxt->server, ctxt);
+#ifdef WITH_SASL
+		/* Dispose of the sasl authentication connection and try again. */
+		if (!ldap) {
+			autofs_sasl_dispose(ctxt);
+			ldap = connect_to_server(logopt, ctxt->server, ctxt);
+		}
+#endif
 		return ldap;
 	}
 
@@ -682,6 +689,16 @@ static LDAP *do_reconnect(unsigned logop
 	this = ctxt->uri;
 	uris_mutex_unlock(ctxt);
 	ldap = do_connect(logopt, this->uri, ctxt);
+#ifdef WITH_SASL
+	/*
+	 * Dispose of the sasl authentication connection and try the
+	 * current server again before trying other servers in the list.
+	 */
+	if (!ldap) {
+		autofs_sasl_dispose(ctxt);
+		ldap = connect_to_server(logopt, this->uri, ctxt);
+	}
+#endif
 	if (ldap)
 		return ldap;
 

autofs-5.0.3-uris-list-locking-final.patch:

--- NEW FILE autofs-5.0.3-uris-list-locking-final.patch ---
autofs-5.0.3 - add missing uris list locking

From: Ian Kent <raven at themaw.net>

Add inadvertantly ommitted server list locking in LDAP module.

The ldap uris list doesn't need to change we just need to keep
track of current server uri in the list and try to connect in
a round robin order. Also it's possible multiple concurrent
connection attempts may not be able to use the full list of
servers (if one is present).
---

 include/lookup_ldap.h |    4 +-
 modules/lookup_ldap.c |   97 ++++++++++++++++++++++++++++++++------------------
 2 files changed, 66 insertions(+), 35 deletions(-)


--- autofs-5.0.3.orig/include/lookup_ldap.h
+++ autofs-5.0.3/include/lookup_ldap.h
@@ -54,7 +54,9 @@ struct lookup_context {
  	 * sdns is the list of basdns to check, done in the order
  	 * given in configuration.
  	 */
-	struct list_head *uri;
+	pthread_mutex_t uris_mutex;
+	struct list_head *uris;
+	struct ldap_uri *uri;
 	char *cur_host;
 	struct ldap_searchdn *sdns;
 
--- autofs-5.0.3.orig/modules/lookup_ldap.c
+++ autofs-5.0.3/modules/lookup_ldap.c
@@ -121,7 +121,23 @@ int ldap_parse_page_control(LDAP *ldap, 
 }
 #endif /* HAVE_LDAP_PARSE_PAGE_CONTROL */
 
-int bind_ldap_anonymous(unsigned logopt, LDAP *ldap, struct lookup_context *ctxt)
+static void uris_mutex_lock(struct lookup_context *ctxt)
+{
+	int status = pthread_mutex_lock(&ctxt->uris_mutex);
+	if (status)
+		fatal(status);
+	return;
+}
+
+static void uris_mutex_unlock(struct lookup_context *ctxt)
+{
+	int status = pthread_mutex_unlock(&ctxt->uris_mutex);
+	if (status)
+		fatal(status);
+	return;
+}
+
+int bind_ldap_anonymous(unsigned logopt, LDAP *ldap, const char *uri, struct lookup_context *ctxt)
 {
 	int rv;
 
@@ -131,16 +147,14 @@ int bind_ldap_anonymous(unsigned logopt,
 		rv = ldap_simple_bind_s(ldap, NULL, NULL);
 
 	if (rv != LDAP_SUCCESS) {
-		if (!ctxt->uri) {
+		if (!ctxt->uris) {
 			crit(logopt, MODPREFIX
 			     "Unable to bind to the LDAP server: "
 			     "%s, error %s", ctxt->server ? "" : "(default)",
 			     ldap_err2string(rv));
 		} else {
-			struct ldap_uri *uri;
-			uri = list_entry(ctxt->uri->next, struct ldap_uri, list);
 			info(logopt, MODPREFIX "Unable to bind to the LDAP server: "
-			     "%s, error %s", uri->uri, ldap_err2string(rv));
+			     "%s, error %s", uri, ldap_err2string(rv));
 		}
 		return -1;
 	}
@@ -482,7 +496,7 @@ static int find_query_dn(unsigned logopt
 	return 0;
 }
 
-static int do_bind(unsigned logopt, LDAP *ldap, struct lookup_context *ctxt)
+static int do_bind(unsigned logopt, LDAP *ldap, const char *uri, struct lookup_context *ctxt)
 {
 	char *host = NULL, *nhost;
 	int rv, need_base = 1;
@@ -495,11 +509,11 @@ static int do_bind(unsigned logopt, LDAP
 		rv = autofs_sasl_bind(logopt, ldap, ctxt);
 		debug(logopt, MODPREFIX "autofs_sasl_bind returned %d", rv);
 	} else {
-		rv = bind_ldap_anonymous(logopt, ldap, ctxt);
+		rv = bind_ldap_anonymous(logopt, ldap, uri, ctxt);
 		debug(logopt, MODPREFIX "ldap anonymous bind returned %d", rv);
 	}
 #else
-	rv = bind_ldap_anonymous(logopt, ldap, ctxt);
+	rv = bind_ldap_anonymous(logopt, ldap, uri, ctxt);
 	debug(logopt, MODPREFIX "ldap anonymous bind returned %d", rv);
 #endif
 
@@ -568,7 +582,7 @@ static LDAP *do_connect(unsigned logopt,
 	if (!ldap)
 		return NULL;
 
-	if (!do_bind(logopt, ldap, ctxt)) {
+	if (!do_bind(logopt, ldap, uri, ctxt)) {
 		unbind_ldap_connection(logopt, ldap, ctxt);
 		return NULL;
 	}
@@ -596,7 +610,7 @@ static LDAP *connect_to_server(unsigned 
 			return NULL;
 		}
 
-		if (!do_bind(logopt, ldap, ctxt)) {
+		if (!do_bind(logopt, ldap, uri, ctxt)) {
 			unbind_ldap_connection(logopt, ldap, ctxt);
 			autofs_sasl_dispose(ctxt);
 			error(logopt, MODPREFIX "cannot bind to server");
@@ -622,31 +636,34 @@ static LDAP *find_server(unsigned logopt
 {
 	LDAP *ldap = NULL;
 	struct ldap_uri *this;
-	struct list_head *p;
-	LIST_HEAD(tmp);
+	struct list_head *p, *first;
 
 	/* Try each uri in list, add connect fails to tmp list */
-	p = ctxt->uri->next;
-	while(p != ctxt->uri) {
+	uris_mutex_lock(ctxt);
+	if (!ctxt->uri)
+		first = ctxt->uris;
+	else
+		first = &ctxt->uri->list;
+	uris_mutex_unlock(ctxt);
+	p = first->next;
+	while(p != first) {
+		/* Skip list head */
+		if (p == ctxt->uris) {
+			p = p->next;
+			continue;
+		}
 		this = list_entry(p, struct ldap_uri, list);
-		p = p->next;
 		debug(logopt, "trying server %s", this->uri);
 		ldap = connect_to_server(logopt, this->uri, ctxt);
 		if (ldap) {
 			info(logopt, "connected to uri %s", this->uri);
+			uris_mutex_lock(ctxt);
+			ctxt->uri = this;
+			uris_mutex_unlock(ctxt);
 			break;
 		}
-		list_del_init(&this->list);
-		list_add_tail(&this->list, &tmp);
+		p = p->next;
 	}
-	/*
-	 * Successfuly connected uri (head of list) and untried uris are
-	 * in ctxt->uri list. Make list of remainder and failed uris with
-	 * failed uris at end and assign back to ctxt-uri.
-	 */
-	list_splice(ctxt->uri, &tmp);
-	INIT_LIST_HEAD(ctxt->uri);
-	list_splice(&tmp, ctxt->uri);
 
 	return ldap;
 }
@@ -656,19 +673,19 @@ static LDAP *do_reconnect(unsigned logop
 	struct ldap_uri *this;
 	LDAP *ldap;
 
-	if (ctxt->server || !ctxt->uri) {
+	if (ctxt->server || !ctxt->uris) {
 		ldap = do_connect(logopt, ctxt->server, ctxt);
 		return ldap;
 	}
 
-	this = list_entry(ctxt->uri->next, struct ldap_uri, list);
+	uris_mutex_lock(ctxt);
+	this = ctxt->uri;
+	uris_mutex_unlock(ctxt);
 	ldap = do_connect(logopt, this->uri, ctxt);
 	if (ldap)
 		return ldap;
 
-	/* Failed to connect, put at end of list */
-	list_del_init(&this->list);
-	list_add_tail(&this->list, ctxt->uri);
+	/* Failed to connect, try to find a new server */
 
 #ifdef WITH_SASL
 	autofs_sasl_dispose(ctxt);
@@ -1202,6 +1219,8 @@ done:
 
 static void free_context(struct lookup_context *ctxt)
 {
+	int ret;
+
 	if (ctxt->schema) {
 		free(ctxt->schema->map_class);
 		free(ctxt->schema->map_attr);
@@ -1232,8 +1251,11 @@ static void free_context(struct lookup_c
 		free(ctxt->cur_host);
 	if (ctxt->base)
 		free(ctxt->base);
-	if (ctxt->uri)
-		defaults_free_uris(ctxt->uri);
+	if (ctxt->uris)
+		defaults_free_uris(ctxt->uris);
+	ret = pthread_mutex_destroy(&ctxt->uris_mutex);
+	if (ret)
+		fatal(ret);
 	if (ctxt->sdns)
 		defaults_free_searchdns(ctxt->sdns);
 	free(ctxt);
@@ -1285,6 +1307,13 @@ int lookup_init(const char *mapfmt, int 
 	}
 	memset(ctxt, 0, sizeof(struct lookup_context));
 
+	ret = pthread_mutex_init(&ctxt->uris_mutex, NULL);
+	if (ret) {
+		error(LOGOPT_ANY, MODPREFIX "failed to init uris mutex");
+		free(ctxt);
+		return 1;
+	}
+
 	/* If a map type isn't explicitly given, parse it like sun entries. */
 	if (mapfmt == NULL)
 		mapfmt = MAPFMT_DEFAULT;
@@ -1307,7 +1336,7 @@ int lookup_init(const char *mapfmt, int 
 		if (uris) {
 			validate_uris(uris);
 			if (!list_empty(uris))
-				ctxt->uri = uris;
+				ctxt->uris = uris;
 			else {
 				error(LOGOPT_ANY,
 				      "no valid uris found in config list"
@@ -1338,7 +1367,7 @@ int lookup_init(const char *mapfmt, int 
 	}
 #endif
 
-	if (ctxt->server || !ctxt->uri) {
+	if (ctxt->server || !ctxt->uris) {
 		ldap = connect_to_server(LOGOPT_NONE, ctxt->server, ctxt);
 		if (!ldap) {
 			free_context(ctxt);

autofs-5.0.4-add-lsb-init-script-parameter-block.patch:

--- NEW FILE autofs-5.0.4-add-lsb-init-script-parameter-block.patch ---
autofs-5.0.4 - add lsb init script parameter block

From: Ian Kent <raven at themaw.net>


---

 redhat/autofs.init.in |   11 ++++++++++-
 samples/rc.autofs.in  |   11 ++++++++++-
 2 files changed, 20 insertions(+), 2 deletions(-)


--- autofs-5.0.3.orig/redhat/autofs.init.in
+++ autofs-5.0.3/redhat/autofs.init.in
@@ -6,7 +6,16 @@
 # processname: /usr/sbin/automount
 # config: /etc/auto.master
 # description: Automounts filesystems on demand
-
+#
+### BEGIN INIT INFO
+# Provides: $autofs
+# Required-Start: $network $ypbind
+# Required-Stop: $network $ypbind
+# Default-Start: 3 4 5
+# Default-Stop: 0 1 2 6
+# Short-Description: Automounts filesystems on demand
+# Description: Automounts filesystems on demand
+### END INIT INFO
 #
 # Location of the automount daemon and the init directory
 #
--- autofs-5.0.3.orig/samples/rc.autofs.in
+++ autofs-5.0.3/samples/rc.autofs.in
@@ -5,7 +5,16 @@
 # On most distributions, this file should be called:
 # /etc/rc.d/init.d/autofs or /etc/init.d/autofs or /etc/rc.d/rc.autofs
 #
-
+#
+### BEGIN INIT INFO
+# Provides: $autofs
+# Required-Start: $network $ypbind
+# Required-Stop: $network $ypbind
+# Default-Start: 3 4 5
+# Default-Stop: 0 1 2 6
+# Short-Description: Automounts filesystems on demand
+# Description: Automounts filesystems on demand
+### END INIT INFO
 #
 # Location of the automount daemon and the init directory
 #


Index: autofs.spec
===================================================================
RCS file: /cvs/pkgs/rpms/autofs/F-10/autofs.spec,v
retrieving revision 1.261
retrieving revision 1.262
diff -u -p -r1.261 -r1.262
--- autofs.spec	19 Feb 2009 00:24:31 -0000	1.261
+++ autofs.spec	4 May 2009 06:58:26 -0000	1.262
@@ -4,7 +4,7 @@
 Summary: A tool for automatically mounting and unmounting filesystems
 Name: autofs
 Version: 5.0.3
-Release: 41
+Release: 43
 Epoch: 1
 License: GPLv2+
 Group: System Environment/Daemons
@@ -64,7 +64,7 @@ Patch51: autofs-5.0.3-dont-readmap-on-hu
 Patch52: autofs-5.0.3-nisplus-partial-and-free.patch
 Patch53: autofs-5.0.3-fix-rootless-direct-multi-mount-expire.patch
 Patch54: autofs-5.0.3-wait-submount-expire-complete.patch
-Patch55: autofs-5.0.3-add-missing-uris-list-locking.patch
+Patch55: autofs-5.0.3-uris-list-locking-final.patch
 Patch56: autofs-5.0.3-library-reload-fix.patch
 Patch57: autofs-5.0.3-expire-thread-create-cond-handling.patch
 Patch58: autofs-5.0.3-fix-master-map-lexer-eval-order.patch
@@ -73,6 +73,9 @@ Patch60: autofs-5.0.4-fix-dumb-libxml2-c
 Patch61: autofs-5.0.3-use-CLOEXEC-flag.patch
 Patch62: autofs-5.0.3-use-CLOEXEC-flag-setmntent.patch
 Patch63: autofs-5.0.3-use-CLOEXEC-flag-setmntent-include-fix.patch
+Patch64: autofs-5.0.3-renew-sasl-creds-upon-reconnect-fail.patch
+Patch65: autofs-5.0.3-fix-memory-leak-reading-ldap-master.patch
+Patch66: autofs-5.0.4-add-lsb-init-script-parameter-block.patch
 Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildRequires: autoconf, hesiod-devel, openldap-devel, bison, flex, libxml2-devel, cyrus-sasl-devel, openssl-devel module-init-tools util-linux nfs-utils e2fsprogs
 Requires: kernel >= 2.6.17
@@ -177,6 +180,9 @@ echo %{version}-%{release} > .version
 %patch61 -p1
 %patch62 -p1
 %patch63 -p1
+%patch64 -p1
+%patch65 -p1
+%patch66 -p1
 
 %build
 #CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=/usr --libdir=%{_libdir}
@@ -229,6 +235,12 @@ fi
 %{_libdir}/autofs/
 
 %changelog
+* Mon May 4 2009 Ian Kent <ikent at redhat.com> - 5.0.4-43
+- update uris list lcoking patch.
+- renew sasl creds upon reconnect fail.
+- fix memory leak reading ldap master map.
+- add LSB init script block.
+
 * Thu Feb 19 2009 Ian Kent <ikent at redhat.com> - 5.0.4-41
 - fix mntent.h not included before use of setmntent_r().
 


--- autofs-5.0.3-add-missing-uris-list-locking.patch DELETED ---




More information about the scm-commits mailing list