Blob Blame History Raw
autofs-5.1.6 - fix browse dir not re-created on symlink expire

From: Ian Kent <raven@themaw.net>

If symlinks are being used for mounts and the autofs mount has browse mode
enabled when a symlink is removed at expire the browse mode directory needs
to be re-created.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG          |    1 +
 daemon/automount.c |   19 +++++++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/CHANGELOG b/CHANGELOG
index 3c784d34..214ee8bb 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,7 @@ xx/xx/2020 autofs-5.1.7
 - make bind mounts propagation slave by default.
 - update ldap READMEs and schema definitions.
 - fix program map multi-mount lookup after mount fail.
+- fix browse dir not re-created on symlink expire.
 
 07/10/2019 autofs-5.1.6
 - support strictexpire mount option.
diff --git a/daemon/automount.c b/daemon/automount.c
index 8ec4ac5e..0391bfb5 100644
--- a/daemon/automount.c
+++ b/daemon/automount.c
@@ -650,6 +650,25 @@ int umount_multi(struct autofs_point *ap, const char *path, int incl)
 			      "failed to remove symlink %s", path);
 			return 1;
 		}
+		/* Check if the autofs mount has browse mode enabled.
+		 * If so re-create the directory entry.
+		 */
+		if (ap->flags | MOUNT_FLAG_GHOST) {
+			int ret;
+
+			/* If the browse directory create fails log an
+			 * error and continue anyway since the expire
+			 * has succeeded.
+			 */
+			ret = mkdir_path(path, mp_mode);
+			if (ret && errno != EEXIST) {
+				char buf[MAX_ERR_BUF];
+				char *estr;
+				estr = strerror_r(errno, buf, MAX_ERR_BUF);
+				warn(ap->logopt,
+				     "mkdir_path %s failed: %s", path, estr);
+			}
+		}
 		/* Check for an external mount and attempt umount if needed */
 		mounts_mutex_lock(ap);
 		entry = __master_find_amdmount(ap, path);