Blame SOURCES/autofs-5.0.8-use-open-instead-of-access.patch

306fa1
autofs-5.0.8 - use open(2) instead of access(2)
306fa1
306fa1
From: Ian Kent <ikent@redhat.com>
306fa1
306fa1
The access(2) system call has been used to trigger dependednt automounts
306fa1
in the target path when mounting. But access(2) no longer triggers the
306fa1
dependednt mounts.
306fa1
306fa1
So use open(2) with flag O_DIRECTORY which will trigger these mounts.
306fa1
---
306fa1
 CHANGELOG      |    1 +
306fa1
 daemon/spawn.c |   30 ++++++++++++++++++------------
306fa1
 2 files changed, 19 insertions(+), 12 deletions(-)
306fa1
306fa1
--- autofs-5.0.7.orig/CHANGELOG
306fa1
+++ autofs-5.0.7/CHANGELOG
306fa1
@@ -104,6 +104,7 @@
306fa1
 - fix variable substitution description.
306fa1
 - fix incorrect append options description in README.v5-release.
306fa1
 - fix mistake in assignment.
306fa1
+- use open(2) instead of access(2) to trigger dependent mounts.
306fa1
 
306fa1
 25/07/2012 autofs-5.0.7
306fa1
 =======================
306fa1
--- autofs-5.0.7.orig/daemon/spawn.c
306fa1
+++ autofs-5.0.7/daemon/spawn.c
306fa1
@@ -32,7 +32,7 @@ static pthread_mutex_t spawn_mutex = PTH
306fa1
 
306fa1
 #define SPAWN_OPT_NONE		0x0000
306fa1
 #define SPAWN_OPT_LOCK		0x0001
306fa1
-#define SPAWN_OPT_ACCESS	0x0002
306fa1
+#define SPAWN_OPT_OPEN		0x0002
306fa1
 
306fa1
 #define MTAB_LOCK_RETRIES	3
306fa1
 
306fa1
@@ -126,7 +126,7 @@ static int do_spawn(unsigned logopt, uns
306fa1
 	int errp, errn;
306fa1
 	int cancel_state;
306fa1
 	unsigned int use_lock = options & SPAWN_OPT_LOCK;
306fa1
-	unsigned int use_access = options & SPAWN_OPT_ACCESS;
306fa1
+	unsigned int use_open = options & SPAWN_OPT_OPEN;
306fa1
 	sigset_t allsigs, tmpsig, oldsig;
306fa1
 	struct thread_stdenv_vars *tsv;
306fa1
 	pid_t euid = 0;
306fa1
@@ -166,6 +166,8 @@ static int do_spawn(unsigned logopt, uns
306fa1
 		/* what to mount must always be second last */
306fa1
 		while (*pargv++)
306fa1
 			loc++;
306fa1
+		if (loc <= 3)
306fa1
+			goto done;
306fa1
 		loc -= 2;
306fa1
 
306fa1
 		/*
306fa1
@@ -176,7 +178,9 @@ static int do_spawn(unsigned logopt, uns
306fa1
 		 *
306fa1
 		 * I hope host names are never allowed "/" as first char
306fa1
 		 */
306fa1
-		if (use_access && *(argv[loc]) == '/') {
306fa1
+		if (use_open && *(argv[loc]) == '/') {
306fa1
+			int fd;
306fa1
+
306fa1
 			pid_t pgrp = getpgrp();
306fa1
 
306fa1
 			/*
306fa1
@@ -192,19 +196,21 @@ static int do_spawn(unsigned logopt, uns
306fa1
 			/*
306fa1
 			 * Trigger the recursive mount.
306fa1
 			 *
306fa1
-			 * Ignore the access(2) return code as there may be
306fa1
+			 * Ignore the open(2) return code as there may be
306fa1
 			 * multiple waiters for this mount and we need to
306fa1
-			 * let the  VFS handle access returns to each
306fa1
-			 * individual waiter.
306fa1
+			 * let the VFS handle returns to each individual
306fa1
+			 * waiter.
306fa1
 			 */
306fa1
-			access(argv[loc], F_OK);
306fa1
+			fd = open(argv[loc], O_DIRECTORY);
306fa1
+			if (fd != -1)
306fa1
+				close(fd);
306fa1
 
306fa1
 			seteuid(0);
306fa1
 			setegid(0);
306fa1
 			if (pgrp >= 0)
306fa1
 				setpgid(0, pgrp);
306fa1
 		}
306fa1
-
306fa1
+done:
306fa1
 		execv(prog, (char *const *) argv);
306fa1
 		_exit(255);	/* execv() failed */
306fa1
 	} else {
306fa1
@@ -327,7 +333,7 @@ int spawn_mount(unsigned logopt, ...)
306fa1
 #ifdef ENABLE_MOUNT_LOCKING
306fa1
 	options = SPAWN_OPT_LOCK;
306fa1
 #else
306fa1
-	options = SPAWN_OPT_ACCESS;
306fa1
+	options = SPAWN_OPT_OPEN;
306fa1
 #endif
306fa1
 
306fa1
 	va_start(arg, logopt);
306fa1
@@ -360,7 +366,7 @@ int spawn_mount(unsigned logopt, ...)
306fa1
 		p = argv + 2;
306fa1
 	}
306fa1
 	while ((*p = va_arg(arg, char *))) {
306fa1
-		if (options == SPAWN_OPT_ACCESS && !strcmp(*p, "-t")) {
306fa1
+		if (options == SPAWN_OPT_OPEN && !strcmp(*p, "-t")) {
306fa1
 			*(++p) = va_arg(arg, char *);
306fa1
 			if (!*p)
306fa1
 				break;
306fa1
@@ -429,7 +435,7 @@ int spawn_mount(unsigned logopt, ...)
306fa1
 
306fa1
 /*
306fa1
  * For bind mounts that depend on the target being mounted (possibly
306fa1
- * itself an automount) we attempt to mount the target using an access
306fa1
+ * itself an automount) we attempt to mount the target using an open(2)
306fa1
  * call. For this to work the location must be the second last arg.
306fa1
  *
306fa1
  * NOTE: If mount locking is enabled this type of recursive mount cannot
306fa1
@@ -455,7 +461,7 @@ int spawn_bind_mount(unsigned logopt, ..
306fa1
 #ifdef ENABLE_MOUNT_LOCKING
306fa1
 	options = SPAWN_OPT_LOCK;
306fa1
 #else
306fa1
-	options = SPAWN_OPT_ACCESS;
306fa1
+	options = SPAWN_OPT_OPEN;
306fa1
 #endif
306fa1
 
306fa1
 	/*