rpms/autofs/devel autofs-5.0.0_beta6-ldap-lookup-update.patch, NONE, 1.1 autofs-5.0.0_beta6-mount-mod-dir-cleanup.patch, NONE, 1.1 autofs.spec, 1.121, 1.122

fedora-cvs-commits at redhat.com fedora-cvs-commits at redhat.com
Tue Jul 11 08:05:51 UTC 2006


Author: ikent

Update of /cvs/dist/rpms/autofs/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv31337

Modified Files:
	autofs.spec 
Added Files:
	autofs-5.0.0_beta6-ldap-lookup-update.patch 
	autofs-5.0.0_beta6-mount-mod-dir-cleanup.patch 
Log Message:
* Tue Jul 11 2006 Ian Kent <ikent at redhat.com> - 5.0.0_beta6-7
- correct directory cleanup in mount modules.
- merge key and wildcard LDAP query for lookups (bz 197746).


autofs-5.0.0_beta6-ldap-lookup-update.patch:
 CHANGELOG             |    1 
 modules/lookup_ldap.c |  174 ++++++++++++++++++++++++++------------------------
 2 files changed, 93 insertions(+), 82 deletions(-)

--- NEW FILE autofs-5.0.0_beta6-ldap-lookup-update.patch ---
diff --git a/CHANGELOG b/CHANGELOG
index b581411..c2f04f6 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -11,6 +11,7 @@
 - update LDAP auth - add autodectect option.
 - correct test for libhesiod.
 - correct directory cleanup in mount modules.
+- merge key and wildcard LDAP query for lookups.
 
 29/6/2006 autofs-5.0.0_beta6
 ----------------------------
diff --git a/modules/lookup_ldap.c b/modules/lookup_ldap.c
index ca1258d..82df7f8 100644
--- a/modules/lookup_ldap.c
+++ b/modules/lookup_ldap.c
@@ -1281,6 +1281,7 @@ static int lookup_one(struct autofs_poin
 {
 	struct map_source *source = ap->entry->current;
 	struct mapent_cache *mc = source->mc;
+	struct mapent me;
 	int rv, i, l, ql, count;
 	char buf[MAX_ERR_BUF];
 	time_t age = time(NULL);
@@ -1293,7 +1294,8 @@ static int lookup_one(struct autofs_poin
 	int scope = LDAP_SCOPE_SUBTREE;
 	LDAP *ldap;
 	char *mapent = NULL;
-	int ret = CHE_OK;
+	unsigned int wild = 0;
+	int ret = CHE_MISSING;
 
 	if (ctxt == NULL) {
 		crit(ap->logopt, MODPREFIX "context was NULL");
@@ -1312,7 +1314,7 @@ static int lookup_one(struct autofs_poin
 		*qKey = '/';
 
 	/* Build a query string. */
-	l = strlen(class) + strlen(entry) + strlen(qKey) + 21;
+	l = strlen(class) + 2*strlen(entry) + strlen(qKey) + 29;
 
 	query = alloca(l);
 	if (query == NULL) {
@@ -1325,7 +1327,8 @@ static int lookup_one(struct autofs_poin
 	 * Look for an entry in class under ctxt-base
 	 * whose entry is equal to qKey.
 	 */
-	ql = sprintf(query, "(&(objectclass=%s)(%s=%s))", class, entry, qKey);
+	ql = sprintf(query,
+	      "(&(objectclass=%s)(|(%s=%s)(%s=/)))", class, entry, qKey, entry);
 	if (ql >= l) {
 		error(ap->logopt,
 		      MODPREFIX "error forming query string");
@@ -1361,89 +1364,102 @@ static int lookup_one(struct autofs_poin
 		return CHE_MISSING;
 	}
 
-	keyValue = ldap_get_values(ldap, e, entry);
+	while (e) {
+		keyValue = ldap_get_values(ldap, e, entry);
 
-	/* By definition keys must be unique within each map entry */
-	if (ldap_count_values(keyValue) > 1) {
-		error(ap->logopt,
-		      MODPREFIX "key %s has duplicate entries", *keyValue);
-		ldap_value_free(keyValue);
-		ldap_msgfree(result);
-		unbind_ldap_connection(ldap, ctxt);
-		return CHE_FAIL;
-	}
+		if (!keyValue || !*keyValue) {
+			e = ldap_next_entry(ldap, e);
+			continue;
+		}
 
-	debug(ap->logopt, MODPREFIX "examining first entry");
+		/* By definition keys must be unique within each map entry */
+		if (ldap_count_values(keyValue) > 1) {
+			error(ap->logopt,
+			      MODPREFIX "key %s has duplicate entries",
+			      *keyValue);
+			ret = CHE_FAIL;
+			goto next;
+		}
 
-	values = ldap_get_values(ldap, e, info);
-	if (!values || !*values) {
-		debug(ap->logopt,
-		      MODPREFIX "no %s defined for %s", info, query);
-		ldap_value_free(keyValue);
-		ldap_msgfree(result);
-		unbind_ldap_connection(ldap, ctxt);
-		return CHE_MISSING;
-	}
+		debug(ap->logopt, MODPREFIX "examining first entry");
 
-	count = ldap_count_values(values);
-	for (i = 0; i < count; i++) {
-		int v_len = strlen(values[i]);
+		values = ldap_get_values(ldap, e, info);
+		if (!values || !*values) {
+			debug(ap->logopt,
+			      MODPREFIX "no %s defined for %s", info, query);
+			goto next;
+		}
+
+		count = ldap_count_values(values);
+		for (i = 0; i < count; i++) {
+			int v_len = strlen(values[i]);
 
-		if (!mapent) {
-			mapent = malloc(v_len + 1);
 			if (!mapent) {
-				char *estr;
-				estr = strerror_r(errno, buf, MAX_ERR_BUF);
-				error(ap->logopt,
-				      MODPREFIX "malloc: %s", estr);
-				continue;
-			}
-			strcpy(mapent, values[i]);
-		} else {
-			int new_size = strlen(mapent) + v_len + 2;
-			char *new_me;
-			new_me = realloc(mapent, new_size);
-			if (new_me) {
-				mapent = new_me;
-				strcat(mapent, " ");
-				strcat(mapent, values[i]);
+				mapent = malloc(v_len + 1);
+				if (!mapent) {
+					char *estr;
+					estr = strerror_r(errno, buf, MAX_ERR_BUF);
+					error(ap->logopt,
+					      MODPREFIX "malloc: %s", estr);
+					continue;
+				}
+				strcpy(mapent, values[i]);
 			} else {
-				char *estr;
-				estr = strerror_r(errno, buf, MAX_ERR_BUF);
-				error(ap->logopt,
-				      MODPREFIX "realloc: %s", estr);
+				int new_size = strlen(mapent) + v_len + 2;
+				char *new_me;
+				new_me = realloc(mapent, new_size);
+				if (new_me) {
+					mapent = new_me;
+					strcat(mapent, " ");
+					strcat(mapent, values[i]);
+				} else {
+					char *estr;
+					estr = strerror_r(errno, buf, MAX_ERR_BUF);
+					error(ap->logopt,
+					      MODPREFIX "realloc: %s", estr);
+				}
 			}
 		}
-	}
-	ldap_value_free(values);
-
-	if (**keyValue == '/' && strlen(*keyValue) == 1)
-		**keyValue = '*';
+		ldap_value_free(values);
 
-	if (ap->type == LKP_INDIRECT && **keyValue == '/') {
-		ret = CHE_MISSING;
-		goto done;
-	}
+		if (**keyValue == '/') {
+			if (ap->type == LKP_INDIRECT) {
+				if (strlen(*keyValue) == 1) {
+					wild = 1;
+					**keyValue = '*';
+					cache_writelock(mc);
+					cache_update(mc,
+						source, *keyValue, mapent, age);
+					cache_unlock(mc);
+				}
+				goto next;
+			}
+		} else {
+			if (ap->type == LKP_DIRECT)
+				goto next;
+		}
 
-	if (ap->type == LKP_DIRECT && **keyValue != '/') {
-		ret = CHE_MISSING;
-		goto done;
-	}
+		cache_writelock(mc);
+		ret = cache_update(mc, source, *keyValue, mapent, age);
+		cache_unlock(mc);
+next:
+		if (mapent) {
+			free(mapent);
+			mapent = NULL;
+		}
 
-	cache_writelock(mc);
-	ret = cache_update(mc, source, *keyValue, mapent, age);
-	cache_unlock(mc);
-done:
-	if (mapent) {
-		free(mapent);
-		mapent = NULL;
+		ldap_value_free(keyValue);
+		e = ldap_next_entry(ldap, e);
 	}
 
-	/* Clean up. */
-	ldap_value_free(keyValue);
 	ldap_msgfree(result);
 	unbind_ldap_connection(ldap, ctxt);
 
+	cache_writelock(mc);
+	if (!wild && cache_lookup(mc, "*"))
+		cache_delete(mc, "*");
+	cache_unlock(mc);
+
 	return ret;
 }
 
@@ -1480,19 +1496,9 @@ static int check_map_indirect(struct aut
 	}
 
 	if (ret == CHE_MISSING) {
-		char *wkey = "/";
-		int wild = CHE_MISSING;
-
-		wild = lookup_one(ap, wkey, 1, ctxt);
-		if (wild == CHE_UPDATED || CHE_OK)
-			return NSS_STATUS_SUCCESS;
-
-		pthread_cleanup_push(cache_lock_cleanup, mc);
 		cache_writelock(mc);
-		if (wild == CHE_MISSING)
-			cache_delete(mc, "*");
-
-		if (cache_delete(mc, key) && wild & (CHE_MISSING | CHE_FAIL))
+		pthread_cleanup_push(cache_lock_cleanup, mc);
+		if (cache_delete(mc, key))
 			rmdir_path(ap, key);
 		pthread_cleanup_pop(1);
 	}
@@ -1514,8 +1520,12 @@ static int check_map_indirect(struct aut
 			fatal(status);
 	}
 
-	if (ret == CHE_MISSING)
+	cache_readlock(mc);
+	if (ret == CHE_MISSING && !cache_lookup(mc, "*")) {
+		cache_unlock(mc);
 		return NSS_STATUS_NOTFOUND;
+	}
+	cache_unlock(mc);
 
 	return NSS_STATUS_SUCCESS;
 }

autofs-5.0.0_beta6-mount-mod-dir-cleanup.patch:
 CHANGELOG               |    1 +
 modules/mount_bind.c    |   15 ++++++++++-----
 modules/mount_changer.c |    8 +++++---
 modules/mount_ext2.c    |    7 +++++--
 modules/mount_generic.c |    8 +++++---
 modules/mount_nfs.c     |   10 ++++++----
 6 files changed, 32 insertions(+), 17 deletions(-)

--- NEW FILE autofs-5.0.0_beta6-mount-mod-dir-cleanup.patch ---
diff --git a/CHANGELOG b/CHANGELOG
index 62e3e5b..b581411 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -10,6 +10,7 @@
 - correct auto.net installed as auto.smb.
 - update LDAP auth - add autodectect option.
 - correct test for libhesiod.
+- correct directory cleanup in mount modules.
 
 29/6/2006 autofs-5.0.0_beta6
 ----------------------------
diff --git a/modules/mount_bind.c b/modules/mount_bind.c
index 07c3c3b..3d292a6 100644
--- a/modules/mount_bind.c
+++ b/modules/mount_bind.c
@@ -155,8 +155,11 @@ int mount_mount(struct autofs_point *ap,
 			     what, fullpath, NULL);
 
 		if (err) {
-			if ((!ap->ghost && name_len) || !existed)
-				rmdir_path(ap, name);
+			if ((!ap->ghost && name_len) || !existed) {
+				if (!chdir(ap->path))
+					rmdir_path(ap, name);
+				err = chdir("/");
+			}
 			return 1;
 		} else {
 			debug(ap->logopt,
@@ -199,9 +202,11 @@ int mount_mount(struct autofs_point *ap,
 			      fullpath, what);
 			if (ap->ghost && !status)
 				mkdir_path(fullpath, 0555);
-			else
-				rmdir_path(ap, fullpath);
-
+			else {
+				if (!chdir(ap->path))
+					rmdir_path(ap, name);
+				err = chdir("/");
+			}
 			return 1;
 		} else {
 			debug(ap->logopt,
diff --git a/modules/mount_changer.c b/modules/mount_changer.c
index 40a3d5f..06e2032 100644
--- a/modules/mount_changer.c
+++ b/modules/mount_changer.c
@@ -130,9 +130,11 @@ int mount_mount(struct autofs_point *ap,
 	}
 
 	if (err) {
-		if ((!ap->ghost && name_len) || !existed)
-			rmdir_path(ap, name);
-
+		if ((!ap->ghost && name_len) || !existed) {
+			if (!chdir(ap->path))
+				rmdir_path(ap, name);
+			chdir("/");
+		}
 		error(ap->logopt,
 		      MODPREFIX "failed to mount %s (type %s) on %s",
 		      what, fstype, fullpath);
diff --git a/modules/mount_ext2.c b/modules/mount_ext2.c
index 16effdd..976d23a 100644
--- a/modules/mount_ext2.c
+++ b/modules/mount_ext2.c
@@ -146,8 +146,11 @@ #endif
 	}
 
 	if (err) {
-		if ((!ap->ghost && name_len) || !existed)
-			rmdir_path(ap, name);
+		if ((!ap->ghost && name_len) || !existed) {
+			if (!chdir(ap->path))
+				rmdir_path(ap, name);
+			err = chdir("/");
+		}
 		error(ap->logopt,
 		      MODPREFIX "failed to mount %s (type %s) on %s",
 		      what, fstype, fullpath);
diff --git a/modules/mount_generic.c b/modules/mount_generic.c
index 290ccc0..e744813 100644
--- a/modules/mount_generic.c
+++ b/modules/mount_generic.c
@@ -106,9 +106,11 @@ int mount_mount(struct autofs_point *ap,
 	}
 
 	if (err) {
-		if ((!ap->ghost && name_len) || !existed)
-			rmdir_path(ap, name);
-
+		if ((!ap->ghost && name_len) || !existed) {
+			if (!chdir(ap->path))
+				rmdir_path(ap, name);
+			err = chdir("/");
+		}
 		error(ap->logopt,
 		      MODPREFIX "failed to mount %s (type %s) on %s",
 		      what, fstype, fullpath);
diff --git a/modules/mount_nfs.c b/modules/mount_nfs.c
index a67d01c..b4df2f2 100644
--- a/modules/mount_nfs.c
+++ b/modules/mount_nfs.c
@@ -63,7 +63,7 @@ int mount_mount(struct autofs_point *ap,
 	struct host *this, *hosts = NULL;
 	unsigned int vers;
 	char *nfsoptions = NULL;
-	int len, rlen, status, existed = 1;
+	int len, rlen, status, err, existed = 1;
 	int nosymlink = 0;
 	int ro = 0;            /* Set if mount bind should be read-only */
 
@@ -182,7 +182,6 @@ int mount_mount(struct autofs_point *ap,
 
 	this = hosts;
 	while (this) {
-		int err;
 		char *loc;
 
 		if (is_mounted(_PATH_MOUNTED, fullpath, MNTS_REAL)) {
@@ -255,8 +254,11 @@ int mount_mount(struct autofs_point *ap,
 	free_host_list(&hosts);
 
 	/* If we get here we've failed to complete the mount */
-	if ((!ap->ghost && name_len) || !existed)
-		rmdir_path(ap, name);
+	if ((!ap->ghost && name_len) || !existed) {
+		if (!chdir(ap->path))
+			rmdir_path(ap, name);
+		err = chdir("/");
+	}
 
 	error(ap->logopt,
 	      MODPREFIX "nfs: mount failure %s on %s", what, fullpath);


Index: autofs.spec
===================================================================
RCS file: /cvs/dist/rpms/autofs/devel/autofs.spec,v
retrieving revision 1.121
retrieving revision 1.122
diff -u -r1.121 -r1.122
--- autofs.spec	7 Jul 2006 19:35:14 -0000	1.121
+++ autofs.spec	11 Jul 2006 08:05:48 -0000	1.122
@@ -4,7 +4,7 @@
 Summary: A tool for automatically mounting and unmounting filesystems.
 Name: autofs
 %define version 5.0.0_beta6
-%define release 6
+%define release 7
 Version: %{version}
 Release: %{release}
 Epoch: 1
@@ -21,6 +21,8 @@
 Patch8: autofs-5.0.0_beta6-correct-auto.smb.patch
 Patch9: autofs-5.0.0_beta6-auth-add-autodetect.patch
 Patch10: autofs-5.0.0_beta6-hesiod-lib.patch
+Patch11: autofs-5.0.0_beta6-mount-mod-dir-cleanup.patch
+Patch12: autofs-5.0.0_beta6-ldap-lookup-update.patch
 Buildroot: /var/tmp/autofs-tmp
 BuildRequires: autoconf, hesiod-devel, openldap-devel, bison, flex, libxml2-devel, cyrus-sasl-devel, openssl-devel
 Prereq: chkconfig
@@ -69,6 +71,8 @@
 %patch8 -p1
 %patch9 -p1
 %patch10 -p1
+%patch11 -p1
+%patch12 -p1
 
 %build
 #CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=/usr --libdir=%{_libdir}
@@ -125,6 +129,10 @@
 %{_libdir}/autofs/*
 
 %changelog
+* Tue Jul 11 2006 Ian Kent <ikent at redhat.com> - 5.0.0_beta6-7
+- correct directory cleanup in mount modules.
+- merge key and wildcard LDAP query for lookups (bz 197746).
+
 * Sat Jul 8 2006 Ian Kent <ikent at redhat.com> - 5.0.0_beta6-6
 - correct test for libhesiod.
 




More information about the fedora-cvs-commits mailing list