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

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