Blame SOURCES/autofs-5.1.7-fix-amd-section-mounts-map-reload.patch

29d2b9
autofs-5.1.7 - fix amd section mounts map reload
29d2b9
29d2b9
From: Ian Kent <raven@themaw.net>
29d2b9
29d2b9
Master map section mounts (amd format mounts) get umounted on reload.
29d2b9
29d2b9
Signed-off-by: Ian Kent <raven@themaw.net>
29d2b9
---
29d2b9
 CHANGELOG       |    1 
29d2b9
 daemon/master.c |   81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
29d2b9
 2 files changed, 81 insertions(+), 1 deletion(-)
29d2b9
29d2b9
--- autofs-5.1.7.orig/CHANGELOG
29d2b9
+++ autofs-5.1.7/CHANGELOG
29d2b9
@@ -67,6 +67,7 @@
29d2b9
 - cater for empty mounts list in mnts_get_expire_list().
29d2b9
 - add ext_mount_hash_mutex lock helpers.
29d2b9
 - fix dangling symlink creation if nis support is not available.
29d2b9
+- fix amd section mounts map reload.
29d2b9
 
29d2b9
 25/01/2021 autofs-5.1.7
29d2b9
 - make bind mounts propagation slave by default.
29d2b9
--- autofs-5.1.7.orig/daemon/master.c
29d2b9
+++ autofs-5.1.7/daemon/master.c
29d2b9
@@ -882,6 +882,83 @@ struct master *master_new(const char *na
29d2b9
 	return master;
29d2b9
 }
29d2b9
 
29d2b9
+static void master_update_amd_mount_section_mount(struct master *master,
29d2b9
+						  const char *path, time_t age)
29d2b9
+{
29d2b9
+	unsigned int m_logopt = master->logopt;
29d2b9
+	struct master_mapent *entry;
29d2b9
+	struct map_source *source;
29d2b9
+	unsigned int loglevel;
29d2b9
+	unsigned int logopt;
29d2b9
+	unsigned int flags;
29d2b9
+	time_t timeout;
29d2b9
+	char *map;
29d2b9
+	char *opts;
29d2b9
+
29d2b9
+	entry = master_find_mapent(master, path);
29d2b9
+	if (!entry)
29d2b9
+		return;
29d2b9
+
29d2b9
+	map = conf_amd_get_map_name(path);
29d2b9
+	if (!map)
29d2b9
+		return;
29d2b9
+
29d2b9
+	/* amd top level mounts have only one map */
29d2b9
+	source = entry->maps;
29d2b9
+	if (strcmp(source->name, map) != 0) {
29d2b9
+		struct map_source *new;
29d2b9
+		char *type;
29d2b9
+		char *argv[2];
29d2b9
+
29d2b9
+		type = conf_amd_get_map_type(path);
29d2b9
+		argv[0] = map;
29d2b9
+		argv[1] = NULL;
29d2b9
+
29d2b9
+		new = master_add_map_source(entry, type, "amd",
29d2b9
+					    age, 1, (const char **) argv);
29d2b9
+		if (!new) {
29d2b9
+			error(m_logopt,
29d2b9
+			      "failed to add source for amd section mount %s",
29d2b9
+			      path);
29d2b9
+			if (type)
29d2b9
+				free(type);
29d2b9
+			goto out;
29d2b9
+		}
29d2b9
+		master_free_map_source(source, 0);
29d2b9
+		entry->maps = new;
29d2b9
+		source = new;
29d2b9
+		if (type)
29d2b9
+			free(type);
29d2b9
+	}
29d2b9
+
29d2b9
+	loglevel = conf_amd_get_log_options();
29d2b9
+	logopt = m_logopt;
29d2b9
+	if (loglevel <= LOG_DEBUG && loglevel > LOG_INFO)
29d2b9
+		logopt = LOGOPT_DEBUG;
29d2b9
+	else if (loglevel <= LOG_INFO && loglevel > LOG_ERR)
29d2b9
+		logopt = LOGOPT_VERBOSE;
29d2b9
+
29d2b9
+	flags = conf_amd_get_flags(path);
29d2b9
+	if (flags & CONF_BROWSABLE_DIRS)
29d2b9
+		entry->ap->flags |= MOUNT_FLAG_GHOST;
29d2b9
+
29d2b9
+	opts = conf_amd_get_map_options(path);
29d2b9
+	if (opts) {
29d2b9
+		if (strstr(opts, "cache:=all"))
29d2b9
+			entry->ap->flags |= MOUNT_FLAG_AMD_CACHE_ALL;
29d2b9
+		free(opts);
29d2b9
+	}
29d2b9
+
29d2b9
+	entry->ap->logopt = logopt;
29d2b9
+
29d2b9
+	timeout = conf_amd_get_dismount_interval(path);
29d2b9
+	set_exp_timeout(entry->ap, source, timeout);
29d2b9
+	source->master_line = 0;
29d2b9
+	entry->age = age;
29d2b9
+out:
29d2b9
+	free(map);
29d2b9
+}
29d2b9
+
29d2b9
 static void master_add_amd_mount_section_mounts(struct master *master, time_t age)
29d2b9
 {
29d2b9
 	unsigned int m_logopt = master->logopt;
29d2b9
@@ -916,8 +993,10 @@ static void master_add_amd_mount_section
29d2b9
 			 * master map it's not a duplicate, don't issue
29d2b9
 			 * an error message.
29d2b9
 			 */
29d2b9
-			if (ret == 1)
29d2b9
+			if (ret == 1) {
29d2b9
+				master_update_amd_mount_section_mount(master, path, age);
29d2b9
 				goto next;
29d2b9
+			}
29d2b9
 			info(m_logopt,
29d2b9
 			     "amd section mount path conflict, %s ignored",
29d2b9
 			     path);