Ian Kent ca38f0
autofs-5.0.6 - add disable move mount configure option
Ian Kent ca38f0
Ian Kent ca38f0
From: Ian Kent <ikent@redhat.com>
Ian Kent ca38f0
Ian Kent ca38f0
With the introduction of systemd the root filesystem is now usually
Ian Kent ca38f0
marked as shared instead of private as part of the systemd sandbox
Ian Kent ca38f0
functionality. As a consequence moving a mount from one mount point
Ian Kent ca38f0
to another is not allowed.
Ian Kent ca38f0
Ian Kent ca38f0
To resolve this a configure option (--disable-move-mount) to disable
Ian Kent ca38f0
autofs preparing mount tree and then moving it into place has been
Ian Kent ca38f0
added. The move mount use in autofs was needed for a small set of
Ian Kent ca38f0
automount types with older kernels (prior to 2.6.39). So to disable
Ian Kent ca38f0
the use of move mount it's necessary to use a recent kernel.
Ian Kent ca38f0
---
Ian Kent ca38f0
Ian Kent ca38f0
 CHANGELOG           |    1 +
Ian Kent ca38f0
 autofs.spec         |    2 +-
Ian Kent ca38f0
 configure           |   18 ++++++++++++++++++
Ian Kent ca38f0
 configure.in        |   10 ++++++++++
Ian Kent ca38f0
 daemon/automount.c  |   11 +++++++++++
Ian Kent ca38f0
 include/config.h.in |    3 +++
Ian Kent ca38f0
 modules/mount_nfs.c |    5 -----
Ian Kent ca38f0
 modules/parse_sun.c |   40 +++++++++++++++++++++++++++++++++++-----
Ian Kent ca38f0
 8 files changed, 79 insertions(+), 11 deletions(-)
Ian Kent ca38f0
Ian Kent ca38f0
Ian Kent ca38f0
diff --git a/CHANGELOG b/CHANGELOG
Ian Kent ca38f0
index 304b6a2..c682f94 100644
Ian Kent ca38f0
--- a/CHANGELOG
Ian Kent ca38f0
+++ b/CHANGELOG
Ian Kent ca38f0
@@ -12,6 +12,7 @@
Ian Kent ca38f0
 - fix wait for master source mutex.
Ian Kent ca38f0
 - fix submount shutdown race.
Ian Kent ca38f0
 - fix fix map source check in file lookup.
Ian Kent ca38f0
+- add disable move mount configure option.
Ian Kent ca38f0
 
Ian Kent ca38f0
 28/06/2011 autofs-5.0.6
Ian Kent ca38f0
 -----------------------
Ian Kent ca38f0
diff --git a/autofs.spec b/autofs.spec
Ian Kent ca38f0
index 82edd1e..510ef76 100644
Ian Kent ca38f0
--- a/autofs.spec
Ian Kent ca38f0
+++ b/autofs.spec
Ian Kent ca38f0
@@ -57,7 +57,7 @@ inkludera n
Ian Kent ca38f0
 echo %{version}-%{release} > .version
Ian Kent ca38f0
 
Ian Kent ca38f0
 %build
Ian Kent ca38f0
-CFLAGS="$RPM_OPT_FLAGS -Wall" ./configure --libdir=%{_libdir} --disable-mount-locking --enable-ignore-busy --with-libtirpc
Ian Kent ca38f0
+CFLAGS="$RPM_OPT_FLAGS -Wall" ./configure --libdir=%{_libdir} --disable-mount-locking --enable-ignore-busy --with-libtirpc --disable-mount-move
Ian Kent ca38f0
 CFLAGS="$RPM_OPT_FLAGS -Wall" make initdir=/etc/rc.d/init.d DONTSTRIP=1
Ian Kent ca38f0
 
Ian Kent ca38f0
 %install
Ian Kent ca38f0
diff --git a/configure b/configure
Ian Kent ca38f0
index b5a3608..76b6d86 100755
Ian Kent ca38f0
--- a/configure
Ian Kent ca38f0
+++ b/configure
Ian Kent ca38f0
@@ -704,6 +704,7 @@ with_openldap
Ian Kent ca38f0
 with_sasl
Ian Kent ca38f0
 enable_ext_env
Ian Kent ca38f0
 enable_mount_locking
Ian Kent ca38f0
+enable_mount_move
Ian Kent ca38f0
 enable_forced_shutdown
Ian Kent ca38f0
 enable_ignore_busy
Ian Kent ca38f0
 '
Ian Kent ca38f0
@@ -1326,6 +1327,7 @@ Optional Features:
Ian Kent ca38f0
   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
Ian Kent ca38f0
   --disable-ext-env	  disable search in environment for substitution variable
Ian Kent ca38f0
   --disable-mount-locking disable use of locking when spawning mount command
Ian Kent ca38f0
+  --disable-mount-move    disable use of mount move when when preparing tree of mounts
Ian Kent ca38f0
   --enable-force-shutdown enable USR1 signal to force unlink umount of any
Ian Kent ca38f0
 			  busy mounts during shutdown
Ian Kent ca38f0
   --enable-ignore-busy	  enable exit without umounting busy mounts during
Ian Kent ca38f0
@@ -5349,6 +5351,22 @@ $as_echo "#define ENABLE_MOUNT_LOCKING 1" >>confdefs.h
Ian Kent ca38f0
 fi
Ian Kent ca38f0
 
Ian Kent ca38f0
 #
Ian Kent ca38f0
+# Disable use of mount move
Ian Kent ca38f0
+#
Ian Kent ca38f0
+# Check whether --enable-mount-move was given.
Ian Kent ca38f0
+if test "${enable_mount_move+set}" = set; then :
Ian Kent ca38f0
+  enableval=$enable_mount_move;
Ian Kent ca38f0
+else
Ian Kent ca38f0
+  enableval=yes
Ian Kent ca38f0
+fi
Ian Kent ca38f0
+
Ian Kent ca38f0
+if test x$enable_mount_move = xyes -o x$enableval = xyes; then
Ian Kent ca38f0
+
Ian Kent ca38f0
+$as_echo "#define ENABLE_MOUNT_MOVE 1" >>confdefs.h
Ian Kent ca38f0
+
Ian Kent ca38f0
+fi
Ian Kent ca38f0
+
Ian Kent ca38f0
+#
Ian Kent ca38f0
 # Enable forced shutdown on USR1 signal (unlink umounts all mounts).
Ian Kent ca38f0
 #
Ian Kent ca38f0
 # Check whether --enable-forced-shutdown was given.
Ian Kent ca38f0
diff --git a/configure.in b/configure.in
Ian Kent ca38f0
index 46de65a..d3e4e54 100644
Ian Kent ca38f0
--- a/configure.in
Ian Kent ca38f0
+++ b/configure.in
Ian Kent ca38f0
@@ -324,6 +324,16 @@ if test x$enable_mount_locking = xyes -o x$enableval = xyes; then
Ian Kent ca38f0
 fi
Ian Kent ca38f0
 
Ian Kent ca38f0
 #
Ian Kent ca38f0
+# Disable use of mount move
Ian Kent ca38f0
+#
Ian Kent ca38f0
+AC_ARG_ENABLE(mount-move,
Ian Kent ca38f0
+[  --disable-mount-move    disable use of mount move when when preparing tree of mounts],,
Ian Kent ca38f0
+	enableval=yes)
Ian Kent ca38f0
+if test x$enable_mount_move = xyes -o x$enableval = xyes; then
Ian Kent ca38f0
+	AC_DEFINE(ENABLE_MOUNT_MOVE, 1, [Disable use of mount move when preparing tree of mounts])
Ian Kent ca38f0
+fi
Ian Kent ca38f0
+
Ian Kent ca38f0
+#
Ian Kent ca38f0
 # Enable forced shutdown on USR1 signal (unlink umounts all mounts).
Ian Kent ca38f0
 #
Ian Kent ca38f0
 AC_ARG_ENABLE(forced-shutdown,
Ian Kent ca38f0
diff --git a/daemon/automount.c b/daemon/automount.c
Ian Kent ca38f0
index 4f3151f..6bb5aa8 100644
Ian Kent ca38f0
--- a/daemon/automount.c
Ian Kent ca38f0
+++ b/daemon/automount.c
Ian Kent ca38f0
@@ -1743,9 +1743,20 @@ static void show_build_info(void)
Ian Kent ca38f0
 	count = 22;
Ian Kent ca38f0
 #endif
Ian Kent ca38f0
 
Ian Kent ca38f0
+#ifndef ENABLE_MOUNT_MOVE
Ian Kent ca38f0
+	printf("DISABLE_MOUNT_MOVE ");
Ian Kent ca38f0
+	count = count + 19;
Ian Kent ca38f0
+#endif
Ian Kent ca38f0
+
Ian Kent ca38f0
 #ifdef ENABLE_FORCED_SHUTDOWN
Ian Kent ca38f0
 	printf("ENABLE_FORCED_SHUTDOWN ");
Ian Kent ca38f0
 	count = count + 23;
Ian Kent ca38f0
+
Ian Kent ca38f0
+	if (count > 60) {
Ian Kent ca38f0
+		printf("\n  ");
Ian Kent ca38f0
+		count = 0;
Ian Kent ca38f0
+	}
Ian Kent ca38f0
+
Ian Kent ca38f0
 #endif
Ian Kent ca38f0
 
Ian Kent ca38f0
 #ifdef ENABLE_IGNORE_BUSY_MOUNTS
Ian Kent ca38f0
diff --git a/include/config.h.in b/include/config.h.in
Ian Kent ca38f0
index 4a3a990..97a8d2d 100644
Ian Kent ca38f0
--- a/include/config.h.in
Ian Kent ca38f0
+++ b/include/config.h.in
Ian Kent ca38f0
@@ -12,6 +12,9 @@
Ian Kent ca38f0
 /* Disable use of locking when spawning mount command */
Ian Kent ca38f0
 #undef ENABLE_MOUNT_LOCKING
Ian Kent ca38f0
 
Ian Kent ca38f0
+/* Disable use of mount move when preparing tree of mounts */
Ian Kent ca38f0
+#undef ENABLE_MOUNT_MOVE
Ian Kent ca38f0
+
Ian Kent ca38f0
 /* define if you have E2FSCK */
Ian Kent ca38f0
 #undef HAVE_E2FSCK
Ian Kent ca38f0
 
Ian Kent ca38f0
diff --git a/modules/mount_nfs.c b/modules/mount_nfs.c
Ian Kent ca38f0
index 8b567d2..7eab728 100644
Ian Kent ca38f0
--- a/modules/mount_nfs.c
Ian Kent ca38f0
+++ b/modules/mount_nfs.c
Ian Kent ca38f0
@@ -163,11 +163,6 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
Ian Kent ca38f0
 	if (root[len - 1] == '/') {
Ian Kent ca38f0
 		len = snprintf(fullpath, len, "%s", root);
Ian Kent ca38f0
 	} else if (*name == '/') {
Ian Kent ca38f0
-		/*
Ian Kent ca38f0
-		 * Direct or offset mount, name is absolute path so
Ian Kent ca38f0
-		 * don't use root (but with move mount changes root
Ian Kent ca38f0
-		 * is now the same as name).
Ian Kent ca38f0
-		 */
Ian Kent ca38f0
 		len = sprintf(fullpath, "%s", root);
Ian Kent ca38f0
 	} else {
Ian Kent ca38f0
 		len = sprintf(fullpath, "%s/%s", root, name);
Ian Kent ca38f0
diff --git a/modules/parse_sun.c b/modules/parse_sun.c
Ian Kent ca38f0
index 021850d..13b8af8 100644
Ian Kent ca38f0
--- a/modules/parse_sun.c
Ian Kent ca38f0
+++ b/modules/parse_sun.c
Ian Kent ca38f0
@@ -1028,6 +1028,7 @@ static int parse_mapent(const char *ent, char *g_options, char **options, char *
Ian Kent ca38f0
 	return (p - ent);
Ian Kent ca38f0
 }
Ian Kent ca38f0
 
Ian Kent ca38f0
+#ifdef ENABLE_MOUNT_MOVE
Ian Kent ca38f0
 static int move_mount(struct autofs_point *ap,
Ian Kent ca38f0
 		      const char *mm_tmp_root, const char *mm_root,
Ian Kent ca38f0
 		      unsigned int move)
Ian Kent ca38f0
@@ -1063,6 +1064,7 @@ static int move_mount(struct autofs_point *ap,
Ian Kent ca38f0
 
Ian Kent ca38f0
 	return 1;
Ian Kent ca38f0
 }
Ian Kent ca38f0
+#endif
Ian Kent ca38f0
 
Ian Kent ca38f0
 static void cleanup_multi_root(struct autofs_point *ap, const char *root,
Ian Kent ca38f0
 					 const char *path, unsigned int move)
Ian Kent ca38f0
@@ -1145,6 +1147,7 @@ static void cleanup_multi_triggers(struct autofs_point *ap,
Ian Kent ca38f0
 	return;
Ian Kent ca38f0
 }
Ian Kent ca38f0
 
Ian Kent ca38f0
+#ifdef ENABLE_MOUNT_MOVE
Ian Kent ca38f0
 static int check_fstype_autofs_option(const char *options)
Ian Kent ca38f0
 {
Ian Kent ca38f0
 	char *tok, *tokbuf;
Ian Kent ca38f0
@@ -1171,24 +1174,27 @@ static int check_fstype_autofs_option(const char *options)
Ian Kent ca38f0
 
Ian Kent ca38f0
 	return found;
Ian Kent ca38f0
 }
Ian Kent ca38f0
+#endif
Ian Kent ca38f0
 
Ian Kent ca38f0
 static int mount_subtree(struct autofs_point *ap, struct mapent *me,
Ian Kent ca38f0
 			 const char *name, char *loc, char *options, void *ctxt)
Ian Kent ca38f0
 {
Ian Kent ca38f0
 	struct mapent *mm;
Ian Kent ca38f0
 	struct mapent *ro;
Ian Kent ca38f0
-	char t_dir[] = "/tmp/autoXXXXXX";
Ian Kent ca38f0
-	char *mnt_tmp_root, *mm_root, *mm_base, *mm_key;
Ian Kent ca38f0
+	char *mm_root, *mm_base, *mm_key;
Ian Kent ca38f0
 	const char *mnt_root, *target;
Ian Kent ca38f0
 	unsigned int mm_root_len, mnt_root_len;
Ian Kent ca38f0
 	int start, ret = 0, rv;
Ian Kent ca38f0
-	unsigned int move;
Ian Kent ca38f0
+	unsigned int move = MOUNT_MOVE_NONE;
Ian Kent ca38f0
+#ifdef ENABLE_MOUNT_MOVE
Ian Kent ca38f0
+	char t_dir[] = "/tmp/autoXXXXXX";
Ian Kent ca38f0
+	char *mnt_tmp_root = NULL;
Ian Kent ca38f0
+#endif
Ian Kent ca38f0
 
Ian Kent ca38f0
 	rv = 0;
Ian Kent ca38f0
 
Ian Kent ca38f0
 	mm = me->multi;
Ian Kent ca38f0
 	mm_key = mm->key;
Ian Kent ca38f0
-	move = MOUNT_MOVE_NONE;
Ian Kent ca38f0
 
Ian Kent ca38f0
 	if (*mm_key == '/') {
Ian Kent ca38f0
 		mm_root = mm_key;
Ian Kent ca38f0
@@ -1202,7 +1208,10 @@ static int mount_subtree(struct autofs_point *ap, struct mapent *me,
Ian Kent ca38f0
 	}
Ian Kent ca38f0
 	mm_root_len = strlen(mm_root);
Ian Kent ca38f0
 
Ian Kent ca38f0
-	mnt_tmp_root = NULL;
Ian Kent ca38f0
+#ifndef ENABLE_MOUNT_MOVE
Ian Kent ca38f0
+	mnt_root = mm_root;
Ian Kent ca38f0
+	mnt_root_len = mm_root_len;
Ian Kent ca38f0
+#else
Ian Kent ca38f0
 	if (ap->flags & MOUNT_FLAG_REMOUNT) {
Ian Kent ca38f0
 		mnt_root = mm_root;
Ian Kent ca38f0
 		mnt_root_len = mm_root_len;
Ian Kent ca38f0
@@ -1213,6 +1222,7 @@ static int mount_subtree(struct autofs_point *ap, struct mapent *me,
Ian Kent ca38f0
 		mnt_root_len = strlen(mnt_root);
Ian Kent ca38f0
 		mnt_tmp_root = (char *) mnt_root;
Ian Kent ca38f0
 	}
Ian Kent ca38f0
+#endif
Ian Kent ca38f0
 
Ian Kent ca38f0
 	if (me == me->multi) {
Ian Kent ca38f0
 		/* name = NULL */
Ian Kent ca38f0
@@ -1238,11 +1248,13 @@ static int mount_subtree(struct autofs_point *ap, struct mapent *me,
Ian Kent ca38f0
 			}
Ian Kent ca38f0
 			ro_len = strlen(ro_loc);
Ian Kent ca38f0
 
Ian Kent ca38f0
+#ifdef ENABLE_MOUNT_MOVE
Ian Kent ca38f0
 			if (!(ap->flags & MOUNT_FLAG_REMOUNT)) {
Ian Kent ca38f0
 				move = MOUNT_MOVE_OTHER;
Ian Kent ca38f0
 				if (check_fstype_autofs_option(myoptions))
Ian Kent ca38f0
 					move = MOUNT_MOVE_AUTOFS;
Ian Kent ca38f0
 			}
Ian Kent ca38f0
+#endif
Ian Kent ca38f0
 
Ian Kent ca38f0
 			tmp = alloca(mnt_root_len + 1);
Ian Kent ca38f0
 			strcpy(tmp, mnt_root);
Ian Kent ca38f0
@@ -1266,7 +1278,9 @@ static int mount_subtree(struct autofs_point *ap, struct mapent *me,
Ian Kent ca38f0
 				goto error_out;
Ian Kent ca38f0
 			}
Ian Kent ca38f0
 		} else if (rv <= 0) {
Ian Kent ca38f0
+#ifdef ENABLE_MOUNT_MOVE
Ian Kent ca38f0
 			move = MOUNT_MOVE_NONE;
Ian Kent ca38f0
+#endif
Ian Kent ca38f0
 			ret = mount_multi_triggers(ap, me, mm_root, start, mm_base);
Ian Kent ca38f0
 			if (ret == -1) {
Ian Kent ca38f0
 				error(ap->logopt, MODPREFIX
Ian Kent ca38f0
@@ -1279,11 +1293,21 @@ static int mount_subtree(struct autofs_point *ap, struct mapent *me,
Ian Kent ca38f0
 		int loclen = strlen(loc);
Ian Kent ca38f0
 		int namelen = strlen(name);
Ian Kent ca38f0
 
Ian Kent ca38f0
+#ifndef ENABLE_MOUNT_MOVE
Ian Kent ca38f0
+		/*
Ian Kent ca38f0
+		 * When using move mount to mount offsets or direct mounts
Ian Kent ca38f0
+		 * the base of the tree can be the base of the temporary
Ian Kent ca38f0
+		 * mount point it needs to be the full path when not moving
Ian Kent ca38f0
+		 * the mount after construction.
Ian Kent ca38f0
+		 */
Ian Kent ca38f0
+		mnt_root = name;
Ian Kent ca38f0
+#else
Ian Kent ca38f0
 		if (!(ap->flags & MOUNT_FLAG_REMOUNT)) {
Ian Kent ca38f0
 			move = MOUNT_MOVE_OTHER;
Ian Kent ca38f0
 			if (check_fstype_autofs_option(options))
Ian Kent ca38f0
 				move = MOUNT_MOVE_AUTOFS;
Ian Kent ca38f0
 		}
Ian Kent ca38f0
+#endif
Ian Kent ca38f0
 
Ian Kent ca38f0
 		/* name = mm_root + mm_base */
Ian Kent ca38f0
 		/* destination = mm_root + mm_base = name */
Ian Kent ca38f0
@@ -1303,7 +1327,9 @@ static int mount_subtree(struct autofs_point *ap, struct mapent *me,
Ian Kent ca38f0
 		} else if (rv < 0) {
Ian Kent ca38f0
 			char *mm_root_base = alloca(strlen(mm_root) + strlen(mm_base) + 1);
Ian Kent ca38f0
 	
Ian Kent ca38f0
+#ifdef ENABLE_MOUNT_MOVE
Ian Kent ca38f0
 			move = MOUNT_MOVE_NONE;
Ian Kent ca38f0
+#endif
Ian Kent ca38f0
 
Ian Kent ca38f0
 			strcpy(mm_root_base, mm_root);
Ian Kent ca38f0
 			strcat(mm_root_base, mm_base);
Ian Kent ca38f0
@@ -1318,6 +1344,7 @@ static int mount_subtree(struct autofs_point *ap, struct mapent *me,
Ian Kent ca38f0
 		}
Ian Kent ca38f0
 	}
Ian Kent ca38f0
 
Ian Kent ca38f0
+#ifdef ENABLE_MOUNT_MOVE
Ian Kent ca38f0
 	if (!move_mount(ap, mnt_root, target, move)) {
Ian Kent ca38f0
 		cleanup_multi_triggers(ap, me, mnt_root, start, mm_base);
Ian Kent ca38f0
 		cleanup_multi_root(ap, mnt_root, mm_root, move);
Ian Kent ca38f0
@@ -1326,6 +1353,7 @@ static int mount_subtree(struct autofs_point *ap, struct mapent *me,
Ian Kent ca38f0
 
Ian Kent ca38f0
 	if (mnt_tmp_root)
Ian Kent ca38f0
 		rmdir(mnt_tmp_root);
Ian Kent ca38f0
+#endif
Ian Kent ca38f0
 
Ian Kent ca38f0
 	/* Mount for base of tree failed */
Ian Kent ca38f0
 	if (rv > 0)
Ian Kent ca38f0
@@ -1341,8 +1369,10 @@ static int mount_subtree(struct autofs_point *ap, struct mapent *me,
Ian Kent ca38f0
 	return rv;
Ian Kent ca38f0
 
Ian Kent ca38f0
 error_out:
Ian Kent ca38f0
+#ifdef ENABLE_MOUNT_MOVE
Ian Kent ca38f0
 	if (mnt_tmp_root)
Ian Kent ca38f0
 		rmdir(mnt_tmp_root);
Ian Kent ca38f0
+#endif
Ian Kent ca38f0
 
Ian Kent ca38f0
 	return 1;
Ian Kent ca38f0
 }