Blame SOURCES/autofs-5.1.2-include-amd-mount-section-mounts-in-master-mounts-list.patch

306fa1
autofs-5.1.2 - include amd mount section mounts in master mounts list
306fa1
306fa1
From: Ian Kent <raven@themaw.net>
306fa1
306fa1
Currently a master map entry is required for amd format maps and
306fa1
top level amd mount path configuration sections can only used to
306fa1
provide additional per-mount configuration.
306fa1
306fa1
But being able to use the top level amd format mount path
306fa1
configuration sections alone allows potentially incompatible
306fa1
master map entries to not be included in the master map.
306fa1
306fa1
Signed-off-by: Ian Kent <raven@themaw.net>
306fa1
---
306fa1
 CHANGELOG       |    1 
306fa1
 README.amd-maps |   49 +++++++++++++++++++++----
306fa1
 lib/master.c    |  109 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
306fa1
 3 files changed, 152 insertions(+), 7 deletions(-)
306fa1
306fa1
--- autofs-5.0.7.orig/CHANGELOG
306fa1
+++ autofs-5.0.7/CHANGELOG
306fa1
@@ -227,6 +227,7 @@
306fa1
 - add support for amd browsable option.
306fa1
 - add function conf_amd_get_map_name().
306fa1
 - add function conf_amd_get_mount_paths().
306fa1
+- include amd mount sections mounts in master mounts list.
306fa1
 
306fa1
 25/07/2012 autofs-5.0.7
306fa1
 =======================
306fa1
--- autofs-5.0.7.orig/README.amd-maps
306fa1
+++ autofs-5.0.7/README.amd-maps
306fa1
@@ -9,8 +9,10 @@ How to use amd maps in autofs
306fa1
 
306fa1
 To add amd map parsing to autofs a new "format" module has been added.
306fa1
 
306fa1
-To use this new map format module the existing master map syntax is
306fa1
-used as described below.
306fa1
+There are two ways to use this new map format module. First, the existing
306fa1
+master map syntax can be used as described below, and second, sections that
306fa1
+use the top level mount path may be added to the autofs configuration below
306fa1
+the "amd" section in much the same way as is done with amd.
306fa1
 
306fa1
 The master map entry syntax is:
306fa1
 
306fa1
@@ -21,8 +23,22 @@ For amd format maps this becomes:
306fa1
 /amd/mp   file,amd:amd.mp
306fa1
 
306fa1
 which will use file as the map source and the amd format parser for
306fa1
-the map. But see the section below on configuration for how to
306fa1
-eliminate the need to specify "map-type,format" in the master map.
306fa1
+the map.
306fa1
+
306fa1
+In order to use nsswitch to specify the map source an amd per-mount
306fa1
+section needs to be added to the autofs configuration so autofs
306fa1
+knows the master map entry is an amd format mount.
306fa1
+
306fa1
+If an amd-per-mount section is added to the autofs configuration a
306fa1
+corresponding master map entry is optional. If both are present the
306fa1
+map name given in the master map entry will override a "map_name"
306fa1
+option in the amd per-mount section.
306fa1
+
306fa1
+If an amd per-mount section is used alone then not giving the "map_type"
306fa1
+option will alow the use of nsswicth for map selection.
306fa1
+
306fa1
+See below for an example of an amd per-mount configuration entry.
306fa1
+
306fa1
 
306fa1
 Configuration sub-system changes
306fa1
 --------------------------------
306fa1
@@ -56,12 +72,19 @@ avoid the need to specify the "type,form
306fa1
 entry. This allows them to use the nsswitch map source functionality
306fa1
 in the same way autofs master map entries do.
306fa1
 
306fa1
+If amd per-mount sections are present in the autofs configuration
306fa1
+their corresponding master map entries are optional. This allows
306fa1
+amd maps to be used without adding incompatible entries to the autofs
306fa1
+master map in shared infrastructure environments.
306fa1
+
306fa1
 If a section for an amd mount is added below the global amd section
306fa1
 using the mount point path (as is done in amd.conf) then autofs will
306fa1
 know the map format is amd (it doesn't matter if there are no other
306fa1
-configuration options in the mount point section). Since the map must
306fa1
-be given in the master map entry the map_name option is not mandatory
306fa1
-as it is in amd and will no be used.
306fa1
+configuration options in the mount point section).
306fa1
+
306fa1
+If there is a corresponding master map entry the map given in the
306fa1
+master map entry will be used over the map_name option if it is
306fa1
+present in an amd per-mount section.
306fa1
 
306fa1
 If a mount point is present in the master map and the source of the
306fa1
 map is nis then it is sufficient to use (for example):
306fa1
@@ -86,6 +109,18 @@ or
306fa1
 [ /amd/mp ]
306fa1
 map_type = nis
306fa1
 
306fa1
+An example of an amd per-mount configuration entry is:
306fa1
+
306fa1
+[ amd ]
306fa1
+...
306fa1
+
306fa1
+[ /test ]
306fa1
+map_name = /etc/amd.test
306fa1
+#map_type = file
306fa1
+#search_path =			/etc
306fa1
+#browsable_dirs =		yes | no
306fa1
+browsable_dirs =		yes
306fa1
+
306fa1
 
306fa1
 amd map options that can be used
306fa1
 --------------------------------
306fa1
--- autofs-5.0.7.orig/lib/master.c
306fa1
+++ autofs-5.0.7/lib/master.c
306fa1
@@ -910,6 +910,114 @@ struct master *master_new(const char *na
306fa1
 	return master;
306fa1
 }
306fa1
 
306fa1
+static void master_add_amd_mount_section_mounts(struct master *master, time_t age)
306fa1
+{
306fa1
+	unsigned int m_logopt = master->logopt;
306fa1
+	struct master_mapent *entry;
306fa1
+	struct map_source *source;
306fa1
+	unsigned int loglevel;
306fa1
+	unsigned int logopt;
306fa1
+	unsigned int flags;
306fa1
+	char *argv[2];
306fa1
+	char **paths;
306fa1
+	int ret;
306fa1
+	int i;
306fa1
+
306fa1
+	loglevel = conf_amd_get_log_options();
306fa1
+
306fa1
+	paths = conf_amd_get_mount_paths();
306fa1
+	if (!paths)
306fa1
+		return;
306fa1
+
306fa1
+	i = 0;
306fa1
+	while (paths[i]) {
306fa1
+		const char *path = paths[i];
306fa1
+		unsigned int ghost = 0;
306fa1
+		char *type = NULL;
306fa1
+		char *map = NULL;
306fa1
+
306fa1
+		entry = master_find_mapent(master, path);
306fa1
+		if (entry) {
306fa1
+			info(m_logopt,
306fa1
+			     "ignoring duplicate amd section mount %s",
306fa1
+			     path);
306fa1
+			goto next;
306fa1
+		}
306fa1
+
306fa1
+		map = conf_amd_get_map_name(path);
306fa1
+		if (!map) {
306fa1
+			error(m_logopt,
306fa1
+			      "failed to get map name for amd section mount %s",
306fa1
+			      path);
306fa1
+			goto next;
306fa1
+		}
306fa1
+
306fa1
+		entry = master_new_mapent(master, path, age);
306fa1
+		if (!entry) {
306fa1
+			error(m_logopt,
306fa1
+			      "failed to allocate new amd section mount %s",
306fa1
+			      path);
306fa1
+			goto next;
306fa1
+		}
306fa1
+
306fa1
+		logopt = m_logopt;
306fa1
+		if (loglevel <= LOG_DEBUG && loglevel > LOG_INFO)
306fa1
+			logopt = LOGOPT_DEBUG;
306fa1
+		else if (loglevel <= LOG_INFO && loglevel > LOG_ERR)
306fa1
+			logopt = LOGOPT_VERBOSE;
306fa1
+
306fa1
+		/* It isn't possible to provide the fullybrowsable amd
306fa1
+		 * browsing functionality within the autofs framework.
306fa1
+		 * This flag will not be set if browsable_dirs = full
306fa1
+		 * in the configuration or fullybrowsable is present as
306fa1
+		 * an option.
306fa1
+		 */
306fa1
+		flags = conf_amd_get_flags(path);
306fa1
+		if (flags & CONF_BROWSABLE_DIRS)
306fa1
+			ghost = 1;
306fa1
+
306fa1
+		ret = master_add_autofs_point(entry, logopt, 0, ghost, 0);
306fa1
+		if (!ret) {
306fa1
+			error(m_logopt, "failed to add autofs_point");
306fa1
+			master_free_mapent(entry);
306fa1
+			goto next;
306fa1
+		}
306fa1
+
306fa1
+		type = conf_amd_get_map_type(path);
306fa1
+		argv[0] = map;
306fa1
+		argv[1] = NULL;
306fa1
+
306fa1
+		source = master_add_map_source(entry, type, "amd",
306fa1
+					       age, 1, (const char **) argv);
306fa1
+		if (!source) {
306fa1
+			error(m_logopt,
306fa1
+			      "failed to add source for amd section mount %s",
306fa1
+			      path);
306fa1
+			master_free_mapent(entry);
306fa1
+			goto next;
306fa1
+		}
306fa1
+
306fa1
+		source->exp_timeout = conf_amd_get_dismount_interval(path);
306fa1
+		source->master_line = 0;
306fa1
+
306fa1
+		entry->age = age;
306fa1
+		entry->current = NULL;
306fa1
+
306fa1
+		master_add_mapent(master, entry);
306fa1
+next:
306fa1
+		if (type)
306fa1
+			free(type);
306fa1
+		if (map)
306fa1
+			free(map);
306fa1
+		i++;
306fa1
+	}
306fa1
+
306fa1
+	i = 0;
306fa1
+	while (paths[i])
306fa1
+		free(paths[i++]);
306fa1
+	free(paths);
306fa1
+}
306fa1
+
306fa1
 int master_read_master(struct master *master, time_t age, int readall)
306fa1
 {
306fa1
 	unsigned int logopt = master->logopt;
306fa1
@@ -938,6 +1046,7 @@ int master_read_master(struct master *ma
306fa1
 	master_init_scan();
306fa1
 	lookup_nss_read_master(master, age);
306fa1
 	cache_unlock(nc);
306fa1
+	master_add_amd_mount_section_mounts(master, age);
306fa1
 	master_mutex_unlock();
306fa1
 
306fa1
 	if (!master->read_fail)