Blame SOURCES/autofs-5.1.0-dont-allocate-dev_ctl_ops-too-early.patch

6bbd11
autofs-5.1.0 - dont allocate dev_ctl_ops too early
6bbd11
6bbd11
From: Ian Kent <raven@themaw.net>
6bbd11
6bbd11
If the standard io file descriptors have been closed by the cloning
6bbd11
process the file handle for autofs device control can correspond to
6bbd11
a descriptor number of one of the standard io descriptors which will
6bbd11
be closed when the process is daemonized.
6bbd11
6bbd11
Avoid this by closing the device control descriptor opened when
6bbd11
performing sanity checks at startup so that it can be opened
6bbd11
on a higher numbered file descriptor after the process has switched
6bbd11
to daemon mode.
6bbd11
---
6bbd11
 CHANGELOG    |    1 +
6bbd11
 lib/mounts.c |   14 +++++++++++++-
6bbd11
 2 files changed, 14 insertions(+), 1 deletion(-)
6bbd11
6bbd11
--- autofs-5.0.7.orig/CHANGELOG
6bbd11
+++ autofs-5.0.7/CHANGELOG
6bbd11
@@ -127,6 +127,7 @@
6bbd11
 - allow empty value for some map options.
6bbd11
 - allow empty value in macro selectors.
6bbd11
 - add serialization to sasl init.
6bbd11
+- dont allocate dev_ctl_ops too early.
6bbd11
 
6bbd11
 25/07/2012 autofs-5.0.7
6bbd11
 =======================
6bbd11
--- autofs-5.0.7.orig/lib/mounts.c
6bbd11
+++ autofs-5.0.7/lib/mounts.c
6bbd11
@@ -90,7 +90,7 @@ unsigned int linux_version_code(void)
6bbd11
 
6bbd11
 unsigned int query_kproto_ver(void)
6bbd11
 {
6bbd11
-	struct ioctl_ops *ops = get_ioctl_ops();
6bbd11
+	struct ioctl_ops *ops;
6bbd11
 	char dir[] = "/tmp/autoXXXXXX", *t_dir;
6bbd11
 	char options[MAX_OPTIONS_LEN + 1];
6bbd11
 	pid_t pgrp = getpgrp();
6bbd11
@@ -131,10 +131,19 @@ unsigned int query_kproto_ver(void)
6bbd11
 		return 0;
6bbd11
 	}
6bbd11
 
6bbd11
+	ops = get_ioctl_ops();
6bbd11
+	if (!ops) {
6bbd11
+		umount(t_dir);
6bbd11
+		close(pipefd[0]);
6bbd11
+		rmdir(t_dir);
6bbd11
+		return 0;
6bbd11
+	}
6bbd11
+
6bbd11
 	ops->open(LOGOPT_NONE, &ioctlfd, st.st_dev, t_dir);
6bbd11
 	if (ioctlfd == -1) {
6bbd11
 		umount(t_dir);
6bbd11
 		close(pipefd[0]);
6bbd11
+		close_ioctl_ctl();
6bbd11
 		rmdir(t_dir);
6bbd11
 		return 0;
6bbd11
 	}
6bbd11
@@ -146,6 +155,7 @@ unsigned int query_kproto_ver(void)
6bbd11
 		ops->close(LOGOPT_NONE, ioctlfd);
6bbd11
 		umount(t_dir);
6bbd11
 		close(pipefd[0]);
6bbd11
+		close_ioctl_ctl();
6bbd11
 		rmdir(t_dir);
6bbd11
 		return 0;
6bbd11
 	}
6bbd11
@@ -155,6 +165,7 @@ unsigned int query_kproto_ver(void)
6bbd11
 		ops->close(LOGOPT_NONE, ioctlfd);
6bbd11
 		umount(t_dir);
6bbd11
 		close(pipefd[0]);
6bbd11
+		close_ioctl_ctl();
6bbd11
 		rmdir(t_dir);
6bbd11
 		return 0;
6bbd11
 	}
6bbd11
@@ -162,6 +173,7 @@ unsigned int query_kproto_ver(void)
6bbd11
 	ops->close(LOGOPT_NONE, ioctlfd);
6bbd11
 	umount(t_dir);
6bbd11
 	close(pipefd[0]);
6bbd11
+	close_ioctl_ctl();
6bbd11
 	rmdir(t_dir);
6bbd11
 
6bbd11
 	return 1;