autofs-5.1.7 - clear per-mount timeout if not set

From: Ian Kent <raven@themaw.net>

If the per-mount timeout isn't set in the amd map entry clear it so
that updates that remove the setting are seen.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG           |    1 +
 lib/mounts.c        |    8 +++++++-
 modules/parse_amd.c |   12 ++++++++----
 3 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index f9432181f..ce1e82ae4 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -26,6 +26,7 @@
 - fix remount_active_mount() not remounting symlinks.
 - log when setting amd per-mount timeout.
 - update per-mount expire timeout on readmap.
+- clear per-mount timeout if not set.
 
 02/11/2023 autofs-5.1.9
 - fix kernel mount status notification.
diff --git a/lib/mounts.c b/lib/mounts.c
index 2c28a34b0..0818bc269 100644
--- a/lib/mounts.c
+++ b/lib/mounts.c
@@ -2679,8 +2679,14 @@ void update_mounted_mounts_timeout(struct autofs_point *ap, const char *path)
 			goto next;
 
 		/* No per-mount timeout set? */
-		if (!(mnt->amd_flags & AMD_MOUNT_OPT_MASK))
+		if (!(mnt->amd_flags & AMD_MOUNT_OPT_MASK)) {
+			/* Per-mount timeout setting isn't present, reset to
+			 * be sure updates are seen.
+			 */
+			if (ops)
+				ops->timeout(ap->logopt, ap->ioctlfd, de[n]->d_name, -1);
 			goto next;
+		}
 
 		/* The default in autofs is to always expire mounts according to
 		 * a timeout set in the autofs mount super block information
diff --git a/modules/parse_amd.c b/modules/parse_amd.c
index 83e85f946..f7a0bbb7c 100644
--- a/modules/parse_amd.c
+++ b/modules/parse_amd.c
@@ -1727,10 +1727,16 @@ static int amd_mount(struct autofs_point *ap, const char *name,
 	}
 
 	if (!ret) {
-		struct ioctl_ops *ops;
+		struct ioctl_ops *ops = get_ioctl_ops();
 
-		if (!(per_mnt_flags & AMD_MOUNT_OPT_MASK))
+		if (!(per_mnt_flags & AMD_MOUNT_OPT_MASK)) {
+			/* Per-mount timeout setting isn't present, reset to
+			 * be sure updates are seen.
+			 */
+			if (ops)
+				ops->timeout(ap->logopt, ap->ioctlfd, name, -1);
 			goto done;
+		}
 
 		/* The mount succeeded, make sure there's no path component
 		 * seperator in "name" as it must be the last component of
@@ -1741,8 +1747,6 @@ static int amd_mount(struct autofs_point *ap, const char *name,
 			goto done;
 		}
 
-		ops = get_ioctl_ops();
-
 		/* The default in autofs is to always expire mounts according to
 		 * a timeout set in the autofs mount super block information
 		 * structure. But amd allows for differing expire timeouts on a
