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

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