Blame SOURCES/autofs-5.1.0-handle-duplicates-in-multi-mounts.patch

304803
autofs-5.1.0 - handle duplicates in multi mounts
304803
304803
From: Ian Kent <ikent@redhat.com>
304803
304803
Duplicate entries in multi-mounts are a syntax error however some
304803
other automount implementations allow them and attempt to continue
304803
with the mount anyway.
304803
304803
This patch turns a detected duplicate error into a success return
304803
in order to continue.
304803
304803
Since it can't be known if the first or the later entry is the
304803
correct one to use the later replaces the old unless a memory
304803
allocation error occures in which case the old entry is retained
304803
and the change is noted in the log.
304803
---
304803
 CHANGELOG           |    1 +
304803
 lib/cache.c         |   19 ++++++++++++++++++-
304803
 modules/parse_sun.c |    5 +++--
304803
 3 files changed, 22 insertions(+), 3 deletions(-)
304803
304803
--- autofs-5.0.7.orig/CHANGELOG
304803
+++ autofs-5.0.7/CHANGELOG
304803
@@ -165,6 +165,7 @@
304803
 - add a prefix to program map stdvars.
304803
 - add config option to force use of program map stdvars.
304803
 - fix incorrect check in parse_mount().
304803
+- handle duplicates in multi mounts.
304803
 
304803
 25/07/2012 autofs-5.0.7
304803
 =======================
304803
--- autofs-5.0.7.orig/lib/cache.c
304803
+++ autofs-5.0.7/lib/cache.c
304803
@@ -733,8 +733,25 @@ int cache_update_offset(struct mapent_ca
304803
 
304803
 	me = cache_lookup_distinct(mc, key);
304803
 	if (me && me->age == age) {
304803
-		if (me == owner || strcmp(me->key, key) == 0)
304803
+		if (me == owner || strcmp(me->key, key) == 0) {
304803
+			char *pent;
304803
+
304803
+			warn(logopt,
304803
+			     "duplcate offset detected for key %s", me->key);
304803
+
304803
+			pent = malloc(strlen(mapent) + 1);
304803
+			if (!pent)
304803
+				warn(logopt,
304803
+				     "map entry not updated: %s", me->mapent);
304803
+			else {
304803
+				if (me->mapent)
304803
+					free(me->mapent);
304803
+				me->mapent = strcpy(pent, mapent);
304803
+				warn(logopt,
304803
+				     "map entry updated with: %s", mapent);
304803
+			}
304803
 			return CHE_DUPLICATE;
304803
+		}
304803
 	}
304803
 
304803
 	ret = cache_update(mc, owner->source, key, mapent, age);
304803
--- autofs-5.0.7.orig/modules/parse_sun.c
304803
+++ autofs-5.0.7/modules/parse_sun.c
304803
@@ -804,10 +804,11 @@ update_offset_entry(struct autofs_point
304803
 	}
304803
 
304803
 	ret = cache_update_offset(mc, name, m_key, m_mapent, age);
304803
-	if (ret == CHE_DUPLICATE)
304803
+	if (ret == CHE_DUPLICATE) {
304803
 		warn(ap->logopt, MODPREFIX
304803
 		     "syntax error or duplicate offset %s -> %s", path, loc);
304803
-	else if (ret == CHE_FAIL)
304803
+		ret = CHE_OK;
304803
+	} else if (ret == CHE_FAIL)
304803
 		debug(ap->logopt, MODPREFIX
304803
 		      "failed to update multi-mount offset %s -> %s", path, m_mapent);
304803
 	else {