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

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