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

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