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

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