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++; }