All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Kent <raven@themaw.net>
To: autofs mailing list <autofs@vger.kernel.org>
Subject: [PATCH 32/37] autofs-5.1.2 - include amd mount section mounts in master mounts list
Date: Tue, 25 Oct 2016 09:20:16 +0800	[thread overview]
Message-ID: <20161025012015.7778.59245.stgit@pluto.themaw.net> (raw)
In-Reply-To: <20161025010014.7778.69274.stgit@pluto.themaw.net>

Currently a master map entry is required for amd format maps and
top level amd mount path configuration sections can only used to
provide additional per-mount configuration.

But being able to use the top level amd format mount path
configuration sections alone allows potentially incompatible
master map entries to not be included in the master map.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG       |    1 +
 README.amd-maps |   49 +++++++++++++++++++++----
 lib/master.c    |  109 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 152 insertions(+), 7 deletions(-)

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

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

  parent reply	other threads:[~2016-10-25  1:20 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-25  1:17 [PATCH 00/37] Current patch queue for review Ian Kent
2016-10-25  1:17 ` [PATCH 01/37] autofs-5.1.2 - fix release date in CHANGELOG Ian Kent
2016-10-25  1:17 ` [PATCH 02/37] autofs-5.1.2 - build: check for clock_gettime in librt Ian Kent
2016-10-25  1:17 ` [PATCH 03/37] autofs-5.1.2 - Fix compiler warning in try_remount() Ian Kent
2016-10-25  1:17 ` [PATCH 04/37] autofs-5.1.2 - Drop redundant \n in logerr() Ian Kent
2016-10-25  1:17 ` [PATCH 05/37] autofs-5.1.2 - Fix size arg of fgets(3) Ian Kent
2016-10-25  1:17 ` [PATCH 06/37] autofs-5.1.2 - fix libtirpc detection with -Wl, --as-needed Ian Kent
2016-10-25  1:18 ` [PATCH 07/37] autofs-5.1.2 - Fix a typo in CREDITS Ian Kent
2016-10-25  1:18 ` [PATCH 08/37] autofs-5.1.2 - Change .requestor to .requester for consistency Ian Kent
2016-10-25  1:18 ` [PATCH 09/37] autofs-5.1.2 - fix file map changed check Ian Kent
2016-10-25  1:18 ` [PATCH 10/37] autofs-5.1.2 - Remove unused local 2KB buffer Ian Kent
2016-10-25  1:18 ` [PATCH 11/37] autofs-5.1.2 - Fix typos in error messages Ian Kent
2016-10-25  1:18 ` [PATCH 12/37] autofs-5.1.2 - Fix fgets(3) size argument (another one) Ian Kent
2016-10-25  1:18 ` [PATCH 13/37] autofs-5.1.2 - fix short memory allocation in lookup_amd_instance() Ian Kent
2016-10-25  1:18 ` [PATCH 14/37] autofs-5.1.2 - fix count_mounts() function Ian Kent
2016-10-25  1:18 ` [PATCH 15/37] autofs-5.1.2 - configure: add cache variable for Linux proc filesystem check Ian Kent
2016-10-25  1:18 ` [PATCH 16/37] autofs-5.1.2 - Avoid local variable name shadowing another Ian Kent
2016-10-25  1:18 ` [PATCH 17/37] autofs-5.1.2 - fix typo in MOUNT_FLAG_GHOST comment Ian Kent
2016-10-25  1:19 ` [PATCH 18/37] autofs-5.1.2 - fix cachefs parse message not being logged Ian Kent
2016-10-25  1:19 ` [PATCH 19/37] autofs-5.1.2 - fix argc off by one in mount_autofs.c Ian Kent
2016-10-25  1:19 ` [PATCH 20/37] autofs-5.1.2 - fix _strncmp() usage Ian Kent
2016-10-25  1:19 ` [PATCH 21/37] autofs-5.1.1 - fix create_client() RPC client handling Ian Kent
2016-10-25  1:19 ` [PATCH 22/37] autofs-5.1.2 - update and add README for old autofs schema Ian Kent
2016-10-25  1:19 ` [PATCH 23/37] autofs-5.1.2 - wait for master map available at start Ian Kent
2016-10-25  1:19 ` [PATCH 24/37] autofs-5.1.2 - add master read wait option Ian Kent
2016-10-25  1:19 ` [PATCH 25/37] autofs-5.1.2 - work around sss startup delay Ian Kent
2016-10-25  1:19 ` [PATCH 26/37] autofs-5.1.2 - add sss master map wait config option Ian Kent
2016-10-25  1:19 ` [PATCH 27/37] autofs-5.1.2 - fix typos in README.amd-maps Ian Kent
2016-10-25  1:19 ` [PATCH 28/37] autofs-5.1.2 - add ref counting to struct map_source Ian Kent
2016-10-25  1:19 ` [PATCH 29/37] autofs-5.1.2 - add support for amd browsable option Ian Kent
2016-10-25  1:20 ` [PATCH 30/37] autofs-5.1.2 - add function conf_amd_get_map_name() Ian Kent
2016-10-25  1:20 ` [PATCH 31/37] autofs-5.1.2 - add function conf_amd_get_mount_paths() Ian Kent
2016-10-25  1:20 ` Ian Kent [this message]
2016-10-25  1:20 ` [PATCH 33/37] autofs-5.1.2 - check for conflicting amd section mounts Ian Kent
2016-10-25  1:20 ` [PATCH 34/37] autofs-5.1.2 - add function conf_get_map_options() Ian Kent
2016-10-25  1:20 ` [PATCH 35/37] autofs-5.1.2 - capture cache option and its settings during parsing Ian Kent
2016-10-25  1:20 ` [PATCH 36/37] autofs-5.1.2 - handle map_option cache for top level mounts Ian Kent
2016-10-25  1:20 ` [PATCH 37/37] autofs-5.1.2 - handle amd cache option all in amd type auto mounts Ian Kent
2016-11-04  8:53 ` [PATCH 00/37] Current patch queue for review Ian Kent

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161025012015.7778.59245.stgit@pluto.themaw.net \
    --to=raven@themaw.net \
    --cc=autofs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.