File autofs-5.0.3-fix-rootless-direct-multi-mount-expire.patch of Package autofs5
autofs-5.0.3 - don't close direct root
From: Ian Kent <raven@themaw.net>
For direct mount multi-mounts with no real mount at their base we
need to leave the file handle open so they will be expired. This
patch corrects the check done at mount completion to do this so
they will be expired.
---
CHANGELOG | 1 +
daemon/direct.c | 13 +++++++++++--
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/daemon/direct.c b/daemon/direct.c
index b94601a..5b02dcf 100644
--- a/daemon/direct.c
+++ b/daemon/direct.c
@@ -1311,8 +1311,17 @@ static void *do_mount_direct(void *arg)
!master_find_submount(ap, mt.name)))
close_fd = 1;
cache_writelock(mt.mc);
- if (!close_fd && (me = cache_lookup_distinct(mt.mc, mt.name)))
- me->ioctlfd = mt.ioctlfd;
+ if ((me = cache_lookup_distinct(mt.mc, mt.name))) {
+ /*
+ * Careful here, we need to leave the file handle open
+ * for direct mount multi-mounts with no real mount at
+ * their base so they will be expired.
+ */
+ if (close_fd && me == me->multi)
+ close_fd = 0;
+ if (!close_fd)
+ me->ioctlfd = mt.ioctlfd;
+ }
send_ready(ap->logopt, mt.ioctlfd, mt.wait_queue_token);
cache_unlock(mt.mc);
if (close_fd)