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

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