Blame SOURCES/autofs-5.0.7-fix-wildcard-multi-map-regression.patch

4d476f
autofs-5.0.7 - fix wildcard multi map regression
4d476f
4d476f
From: Ian Kent <raven@themaw.net>
4d476f
4d476f
A recent patch that removed code to add the current map entry when
4d476f
being parsed if it didn't already exist cause wildcard indirect
4d476f
multi-mount map entries to fail to mount.
4d476f
4d476f
Indirect multi-mount map entries need the entry matched by a wildcard
4d476f
lookup to be added to the map entry cache because subsequent operations
4d476f
expect a distinct map entry to be present or they will fail. This is
4d476f
what the code that was removed did but it did so in the wrong place
4d476f
which caused a deadlock situation.
4d476f
---
4d476f
 CHANGELOG                |    1 +
4d476f
 modules/lookup_file.c    |   23 ++++++++++++++++-------
4d476f
 modules/lookup_ldap.c    |   19 +++++++++++++++----
4d476f
 modules/lookup_nisplus.c |   21 ++++++++++++++++-----
4d476f
 modules/lookup_sss.c     |   17 ++++++++++++++---
4d476f
 modules/lookup_yp.c      |   21 ++++++++++++++++-----
4d476f
 6 files changed, 78 insertions(+), 24 deletions(-)
4d476f
4d476f
diff --git a/CHANGELOG b/CHANGELOG
4d476f
index 97d6f48..46ef335 100644
4d476f
--- a/CHANGELOG
4d476f
+++ b/CHANGELOG
4d476f
@@ -29,6 +29,7 @@
4d476f
 - modules/replicated.c: use sin6_addr.s6_addr32.
4d476f
 - workaround missing GNU versionsort extension.
4d476f
 - dont fail on master map self include.
4d476f
+- fix wildcard multi map regression.
4d476f
 
4d476f
 25/07/2012 autofs-5.0.7
4d476f
 =======================
4d476f
diff --git a/modules/lookup_file.c b/modules/lookup_file.c
4d476f
index f37bed9..65e5ee6 100644
4d476f
--- a/modules/lookup_file.c
4d476f
+++ b/modules/lookup_file.c
4d476f
@@ -1040,7 +1040,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
4d476f
 			return NSS_STATUS_UNAVAIL;
4d476f
 		}
4d476f
 
4d476f
-		cache_readlock(mc);
4d476f
+		cache_writelock(mc);
4d476f
 		me = cache_lookup_first(mc);
4d476f
 		if (me && st.st_mtime <= me->age) {
4d476f
 			/*
4d476f
@@ -1082,7 +1082,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
4d476f
 		}
4d476f
 	}
4d476f
 
4d476f
-	cache_readlock(mc);
4d476f
+	cache_writelock(mc);
4d476f
 do_cache_lookup:
4d476f
 	me = cache_lookup(mc, key);
4d476f
 	/*
4d476f
@@ -1098,11 +1098,20 @@ do_cache_lookup:
4d476f
 		if (!me)
4d476f
 			me = cache_lookup_distinct(mc, "*");
4d476f
 	}
4d476f
-	if (me && me->mapent && (me->source == source || *me->key == '/')) {
4d476f
-		pthread_cleanup_push(cache_lock_cleanup, mc);
4d476f
-		strcpy(mapent_buf, me->mapent);
4d476f
-		mapent = mapent_buf;
4d476f
-		pthread_cleanup_pop(0);
4d476f
+	if (me && me->mapent) {
4d476f
+		/*
4d476f
+		 * Add wildcard match for later validation checks and
4d476f
+		 * negative cache lookups.
4d476f
+		 */
4d476f
+		if (ap->type == LKP_INDIRECT && *me->key == '*') {
4d476f
+			ret = cache_update(mc, source, key, me->mapent, me->age);
4d476f
+			if (!(ret & (CHE_OK | CHE_UPDATED)))
4d476f
+				me = NULL;
4d476f
+		}
4d476f
+		if (me && (me->source == source || *me->key == '/')) {
4d476f
+			strcpy(mapent_buf, me->mapent);
4d476f
+			mapent = mapent_buf;
4d476f
+		}
4d476f
 	}
4d476f
 	cache_unlock(mc);
4d476f
 
4d476f
diff --git a/modules/lookup_ldap.c b/modules/lookup_ldap.c
4d476f
index 431e50d..83e3215 100644
4d476f
--- a/modules/lookup_ldap.c
4d476f
+++ b/modules/lookup_ldap.c
4d476f
@@ -2969,7 +2969,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
4d476f
 			return status;
4d476f
 	}
4d476f
 
4d476f
-	cache_readlock(mc);
4d476f
+	cache_writelock(mc);
4d476f
 	me = cache_lookup(mc, key);
4d476f
 	/* Stale mapent => check for entry in alternate source or wildcard */
4d476f
 	if (me && !me->mapent) {
4d476f
@@ -2979,9 +2979,20 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
4d476f
 		if (!me)
4d476f
 			me = cache_lookup_distinct(mc, "*");
4d476f
 	}
4d476f
-	if (me && me->mapent && (me->source == source || *me->key == '/')) {
4d476f
-		strcpy(mapent_buf, me->mapent);
4d476f
-		mapent = mapent_buf;
4d476f
+	if (me && me->mapent) {
4d476f
+		/*
4d476f
+		 * Add wildcard match for later validation checks and
4d476f
+		 * negative cache lookups.
4d476f
+		 */
4d476f
+		if (ap->type == LKP_INDIRECT && *me->key == '*') {
4d476f
+			ret = cache_update(mc, source, key, me->mapent, me->age);
4d476f
+			if (!(ret & (CHE_OK | CHE_UPDATED)))
4d476f
+				me = NULL;
4d476f
+		}
4d476f
+		if (me && (me->source == source || *me->key == '/')) {
4d476f
+			strcpy(mapent_buf, me->mapent);
4d476f
+			mapent = mapent_buf;
4d476f
+		}
4d476f
 	}
4d476f
 	cache_unlock(mc);
4d476f
 
4d476f
diff --git a/modules/lookup_nisplus.c b/modules/lookup_nisplus.c
4d476f
index 9fced96..8237a1e 100644
4d476f
--- a/modules/lookup_nisplus.c
4d476f
+++ b/modules/lookup_nisplus.c
4d476f
@@ -561,7 +561,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
4d476f
 			return status;
4d476f
 	}
4d476f
 
4d476f
-	cache_readlock(mc);
4d476f
+	cache_writelock(mc);
4d476f
 	me = cache_lookup(mc, key);
4d476f
 	/* Stale mapent => check for entry in alternate source or wildcard */
4d476f
 	if (me && !me->mapent) {
4d476f
@@ -571,10 +571,21 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
4d476f
 		if (!me)
4d476f
 			me = cache_lookup_distinct(mc, "*");
4d476f
 	}
4d476f
-	if (me && me->mapent && (me->source == source || *me->key == '/')) {
4d476f
-		mapent_len = strlen(me->mapent);
4d476f
-		mapent = malloc(mapent_len + 1);
4d476f
-		strcpy(mapent, me->mapent);
4d476f
+	if (me && me->mapent) {
4d476f
+		/*
4d476f
+		 * Add wildcard match for later validation checks and
4d476f
+		 * negative cache lookups.
4d476f
+		 */
4d476f
+		if (ap->type == LKP_INDIRECT && *me->key == '*') {
4d476f
+			ret = cache_update(mc, source, key, me->mapent, me->age);
4d476f
+			if (!(ret & (CHE_OK | CHE_UPDATED)))
4d476f
+				me = NULL;
4d476f
+		}
4d476f
+		if (me && (me->source == source || *me->key == '/')) {
4d476f
+			mapent_len = strlen(me->mapent);
4d476f
+			mapent = malloc(mapent_len + 1);
4d476f
+			strcpy(mapent, me->mapent);
4d476f
+		}
4d476f
 	}
4d476f
 	cache_unlock(mc);
4d476f
 
4d476f
diff --git a/modules/lookup_sss.c b/modules/lookup_sss.c
4d476f
index e0b84cc..5c2ed0a 100644
4d476f
--- a/modules/lookup_sss.c
4d476f
+++ b/modules/lookup_sss.c
4d476f
@@ -645,9 +645,20 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
4d476f
 		if (!me)
4d476f
 			me = cache_lookup_distinct(mc, "*");
4d476f
 	}
4d476f
-	if (me && me->mapent && (me->source == source || *me->key == '/')) {
4d476f
-		strcpy(mapent_buf, me->mapent);
4d476f
-		mapent = mapent_buf;
4d476f
+	if (me && me->mapent) {
4d476f
+		/*
4d476f
+		 * Add wildcard match for later validation checks and
4d476f
+		 * negative cache lookups.
4d476f
+		 */
4d476f
+		if (ap->type == LKP_INDIRECT && *me->key == '*') {
4d476f
+			ret = cache_update(mc, source, key, me->mapent, me->age);
4d476f
+			if (!(ret & (CHE_OK | CHE_UPDATED)))
4d476f
+				me = NULL;
4d476f
+		}
4d476f
+		if (me && (me->source == source || *me->key == '/')) {
4d476f
+			strcpy(mapent_buf, me->mapent);
4d476f
+			mapent = mapent_buf;
4d476f
+		}
4d476f
 	}
4d476f
 	cache_unlock(mc);
4d476f
 
4d476f
diff --git a/modules/lookup_yp.c b/modules/lookup_yp.c
4d476f
index 720df2e..a716e1f 100644
4d476f
--- a/modules/lookup_yp.c
4d476f
+++ b/modules/lookup_yp.c
4d476f
@@ -662,7 +662,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
4d476f
 			return status;
4d476f
 	}
4d476f
 
4d476f
-	cache_readlock(mc);
4d476f
+	cache_writelock(mc);
4d476f
 	me = cache_lookup(mc, key);
4d476f
 	/* Stale mapent => check for entry in alternate source or wildcard */
4d476f
 	if (me && !me->mapent) {
4d476f
@@ -672,10 +672,21 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
4d476f
 		if (!me)
4d476f
 			me = cache_lookup_distinct(mc, "*");
4d476f
 	}
4d476f
-	if (me && me->mapent && (me->source == source || *me->key == '/')) {
4d476f
-		mapent_len = strlen(me->mapent);
4d476f
-		mapent = alloca(mapent_len + 1);
4d476f
-		strcpy(mapent, me->mapent);
4d476f
+	if (me && me->mapent) {
4d476f
+		/*
4d476f
+		 * Add wildcard match for later validation checks and
4d476f
+		 * negative cache lookups.
4d476f
+		 */
4d476f
+		if (ap->type == LKP_INDIRECT && *me->key == '*') {
4d476f
+			ret = cache_update(mc, source, key, me->mapent, me->age);
4d476f
+			if (!(ret & (CHE_OK | CHE_UPDATED)))
4d476f
+				me = NULL;
4d476f
+		}
4d476f
+		if (me && (me->source == source || *me->key == '/')) {
4d476f
+			mapent_len = strlen(me->mapent);
4d476f
+			mapent = alloca(mapent_len + 1);
4d476f
+			strcpy(mapent, me->mapent);
4d476f
+		}
4d476f
 	}
4d476f
 	cache_unlock(mc);
4d476f