|
|
4d476f |
autofs-5.0.9 - amd lookup fix lofs mounting
|
|
|
4d476f |
|
|
|
4d476f |
From: Ian Kent <raven@themaw.net>
|
|
|
4d476f |
|
|
|
4d476f |
The kernel leaves mount type autofs alone because they are supposed
|
|
|
4d476f |
to be autofs sub-mounts and they look after their own expiration. So
|
|
|
4d476f |
mounts bound to an autofs submount won't ever be expired.
|
|
|
4d476f |
---
|
|
|
4d476f |
daemon/spawn.c | 42 ++++++++++++++++++++++++++++++++++++++----
|
|
|
4d476f |
1 file changed, 38 insertions(+), 4 deletions(-)
|
|
|
4d476f |
|
|
|
4d476f |
diff --git a/daemon/spawn.c b/daemon/spawn.c
|
|
|
4d476f |
index a6c8c34..bfb8cfc 100644
|
|
|
4d476f |
--- a/daemon/spawn.c
|
|
|
4d476f |
+++ b/daemon/spawn.c
|
|
|
4d476f |
@@ -111,6 +111,12 @@ static int timed_read(int pipe, char *buf, size_t len, int time)
|
|
|
4d476f |
return ret;
|
|
|
4d476f |
}
|
|
|
4d476f |
|
|
|
4d476f |
+ if (pfd[0].fd == -1)
|
|
|
4d476f |
+ return 0;
|
|
|
4d476f |
+
|
|
|
4d476f |
+ if ((pfd[0].revents & (POLLIN|POLLHUP)) == POLLHUP)
|
|
|
4d476f |
+ return 0;
|
|
|
4d476f |
+
|
|
|
4d476f |
while ((ret = read(pipe, buf, len)) == -1 && errno == EINTR);
|
|
|
4d476f |
|
|
|
4d476f |
return ret;
|
|
|
4d476f |
@@ -179,7 +185,8 @@ static int do_spawn(unsigned logopt, unsigned int wait,
|
|
|
4d476f |
* I hope host names are never allowed "/" as first char
|
|
|
4d476f |
*/
|
|
|
4d476f |
if (use_open && *(argv[loc]) == '/') {
|
|
|
4d476f |
- int fd;
|
|
|
4d476f |
+ char **p;
|
|
|
4d476f |
+ int is_bind, fd;
|
|
|
4d476f |
|
|
|
4d476f |
pid_t pgrp = getpgrp();
|
|
|
4d476f |
|
|
|
4d476f |
@@ -209,6 +216,33 @@ static int do_spawn(unsigned logopt, unsigned int wait,
|
|
|
4d476f |
setegid(0);
|
|
|
4d476f |
if (pgrp >= 0)
|
|
|
4d476f |
setpgid(0, pgrp);
|
|
|
4d476f |
+
|
|
|
4d476f |
+ /*
|
|
|
4d476f |
+ * The kernel leaves mount type autofs alone because
|
|
|
4d476f |
+ * they are supposed to be autofs sub-mounts and they
|
|
|
4d476f |
+ * look after their own expiration. So mounts bound
|
|
|
4d476f |
+ * to an autofs submount won't ever be expired.
|
|
|
4d476f |
+ */
|
|
|
4d476f |
+ is_bind = 0;
|
|
|
4d476f |
+ p = (char **) argv;
|
|
|
4d476f |
+ while (*p) {
|
|
|
4d476f |
+ if (strcmp(*p, "--bind")) {
|
|
|
4d476f |
+ p++;
|
|
|
4d476f |
+ continue;
|
|
|
4d476f |
+ }
|
|
|
4d476f |
+ is_bind = 1;
|
|
|
4d476f |
+ break;
|
|
|
4d476f |
+ }
|
|
|
4d476f |
+ if (!is_bind)
|
|
|
4d476f |
+ goto done;
|
|
|
4d476f |
+
|
|
|
4d476f |
+ if (is_mounted(_PROC_MOUNTS, argv[loc], MNTS_AUTOFS)) {
|
|
|
4d476f |
+ fprintf(stderr,
|
|
|
4d476f |
+ "error: can't bind to an autofs mount\n");
|
|
|
4d476f |
+ close(STDOUT_FILENO);
|
|
|
4d476f |
+ close(STDERR_FILENO);
|
|
|
4d476f |
+ _exit(EINVAL);
|
|
|
4d476f |
+ }
|
|
|
4d476f |
}
|
|
|
4d476f |
done:
|
|
|
4d476f |
execv(prog, (char *const *) argv);
|
|
|
4d476f |
@@ -384,7 +418,7 @@ int spawn_mount(unsigned logopt, ...)
|
|
|
4d476f |
|
|
|
4d476f |
while (retries--) {
|
|
|
4d476f |
ret = do_spawn(logopt, wait, options, prog, (const char **) argv);
|
|
|
4d476f |
- if (ret & MTAB_NOTUPDATED) {
|
|
|
4d476f |
+ if (ret == MTAB_NOTUPDATED) {
|
|
|
4d476f |
struct timespec tm = {3, 0};
|
|
|
4d476f |
|
|
|
4d476f |
/*
|
|
|
4d476f |
@@ -502,7 +536,7 @@ int spawn_bind_mount(unsigned logopt, ...)
|
|
|
4d476f |
|
|
|
4d476f |
while (retries--) {
|
|
|
4d476f |
ret = do_spawn(logopt, -1, options, prog, (const char **) argv);
|
|
|
4d476f |
- if (ret & MTAB_NOTUPDATED) {
|
|
|
4d476f |
+ if (ret == MTAB_NOTUPDATED) {
|
|
|
4d476f |
struct timespec tm = {3, 0};
|
|
|
4d476f |
|
|
|
4d476f |
/*
|
|
|
4d476f |
@@ -604,7 +638,7 @@ int spawn_umount(unsigned logopt, ...)
|
|
|
4d476f |
|
|
|
4d476f |
while (retries--) {
|
|
|
4d476f |
ret = do_spawn(logopt, wait, options, prog, (const char **) argv);
|
|
|
4d476f |
- if (ret & MTAB_NOTUPDATED) {
|
|
|
4d476f |
+ if (ret == MTAB_NOTUPDATED) {
|
|
|
4d476f |
/*
|
|
|
4d476f |
* If the mount succeeded but the mtab was not
|
|
|
4d476f |
* updated, then retry the umount just to update
|