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

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