Blame SOURCES/autofs-5.0.9-amd-lookup-fix-lofs-mounting.patch

306fa1
autofs-5.0.9 - amd lookup fix lofs mounting
306fa1
306fa1
From: Ian Kent <raven@themaw.net>
306fa1
306fa1
The kernel leaves mount type autofs alone because they are supposed
306fa1
to be autofs sub-mounts and they look after their own expiration. So
306fa1
mounts bound to an autofs submount won't ever be expired.
306fa1
---
306fa1
 daemon/spawn.c |   42 ++++++++++++++++++++++++++++++++++++++----
306fa1
 1 file changed, 38 insertions(+), 4 deletions(-)
306fa1
306fa1
diff --git a/daemon/spawn.c b/daemon/spawn.c
306fa1
index a6c8c34..bfb8cfc 100644
306fa1
--- a/daemon/spawn.c
306fa1
+++ b/daemon/spawn.c
306fa1
@@ -111,6 +111,12 @@ static int timed_read(int pipe, char *buf, size_t len, int time)
306fa1
 		return ret;
306fa1
 	}
306fa1
 
306fa1
+	if (pfd[0].fd == -1)
306fa1
+		return 0;
306fa1
+
306fa1
+	if ((pfd[0].revents & (POLLIN|POLLHUP)) == POLLHUP)
306fa1
+		return 0;
306fa1
+
306fa1
 	while ((ret = read(pipe, buf, len)) == -1 && errno == EINTR);
306fa1
 
306fa1
 	return ret;
306fa1
@@ -179,7 +185,8 @@ static int do_spawn(unsigned logopt, unsigned int wait,
306fa1
 		 * I hope host names are never allowed "/" as first char
306fa1
 		 */
306fa1
 		if (use_open && *(argv[loc]) == '/') {
306fa1
-			int fd;
306fa1
+			char **p;
306fa1
+			int is_bind, fd;
306fa1
 
306fa1
 			pid_t pgrp = getpgrp();
306fa1
 
306fa1
@@ -209,6 +216,33 @@ static int do_spawn(unsigned logopt, unsigned int wait,
306fa1
 			setegid(0);
306fa1
 			if (pgrp >= 0)
306fa1
 				setpgid(0, pgrp);
306fa1
+
306fa1
+			/*
306fa1
+			 * The kernel leaves mount type autofs alone because
306fa1
+			 * they are supposed to be autofs sub-mounts and they
306fa1
+			 * look after their own expiration. So mounts bound
306fa1
+			 * to an autofs submount won't ever be expired.
306fa1
+			 */
306fa1
+			is_bind = 0;
306fa1
+			p = (char **) argv;
306fa1
+			while (*p) {
306fa1
+				if (strcmp(*p, "--bind")) {
306fa1
+					p++;
306fa1
+					continue;
306fa1
+				}
306fa1
+				is_bind = 1;
306fa1
+				break;
306fa1
+			}
306fa1
+			if (!is_bind)
306fa1
+				goto done;
306fa1
+
306fa1
+			if (is_mounted(_PROC_MOUNTS, argv[loc], MNTS_AUTOFS)) {
306fa1
+				fprintf(stderr,
306fa1
+				     "error: can't bind to an autofs mount\n");
306fa1
+				close(STDOUT_FILENO);
306fa1
+				close(STDERR_FILENO);
306fa1
+				 _exit(EINVAL);
306fa1
+			}
306fa1
 		}
306fa1
 done:
306fa1
 		execv(prog, (char *const *) argv);
306fa1
@@ -384,7 +418,7 @@ int spawn_mount(unsigned logopt, ...)
306fa1
 
306fa1
 	while (retries--) {
306fa1
 		ret = do_spawn(logopt, wait, options, prog, (const char **) argv);
306fa1
-		if (ret & MTAB_NOTUPDATED) {
306fa1
+		if (ret == MTAB_NOTUPDATED) {
306fa1
 			struct timespec tm = {3, 0};
306fa1
 
306fa1
 			/*
306fa1
@@ -502,7 +536,7 @@ int spawn_bind_mount(unsigned logopt, ...)
306fa1
 
306fa1
 	while (retries--) {
306fa1
 		ret = do_spawn(logopt, -1, options, prog, (const char **) argv);
306fa1
-		if (ret & MTAB_NOTUPDATED) {
306fa1
+		if (ret == MTAB_NOTUPDATED) {
306fa1
 			struct timespec tm = {3, 0};
306fa1
 
306fa1
 			/*
306fa1
@@ -604,7 +638,7 @@ int spawn_umount(unsigned logopt, ...)
306fa1
 
306fa1
 	while (retries--) {
306fa1
 		ret = do_spawn(logopt, wait, options, prog, (const char **) argv);
306fa1
-		if (ret & MTAB_NOTUPDATED) {
306fa1
+		if (ret == MTAB_NOTUPDATED) {
306fa1
 			/*
306fa1
 			 * If the mount succeeded but the mtab was not
306fa1
 			 * updated, then retry the umount just to update