autofs-5.1.6 - fix remount expire

From: Ian Kent <raven@themaw.net>

When starting autofs when there are active mounts due to in use
mounts from a previous shutdown, and a mount entry has offsets,
and an offset doesn't have a real mount due to a non-strict fail
returning success for the remount a file handle is incorrectly
left open.

The file handle gets assingned to the offset entry for expires
but since there is no mount to expire it never gets closed which
prevents the multi-mount owner itself from expiring.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG    |    1 +
 lib/mounts.c |    8 +++++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG b/CHANGELOG
index 3a073e39..c29fccca 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -60,6 +60,7 @@ xx/xx/2020 autofs-5.1.7
 - use mnt_list for amdmounts.
 - make umount_autofs() static.
 - remove force parameter from umount_all().
+- fix remount expire.
 
 07/10/2019 autofs-5.1.6
 - support strictexpire mount option.
diff --git a/lib/mounts.c b/lib/mounts.c
index 64b911c3..ee78f188 100644
--- a/lib/mounts.c
+++ b/lib/mounts.c
@@ -2205,8 +2205,14 @@ int try_remount(struct autofs_point *ap, struct mapent *me, unsigned int type)
 		if (fd != -1) {
 			if (type == t_indirect)
 				ap->ioctlfd = fd;
-			else
+			else {
+				if (type == t_offset &&
+				    !is_mounted(me->key, MNTS_REAL)) {
+					ops->close(ap->logopt, fd);
+					fd = -1;
+				}
 				me->ioctlfd = fd;
+			}
 			return 1;
 		}
 
