diff --git a/autofs-5.0.5-check-for-path-mount-location-in-generic-module.patch b/autofs-5.0.5-check-for-path-mount-location-in-generic-module.patch new file mode 100644 index 0000000..082f135 --- /dev/null +++ b/autofs-5.0.5-check-for-path-mount-location-in-generic-module.patch @@ -0,0 +1,113 @@ +autofs-5.0.5 - check for path mount location in generic module + +From: Ian Kent + +Currently we check for dependent mounts in the mount location path +for bind mounts and loopback mounts. But we can have the case where +a mount other than a loopback mount uses a local path and is not a +bind mount. In this case we need to check the local path for dependent +mounts. To do this we can check the mount location prior to spawning +the mount and if it starts with a "/" then it is a local path and +the check is needed. +--- + + CHANGELOG | 1 + + daemon/spawn.c | 41 +++++++++++++++++++++++++++-------------- + 2 files changed, 28 insertions(+), 14 deletions(-) + + +diff --git a/CHANGELOG b/CHANGELOG +index cc2efab..8429e20 100644 +--- a/CHANGELOG ++++ b/CHANGELOG +@@ -13,6 +13,7 @@ + - make documentation for set-log-priority clearer. + - fix timeout in connect_nb(). + - fix pidof init script usage. ++- check for path mount location in generic module. + + 03/09/2009 autofs-5.0.5 + ----------------------- +diff --git a/daemon/spawn.c b/daemon/spawn.c +index db356d4..7c254d9 100644 +--- a/daemon/spawn.c ++++ b/daemon/spawn.c +@@ -154,22 +154,30 @@ static int do_spawn(unsigned logopt, unsigned int wait, + + f = fork(); + if (f == 0) { ++ char **pargv = (char **) argv; ++ int loc = 0; ++ + reset_signals(); + close(pipefd[0]); + dup2(pipefd[1], STDOUT_FILENO); + dup2(pipefd[1], STDERR_FILENO); + close(pipefd[1]); + +- /* Bind mount - check target exists */ +- if (use_access) { +- char **pargv = (char **) argv; +- int argc = 0; +- pid_t pgrp = getpgrp(); ++ /* what to mount must always be second last */ ++ while (*pargv++) ++ loc++; ++ loc -= 2; + +- /* what to mount must always be second last */ +- while (*pargv++) +- argc++; +- argc -= 2; ++ /* ++ * If the mount location starts with a "/" then it is ++ * a local path. In this case it is a bind mount, a ++ * loopback mount or a file system that uses a local ++ * path so we need to check for dependent mounts. ++ * ++ * I hope host names are never allowed "/" as first char ++ */ ++ if (use_access && *(argv[loc]) == '/') { ++ pid_t pgrp = getpgrp(); + + /* + * Pretend to be requesting user and set non-autofs +@@ -182,7 +190,7 @@ static int do_spawn(unsigned logopt, unsigned int wait, + setpgrp(); + + /* Trigger the recursive mount */ +- if (access(argv[argc], F_OK) == -1) ++ if (access(argv[loc], F_OK) == -1) + _exit(errno); + + seteuid(0); +@@ -312,7 +320,7 @@ int spawn_mount(unsigned logopt, ...) + #ifdef ENABLE_MOUNT_LOCKING + options = SPAWN_OPT_LOCK; + #else +- options = SPAWN_OPT_NONE; ++ options = SPAWN_OPT_ACCESS; + #endif + + va_start(arg, logopt); +@@ -344,12 +352,17 @@ int spawn_mount(unsigned logopt, ...) + p = argv + 2; + } + while ((*p = va_arg(arg, char *))) { +- if (options == SPAWN_OPT_NONE && !strcmp(*p, "-o")) { ++ if (options == SPAWN_OPT_ACCESS && !strcmp(*p, "-t")) { + *(++p) = va_arg(arg, char *); + if (!*p) + break; +- if (strstr(*p, "loop")) +- options = SPAWN_OPT_ACCESS; ++ /* ++ * A cifs mount location begins with a "/" but ++ * is not a local path, so don't try to resolve ++ * it. Mmmm ... does anyone use smbfs these days? ++ */ ++ if (strstr(*p, "cifs")) ++ options = SPAWN_OPT_NONE; + } + p++; + } diff --git a/autofs-5.0.5-dont-fail-mount-on-access-fail.patch b/autofs-5.0.5-dont-fail-mount-on-access-fail.patch new file mode 100644 index 0000000..c67bd25 --- /dev/null +++ b/autofs-5.0.5-dont-fail-mount-on-access-fail.patch @@ -0,0 +1,55 @@ +autofs-5.0.5 - dont fail mount on access fail + +From: Ian Kent + +If we encounter a recursive autofs mount in the mount location +path, and call access(2) to perform the mount, the mount may +succeed but the access(2) call return a fail. In the case where +there are multiple processes waiting on this mount they will all +get the failure return which may be incorrect for other waiters. +Ignoring the return code from the access(2) call and allowing the +mount to go ahead anyway should give the VFS the chance to check +the access for each individual process and so return an accurate +retult. +--- + + CHANGELOG | 1 + + daemon/spawn.c | 12 +++++++++--- + 2 files changed, 10 insertions(+), 3 deletions(-) + + +diff --git a/CHANGELOG b/CHANGELOG +index 8429e20..88bcc1b 100644 +--- a/CHANGELOG ++++ b/CHANGELOG +@@ -14,6 +14,7 @@ + - fix timeout in connect_nb(). + - fix pidof init script usage. + - check for path mount location in generic module. ++- dont fail mount on access fail. + + 03/09/2009 autofs-5.0.5 + ----------------------- +diff --git a/daemon/spawn.c b/daemon/spawn.c +index 7c254d9..285f4d7 100644 +--- a/daemon/spawn.c ++++ b/daemon/spawn.c +@@ -189,9 +189,15 @@ static int do_spawn(unsigned logopt, unsigned int wait, + } + setpgrp(); + +- /* Trigger the recursive mount */ +- if (access(argv[loc], F_OK) == -1) +- _exit(errno); ++ /* ++ * Trigger the recursive mount. ++ * ++ * Ignore the access(2) return code as there may be ++ * multiple waiters for this mount and we need to ++ * let the VFS handle access returns to each ++ * individual waiter. ++ */ ++ access(argv[loc], F_OK); + + seteuid(0); + setegid(0); diff --git a/autofs.spec b/autofs.spec index 63b8cc9..92f0bdf 100644 --- a/autofs.spec +++ b/autofs.spec @@ -23,6 +23,8 @@ Patch10: autofs-5.0.5-dont-use-master_lex_destroy-to-clear-parse-buffer.patch Patch11: autofs-5.0.5-make-documentation-for-set-log-priority-clearer.patch Patch12: autofs-5.0.5-fix-timeout-in-connect_nb.patch Patch13: autofs-5.0.5-fix-pidof-init-script-usage.patch +Patch14: autofs-5.0.5-check-for-path-mount-location-in-generic-module.patch +Patch15: autofs-5.0.5-dont-fail-mount-on-access-fail.patch Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: autoconf, hesiod-devel, openldap-devel, bison, flex, libxml2-devel, cyrus-sasl-devel, openssl-devel module-init-tools util-linux nfs-utils e2fsprogs libtirpc-devel Requires: kernel >= 2.6.17 @@ -77,6 +79,8 @@ echo %{version}-%{release} > .version %patch11 -p1 %patch12 -p1 %patch13 -p1 +%patch14 -p1 +%patch15 -p1 %build #CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=/usr --libdir=%{_libdir} @@ -129,6 +133,10 @@ fi %{_libdir}/autofs/ %changelog +* Mon Nov 30 2009 Ian Kent - 1:5.0.5-12 +- check for path mount location in generic module. +- dont fail mount on access fail. + * Tue Nov 24 2009 Ian Kent - 1:5.0.5-10 - fix pidof init script usage.