|
|
6bbd11 |
autofs-5.0.8 - use open(2) instead of access(2)
|
|
|
6bbd11 |
|
|
|
6bbd11 |
From: Ian Kent <ikent@redhat.com>
|
|
|
6bbd11 |
|
|
|
6bbd11 |
The access(2) system call has been used to trigger dependednt automounts
|
|
|
6bbd11 |
in the target path when mounting. But access(2) no longer triggers the
|
|
|
6bbd11 |
dependednt mounts.
|
|
|
6bbd11 |
|
|
|
6bbd11 |
So use open(2) with flag O_DIRECTORY which will trigger these mounts.
|
|
|
6bbd11 |
---
|
|
|
6bbd11 |
CHANGELOG | 1 +
|
|
|
6bbd11 |
daemon/spawn.c | 30 ++++++++++++++++++------------
|
|
|
6bbd11 |
2 files changed, 19 insertions(+), 12 deletions(-)
|
|
|
6bbd11 |
|
|
|
6bbd11 |
--- autofs-5.0.7.orig/CHANGELOG
|
|
|
6bbd11 |
+++ autofs-5.0.7/CHANGELOG
|
|
|
6bbd11 |
@@ -104,6 +104,7 @@
|
|
|
6bbd11 |
- fix variable substitution description.
|
|
|
6bbd11 |
- fix incorrect append options description in README.v5-release.
|
|
|
6bbd11 |
- fix mistake in assignment.
|
|
|
6bbd11 |
+- use open(2) instead of access(2) to trigger dependent mounts.
|
|
|
6bbd11 |
|
|
|
6bbd11 |
25/07/2012 autofs-5.0.7
|
|
|
6bbd11 |
=======================
|
|
|
6bbd11 |
--- autofs-5.0.7.orig/daemon/spawn.c
|
|
|
6bbd11 |
+++ autofs-5.0.7/daemon/spawn.c
|
|
|
6bbd11 |
@@ -32,7 +32,7 @@ static pthread_mutex_t spawn_mutex = PTH
|
|
|
6bbd11 |
|
|
|
6bbd11 |
#define SPAWN_OPT_NONE 0x0000
|
|
|
6bbd11 |
#define SPAWN_OPT_LOCK 0x0001
|
|
|
6bbd11 |
-#define SPAWN_OPT_ACCESS 0x0002
|
|
|
6bbd11 |
+#define SPAWN_OPT_OPEN 0x0002
|
|
|
6bbd11 |
|
|
|
6bbd11 |
#define MTAB_LOCK_RETRIES 3
|
|
|
6bbd11 |
|
|
|
6bbd11 |
@@ -126,7 +126,7 @@ static int do_spawn(unsigned logopt, uns
|
|
|
6bbd11 |
int errp, errn;
|
|
|
6bbd11 |
int cancel_state;
|
|
|
6bbd11 |
unsigned int use_lock = options & SPAWN_OPT_LOCK;
|
|
|
6bbd11 |
- unsigned int use_access = options & SPAWN_OPT_ACCESS;
|
|
|
6bbd11 |
+ unsigned int use_open = options & SPAWN_OPT_OPEN;
|
|
|
6bbd11 |
sigset_t allsigs, tmpsig, oldsig;
|
|
|
6bbd11 |
struct thread_stdenv_vars *tsv;
|
|
|
6bbd11 |
pid_t euid = 0;
|
|
|
6bbd11 |
@@ -166,6 +166,8 @@ static int do_spawn(unsigned logopt, uns
|
|
|
6bbd11 |
/* what to mount must always be second last */
|
|
|
6bbd11 |
while (*pargv++)
|
|
|
6bbd11 |
loc++;
|
|
|
6bbd11 |
+ if (loc <= 3)
|
|
|
6bbd11 |
+ goto done;
|
|
|
6bbd11 |
loc -= 2;
|
|
|
6bbd11 |
|
|
|
6bbd11 |
/*
|
|
|
6bbd11 |
@@ -176,7 +178,9 @@ static int do_spawn(unsigned logopt, uns
|
|
|
6bbd11 |
*
|
|
|
6bbd11 |
* I hope host names are never allowed "/" as first char
|
|
|
6bbd11 |
*/
|
|
|
6bbd11 |
- if (use_access && *(argv[loc]) == '/') {
|
|
|
6bbd11 |
+ if (use_open && *(argv[loc]) == '/') {
|
|
|
6bbd11 |
+ int fd;
|
|
|
6bbd11 |
+
|
|
|
6bbd11 |
pid_t pgrp = getpgrp();
|
|
|
6bbd11 |
|
|
|
6bbd11 |
/*
|
|
|
6bbd11 |
@@ -192,19 +196,21 @@ static int do_spawn(unsigned logopt, uns
|
|
|
6bbd11 |
/*
|
|
|
6bbd11 |
* Trigger the recursive mount.
|
|
|
6bbd11 |
*
|
|
|
6bbd11 |
- * Ignore the access(2) return code as there may be
|
|
|
6bbd11 |
+ * Ignore the open(2) return code as there may be
|
|
|
6bbd11 |
* multiple waiters for this mount and we need to
|
|
|
6bbd11 |
- * let the VFS handle access returns to each
|
|
|
6bbd11 |
- * individual waiter.
|
|
|
6bbd11 |
+ * let the VFS handle returns to each individual
|
|
|
6bbd11 |
+ * waiter.
|
|
|
6bbd11 |
*/
|
|
|
6bbd11 |
- access(argv[loc], F_OK);
|
|
|
6bbd11 |
+ fd = open(argv[loc], O_DIRECTORY);
|
|
|
6bbd11 |
+ if (fd != -1)
|
|
|
6bbd11 |
+ close(fd);
|
|
|
6bbd11 |
|
|
|
6bbd11 |
seteuid(0);
|
|
|
6bbd11 |
setegid(0);
|
|
|
6bbd11 |
if (pgrp >= 0)
|
|
|
6bbd11 |
setpgid(0, pgrp);
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
-
|
|
|
6bbd11 |
+done:
|
|
|
6bbd11 |
execv(prog, (char *const *) argv);
|
|
|
6bbd11 |
_exit(255); /* execv() failed */
|
|
|
6bbd11 |
} else {
|
|
|
6bbd11 |
@@ -327,7 +333,7 @@ int spawn_mount(unsigned logopt, ...)
|
|
|
6bbd11 |
#ifdef ENABLE_MOUNT_LOCKING
|
|
|
6bbd11 |
options = SPAWN_OPT_LOCK;
|
|
|
6bbd11 |
#else
|
|
|
6bbd11 |
- options = SPAWN_OPT_ACCESS;
|
|
|
6bbd11 |
+ options = SPAWN_OPT_OPEN;
|
|
|
6bbd11 |
#endif
|
|
|
6bbd11 |
|
|
|
6bbd11 |
va_start(arg, logopt);
|
|
|
6bbd11 |
@@ -360,7 +366,7 @@ int spawn_mount(unsigned logopt, ...)
|
|
|
6bbd11 |
p = argv + 2;
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
while ((*p = va_arg(arg, char *))) {
|
|
|
6bbd11 |
- if (options == SPAWN_OPT_ACCESS && !strcmp(*p, "-t")) {
|
|
|
6bbd11 |
+ if (options == SPAWN_OPT_OPEN && !strcmp(*p, "-t")) {
|
|
|
6bbd11 |
*(++p) = va_arg(arg, char *);
|
|
|
6bbd11 |
if (!*p)
|
|
|
6bbd11 |
break;
|
|
|
6bbd11 |
@@ -429,7 +435,7 @@ int spawn_mount(unsigned logopt, ...)
|
|
|
6bbd11 |
|
|
|
6bbd11 |
/*
|
|
|
6bbd11 |
* For bind mounts that depend on the target being mounted (possibly
|
|
|
6bbd11 |
- * itself an automount) we attempt to mount the target using an access
|
|
|
6bbd11 |
+ * itself an automount) we attempt to mount the target using an open(2)
|
|
|
6bbd11 |
* call. For this to work the location must be the second last arg.
|
|
|
6bbd11 |
*
|
|
|
6bbd11 |
* NOTE: If mount locking is enabled this type of recursive mount cannot
|
|
|
6bbd11 |
@@ -455,7 +461,7 @@ int spawn_bind_mount(unsigned logopt, ..
|
|
|
6bbd11 |
#ifdef ENABLE_MOUNT_LOCKING
|
|
|
6bbd11 |
options = SPAWN_OPT_LOCK;
|
|
|
6bbd11 |
#else
|
|
|
6bbd11 |
- options = SPAWN_OPT_ACCESS;
|
|
|
6bbd11 |
+ options = SPAWN_OPT_OPEN;
|
|
|
6bbd11 |
#endif
|
|
|
6bbd11 |
|
|
|
6bbd11 |
/*
|