Ian Kent cc4062
autofs-5.0.5 - mapent becomes negative during lookup
Ian Kent cc4062
Ian Kent cc4062
From: Ian Kent <raven@themaw.net>
Ian Kent cc4062
Ian Kent cc4062
During a mount request it is possible for a mapent to become negative
Ian Kent cc4062
between the time it is checked on entry and when we fetch the mount
Ian Kent cc4062
location information. This is because we drop the cache lock after
Ian Kent cc4062
the initial check and take it back again before getting the location
Ian Kent cc4062
information.
Ian Kent cc4062
---
Ian Kent cc4062
Ian Kent cc4062
 CHANGELOG                |    1 +
Ian Kent cc4062
 modules/lookup_file.c    |    2 +-
Ian Kent cc4062
 modules/lookup_ldap.c    |    2 +-
Ian Kent cc4062
 modules/lookup_nisplus.c |    2 +-
Ian Kent cc4062
 modules/lookup_yp.c      |    2 +-
Ian Kent cc4062
 5 files changed, 5 insertions(+), 4 deletions(-)
Ian Kent cc4062
Ian Kent cc4062
Ian Kent cc4062
--- autofs-5.0.5.orig/CHANGELOG
Ian Kent cc4062
+++ autofs-5.0.5/CHANGELOG
Ian Kent cc4062
@@ -39,6 +39,7 @@
Ian Kent cc4062
 - dont check null cache on expire.
Ian Kent cc4062
 - fix null cache race.
Ian Kent cc4062
 - fix cache_init() on source re-read.
Ian Kent cc4062
+- fix mapent becomes negative during lookup.
Ian Kent cc4062
 
Ian Kent cc4062
 03/09/2009 autofs-5.0.5
Ian Kent cc4062
 -----------------------
Ian Kent cc4062
--- autofs-5.0.5.orig/modules/lookup_file.c
Ian Kent cc4062
+++ autofs-5.0.5/modules/lookup_file.c
Ian Kent cc4062
@@ -1047,7 +1047,7 @@ do_cache_lookup:
Ian Kent cc4062
 		if (!me)
Ian Kent cc4062
 			me = cache_lookup_distinct(mc, "*");
Ian Kent cc4062
 	}
Ian Kent cc4062
-	if (me && (me->source == source || *me->key == '/')) {
Ian Kent cc4062
+	if (me && me->mapent && (me->source == source || *me->key == '/')) {
Ian Kent cc4062
 		pthread_cleanup_push(cache_lock_cleanup, mc);
Ian Kent cc4062
 		strcpy(mapent_buf, me->mapent);
Ian Kent cc4062
 		mapent = mapent_buf;
Ian Kent cc4062
--- autofs-5.0.5.orig/modules/lookup_ldap.c
Ian Kent cc4062
+++ autofs-5.0.5/modules/lookup_ldap.c
Ian Kent cc4062
@@ -2872,7 +2872,7 @@ int lookup_mount(struct autofs_point *ap
Ian Kent cc4062
 		if (!me)
Ian Kent cc4062
 			me = cache_lookup_distinct(mc, "*");
Ian Kent cc4062
 	}
Ian Kent cc4062
-	if (me && (me->source == source || *me->key == '/')) {
Ian Kent cc4062
+	if (me && me->mapent && (me->source == source || *me->key == '/')) {
Ian Kent cc4062
 		strcpy(mapent_buf, me->mapent);
Ian Kent cc4062
 		mapent = mapent_buf;
Ian Kent cc4062
 	}
Ian Kent cc4062
--- autofs-5.0.5.orig/modules/lookup_nisplus.c
Ian Kent cc4062
+++ autofs-5.0.5/modules/lookup_nisplus.c
Ian Kent cc4062
@@ -569,7 +569,7 @@ int lookup_mount(struct autofs_point *ap
Ian Kent cc4062
 		if (!me)
Ian Kent cc4062
 			me = cache_lookup_distinct(mc, "*");
Ian Kent cc4062
 	}
Ian Kent cc4062
-	if (me && (me->source == source || *me->key == '/')) {
Ian Kent cc4062
+	if (me && me->mapent && (me->source == source || *me->key == '/')) {
Ian Kent cc4062
 		mapent_len = strlen(me->mapent);
Ian Kent cc4062
 		mapent = malloc(mapent_len + 1);
Ian Kent cc4062
 		strcpy(mapent, me->mapent);
Ian Kent cc4062
--- autofs-5.0.5.orig/modules/lookup_yp.c
Ian Kent cc4062
+++ autofs-5.0.5/modules/lookup_yp.c
Ian Kent cc4062
@@ -670,7 +670,7 @@ int lookup_mount(struct autofs_point *ap
Ian Kent cc4062
 		if (!me)
Ian Kent cc4062
 			me = cache_lookup_distinct(mc, "*");
Ian Kent cc4062
 	}
Ian Kent cc4062
-	if (me && (me->source == source || *me->key == '/')) {
Ian Kent cc4062
+	if (me && me->mapent && (me->source == source || *me->key == '/')) {
Ian Kent cc4062
 		mapent_len = strlen(me->mapent);
Ian Kent cc4062
 		mapent = alloca(mapent_len + 1);
Ian Kent cc4062
 		strcpy(mapent, me->mapent);