Blame SOURCES/autofs-5.1.0-fix-mount-as-you-go-offset-selection.patch

306fa1
autofs-5.1.0 - fix mount as you go offset selection
306fa1
306fa1
From: Ian Kent <raven@themaw.net>
306fa1
306fa1
The function cache_get_offset() returns offsets to be mounted that
306fa1
are within the current current subtree for the mount-as-you-go
306fa1
functionality used for nested multi-mount map entries.
306fa1
306fa1
However, the function was returning offsets from the subree below
306fa1
nesting points which prevented the mount at the containing nesting
306fa1
point from being mounted. This is because the kernel will see a
306fa1
non-empty directory and conclude it isn't a mount point.
306fa1
---
306fa1
 CHANGELOG   |    1 +
306fa1
 lib/cache.c |   27 ++++++++++++++++++++++++---
306fa1
 2 files changed, 25 insertions(+), 3 deletions(-)
306fa1
306fa1
--- autofs-5.0.7.orig/CHANGELOG
306fa1
+++ autofs-5.0.7/CHANGELOG
306fa1
@@ -168,6 +168,7 @@
306fa1
 - handle duplicates in multi mounts.
306fa1
 - fix macro usage in lookup_program.c.
306fa1
 - remove unused offset handling code.
306fa1
+- fix mount as you go offset selection.
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
@@ -1183,7 +1183,6 @@ struct mapent *cache_enumerate(struct ma
306fa1
  * Get each offset from list head under prefix.
306fa1
  * Maintain traversal current position in pos for subsequent calls. 
306fa1
  * Return each offset into offset.
306fa1
- * TODO: length check on offset.
306fa1
  */
306fa1
 /* cache must be read locked by caller */
306fa1
 char *cache_get_offset(const char *prefix, char *offset, int start,
306fa1
@@ -1212,6 +1211,9 @@ char *cache_get_offset(const char *prefi
306fa1
 			continue;
306fa1
 
306fa1
 		if (!strncmp(prefix, offset_start, plen)) {
306fa1
+			struct mapent *np = NULL;
306fa1
+			char pe[PATH_MAX + 1];
306fa1
+
306fa1
 			/* "/" doesn't count for root offset */
306fa1
 			if (plen == 1)
306fa1
 				pstart = &offset_start[plen - 1];
306fa1
@@ -1224,7 +1226,24 @@ char *cache_get_offset(const char *prefi
306fa1
 
306fa1
 			/* get next offset */
306fa1
 			pend = pstart;
306fa1
-			while (*pend++) ;
306fa1
+			while (*pend++) {
306fa1
+				size_t nest_pt_offset;
306fa1
+
306fa1
+				if (*pend != '/')
306fa1
+					continue;
306fa1
+
306fa1
+				nest_pt_offset = start + pend - pstart;
306fa1
+				if (plen > 1)
306fa1
+					nest_pt_offset += plen;
306fa1
+				strcpy(pe, this->key);
306fa1
+				pe[nest_pt_offset] = '\0';
306fa1
+
306fa1
+				np = cache_lookup_distinct(this->mc, pe);
306fa1
+				if (np)
306fa1
+					break;
306fa1
+			}
306fa1
+			if (np)
306fa1
+				continue;
306fa1
 			len = pend - pstart - 1;
306fa1
 			strncpy(offset, pstart, len);
306fa1
 			offset[len] ='\0';
306fa1
@@ -1257,7 +1276,9 @@ char *cache_get_offset(const char *prefi
306fa1
 			break;
306fa1
 
306fa1
 		/* compare offset */
306fa1
-		if (pstart[len] != '/' || strncmp(offset, pstart, len))
306fa1
+		if (pstart[len] != '/' ||
306fa1
+		    strlen(pstart) != len ||
306fa1
+		    strncmp(offset, pstart, len))
306fa1
 			break;
306fa1
 
306fa1
 		*pos = next;