|
Ian Kent |
957595 |
autofs-5.0.5 - check for path mount location in generic module
|
|
Ian Kent |
957595 |
|
|
Ian Kent |
957595 |
From: Ian Kent <raven@themaw.net>
|
|
Ian Kent |
957595 |
|
|
Ian Kent |
957595 |
Currently we check for dependent mounts in the mount location path
|
|
Ian Kent |
957595 |
for bind mounts and loopback mounts. But we can have the case where
|
|
Ian Kent |
957595 |
a mount other than a loopback mount uses a local path and is not a
|
|
Ian Kent |
957595 |
bind mount. In this case we need to check the local path for dependent
|
|
Ian Kent |
957595 |
mounts. To do this we can check the mount location prior to spawning
|
|
Ian Kent |
957595 |
the mount and if it starts with a "/" then it is a local path and
|
|
Ian Kent |
957595 |
the check is needed.
|
|
Ian Kent |
957595 |
---
|
|
Ian Kent |
957595 |
|
|
Ian Kent |
957595 |
CHANGELOG | 1 +
|
|
Ian Kent |
957595 |
daemon/spawn.c | 41 +++++++++++++++++++++++++++--------------
|
|
Ian Kent |
957595 |
2 files changed, 28 insertions(+), 14 deletions(-)
|
|
Ian Kent |
957595 |
|
|
Ian Kent |
957595 |
|
|
Ian Kent |
957595 |
diff --git a/CHANGELOG b/CHANGELOG
|
|
Ian Kent |
957595 |
index cc2efab..8429e20 100644
|
|
Ian Kent |
957595 |
--- a/CHANGELOG
|
|
Ian Kent |
957595 |
+++ b/CHANGELOG
|
|
Ian Kent |
957595 |
@@ -13,6 +13,7 @@
|
|
Ian Kent |
957595 |
- make documentation for set-log-priority clearer.
|
|
Ian Kent |
957595 |
- fix timeout in connect_nb().
|
|
Ian Kent |
957595 |
- fix pidof init script usage.
|
|
Ian Kent |
957595 |
+- check for path mount location in generic module.
|
|
Ian Kent |
957595 |
|
|
Ian Kent |
957595 |
03/09/2009 autofs-5.0.5
|
|
Ian Kent |
957595 |
-----------------------
|
|
Ian Kent |
957595 |
diff --git a/daemon/spawn.c b/daemon/spawn.c
|
|
Ian Kent |
957595 |
index db356d4..7c254d9 100644
|
|
Ian Kent |
957595 |
--- a/daemon/spawn.c
|
|
Ian Kent |
957595 |
+++ b/daemon/spawn.c
|
|
Ian Kent |
957595 |
@@ -154,22 +154,30 @@ static int do_spawn(unsigned logopt, unsigned int wait,
|
|
Ian Kent |
957595 |
|
|
Ian Kent |
957595 |
f = fork();
|
|
Ian Kent |
957595 |
if (f == 0) {
|
|
Ian Kent |
957595 |
+ char **pargv = (char **) argv;
|
|
Ian Kent |
957595 |
+ int loc = 0;
|
|
Ian Kent |
957595 |
+
|
|
Ian Kent |
957595 |
reset_signals();
|
|
Ian Kent |
957595 |
close(pipefd[0]);
|
|
Ian Kent |
957595 |
dup2(pipefd[1], STDOUT_FILENO);
|
|
Ian Kent |
957595 |
dup2(pipefd[1], STDERR_FILENO);
|
|
Ian Kent |
957595 |
close(pipefd[1]);
|
|
Ian Kent |
957595 |
|
|
Ian Kent |
957595 |
- /* Bind mount - check target exists */
|
|
Ian Kent |
957595 |
- if (use_access) {
|
|
Ian Kent |
957595 |
- char **pargv = (char **) argv;
|
|
Ian Kent |
957595 |
- int argc = 0;
|
|
Ian Kent |
957595 |
- pid_t pgrp = getpgrp();
|
|
Ian Kent |
957595 |
+ /* what to mount must always be second last */
|
|
Ian Kent |
957595 |
+ while (*pargv++)
|
|
Ian Kent |
957595 |
+ loc++;
|
|
Ian Kent |
957595 |
+ loc -= 2;
|
|
Ian Kent |
957595 |
|
|
Ian Kent |
957595 |
- /* what to mount must always be second last */
|
|
Ian Kent |
957595 |
- while (*pargv++)
|
|
Ian Kent |
957595 |
- argc++;
|
|
Ian Kent |
957595 |
- argc -= 2;
|
|
Ian Kent |
957595 |
+ /*
|
|
Ian Kent |
957595 |
+ * If the mount location starts with a "/" then it is
|
|
Ian Kent |
957595 |
+ * a local path. In this case it is a bind mount, a
|
|
Ian Kent |
957595 |
+ * loopback mount or a file system that uses a local
|
|
Ian Kent |
957595 |
+ * path so we need to check for dependent mounts.
|
|
Ian Kent |
957595 |
+ *
|
|
Ian Kent |
957595 |
+ * I hope host names are never allowed "/" as first char
|
|
Ian Kent |
957595 |
+ */
|
|
Ian Kent |
957595 |
+ if (use_access && *(argv[loc]) == '/') {
|
|
Ian Kent |
957595 |
+ pid_t pgrp = getpgrp();
|
|
Ian Kent |
957595 |
|
|
Ian Kent |
957595 |
/*
|
|
Ian Kent |
957595 |
* Pretend to be requesting user and set non-autofs
|
|
Ian Kent |
957595 |
@@ -182,7 +190,7 @@ static int do_spawn(unsigned logopt, unsigned int wait,
|
|
Ian Kent |
957595 |
setpgrp();
|
|
Ian Kent |
957595 |
|
|
Ian Kent |
957595 |
/* Trigger the recursive mount */
|
|
Ian Kent |
957595 |
- if (access(argv[argc], F_OK) == -1)
|
|
Ian Kent |
957595 |
+ if (access(argv[loc], F_OK) == -1)
|
|
Ian Kent |
957595 |
_exit(errno);
|
|
Ian Kent |
957595 |
|
|
Ian Kent |
957595 |
seteuid(0);
|
|
Ian Kent |
957595 |
@@ -312,7 +320,7 @@ int spawn_mount(unsigned logopt, ...)
|
|
Ian Kent |
957595 |
#ifdef ENABLE_MOUNT_LOCKING
|
|
Ian Kent |
957595 |
options = SPAWN_OPT_LOCK;
|
|
Ian Kent |
957595 |
#else
|
|
Ian Kent |
957595 |
- options = SPAWN_OPT_NONE;
|
|
Ian Kent |
957595 |
+ options = SPAWN_OPT_ACCESS;
|
|
Ian Kent |
957595 |
#endif
|
|
Ian Kent |
957595 |
|
|
Ian Kent |
957595 |
va_start(arg, logopt);
|
|
Ian Kent |
957595 |
@@ -344,12 +352,17 @@ int spawn_mount(unsigned logopt, ...)
|
|
Ian Kent |
957595 |
p = argv + 2;
|
|
Ian Kent |
957595 |
}
|
|
Ian Kent |
957595 |
while ((*p = va_arg(arg, char *))) {
|
|
Ian Kent |
957595 |
- if (options == SPAWN_OPT_NONE && !strcmp(*p, "-o")) {
|
|
Ian Kent |
957595 |
+ if (options == SPAWN_OPT_ACCESS && !strcmp(*p, "-t")) {
|
|
Ian Kent |
957595 |
*(++p) = va_arg(arg, char *);
|
|
Ian Kent |
957595 |
if (!*p)
|
|
Ian Kent |
957595 |
break;
|
|
Ian Kent |
957595 |
- if (strstr(*p, "loop"))
|
|
Ian Kent |
957595 |
- options = SPAWN_OPT_ACCESS;
|
|
Ian Kent |
957595 |
+ /*
|
|
Ian Kent |
957595 |
+ * A cifs mount location begins with a "/" but
|
|
Ian Kent |
957595 |
+ * is not a local path, so don't try to resolve
|
|
Ian Kent |
957595 |
+ * it. Mmmm ... does anyone use smbfs these days?
|
|
Ian Kent |
957595 |
+ */
|
|
Ian Kent |
957595 |
+ if (strstr(*p, "cifs"))
|
|
Ian Kent |
957595 |
+ options = SPAWN_OPT_NONE;
|
|
Ian Kent |
957595 |
}
|
|
Ian Kent |
957595 |
p++;
|
|
Ian Kent |
957595 |
}
|