Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 23 Aug 2014 12:00:45 +0000 (UTC)
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r270406 - in head: etc usr.sbin/autofs
Message-ID:  <201408231200.s7NC0jRd073894@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: trasz
Date: Sat Aug 23 12:00:45 2014
New Revision: 270406
URL: http://svnweb.freebsd.org/changeset/base/270406

Log:
  Add "nobrowse" option.  Previously automountd(8) always behaved as if
  it was set, now it's conditional.
  
  PR:		192862
  MFC after:	2 weeks
  Sponsored by:	The FreeBSD Foundation

Modified:
  head/etc/auto_master
  head/usr.sbin/autofs/auto_master.5
  head/usr.sbin/autofs/automountd.c
  head/usr.sbin/autofs/common.c

Modified: head/etc/auto_master
==============================================================================
--- head/etc/auto_master	Sat Aug 23 11:51:46 2014	(r270405)
+++ head/etc/auto_master	Sat Aug 23 12:00:45 2014	(r270406)
@@ -2,4 +2,4 @@
 #
 # Automounter master map, see auto_master(5) for details.
 #
-/net		-hosts		-nosuid
+/net		-hosts		-nobrowse,nosuid

Modified: head/usr.sbin/autofs/auto_master.5
==============================================================================
--- head/usr.sbin/autofs/auto_master.5	Sat Aug 23 11:51:46 2014	(r270405)
+++ head/usr.sbin/autofs/auto_master.5	Sat Aug 23 12:00:45 2014	(r270406)
@@ -27,7 +27,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd July 31, 2014
+.Dd August 23, 2014
 .Dt AUTO_MASTER 5
 .Os
 .Sh NAME
@@ -134,6 +134,10 @@ is used to specify filesystem type.
 It is not passed to the mount program as an option.
 Instead, it is passed as argument to
 .Cm "mount -t".
+The special option
+.Li nobrowse
+is used to disable creation of top-level directories for special
+and executable maps.
 .Pp
 The optional
 .Pa mountpoint

Modified: head/usr.sbin/autofs/automountd.c
==============================================================================
--- head/usr.sbin/autofs/automountd.c	Sat Aug 23 11:51:46 2014	(r270405)
+++ head/usr.sbin/autofs/automountd.c	Sat Aug 23 12:00:45 2014	(r270406)
@@ -182,7 +182,7 @@ handle_request(const struct autofs_daemo
 	const char *map;
 	struct node *root, *parent, *node;
 	FILE *f;
-	char *options, *fstype, *retrycnt, *tmp;
+	char *options, *fstype, *nobrowse, *retrycnt, *tmp;
 	int error;
 
 	log_debugx("got request %d: from %s, path %s, prefix \"%s\", "
@@ -222,6 +222,28 @@ handle_request(const struct autofs_daemo
 		log_debugx("found node defined at %s:%d; not a mountpoint",
 		    node->n_config_file, node->n_config_line);
 
+		options = node_options(node);
+
+		/*
+		 * Prepend options passed via automountd(8) command line.
+		 */
+		if (cmdline_options != NULL) {
+			options =
+			    separated_concat(cmdline_options, options, ',');
+		}
+
+		nobrowse = pick_option("nobrowse", &options);
+		if (nobrowse != NULL && adr->adr_key[0] == '\0') {
+			log_debugx("skipping map %s due to \"nobrowse\" "
+			    "option; exiting", map);
+			done(0);
+
+			/*
+			 * Exit without calling exit_callback().
+			 */
+			quick_exit(0);
+		}
+
 		/*
 		 * Not a mountpoint; create directories in the autofs mount
 		 * and complete the request.
@@ -239,9 +261,9 @@ handle_request(const struct autofs_daemo
 			if (node != NULL)
 				create_subtree(node, false);
 		}
-		done(0);
 
 		log_debugx("nothing to mount; exiting");
+		done(0);
 
 		/*
 		 * Exit without calling exit_callback().
@@ -274,6 +296,11 @@ handle_request(const struct autofs_daemo
 	options = separated_concat(options, "automounted", ',');
 
 	/*
+	 * Remove "nobrowse", mount(8) doesn't understand it.
+	 */
+	pick_option("nobrowse", &options);
+
+	/*
 	 * Figure out fstype.
 	 */
 	fstype = pick_option("fstype=", &options);
@@ -309,8 +336,8 @@ handle_request(const struct autofs_daemo
 	if (error != 0)
 		log_errx(1, "mount failed");
 
-	done(0);
 	log_debugx("mount done; exiting");
+	done(0);
 
 	/*
 	 * Exit without calling exit_callback().

Modified: head/usr.sbin/autofs/common.c
==============================================================================
--- head/usr.sbin/autofs/common.c	Sat Aug 23 11:51:46 2014	(r270405)
+++ head/usr.sbin/autofs/common.c	Sat Aug 23 12:00:45 2014	(r270406)
@@ -856,6 +856,36 @@ again:
 	}
 }
 
+/*
+ * Parse output of a special map called without argument.  This is just
+ * a list of keys.
+ */
+static void
+parse_map_keys_yyin(struct node *parent, const char *map)
+{
+	char *key = NULL;
+	int ret;
+
+	lineno = 1;
+
+	for (;;) {
+		ret = yylex();
+
+		if (ret == NEWLINE)
+			continue;
+
+		if (ret == 0) {
+			/*
+			 * End of file.
+			 */
+			break;
+		}
+
+		key = checked_strdup(yytext);
+		node_new(parent, key, NULL, NULL, map, lineno);
+	}
+}
+
 static bool
 file_is_executable(const char *path)
 {
@@ -882,11 +912,6 @@ parse_special_map(struct node *parent, c
 
 	assert(map[0] == '-');
 
-	if (key == NULL) {
-		log_debugx("skipping map %s due to forced -nobrowse", map);
-		return;
-	}
-
 	/*
 	 * +1 to skip leading "-" in map name.
 	 */
@@ -897,7 +922,11 @@ parse_special_map(struct node *parent, c
 	yyin = auto_popen(path, key, NULL);
 	assert(yyin != NULL);
 
-	parse_map_yyin(parent, map, key);
+	if (key == NULL) {
+		parse_map_keys_yyin(parent, map);
+	} else {
+		parse_map_yyin(parent, map, key);
+	}
 
 	error = auto_pclose(yyin);
 	yyin = NULL;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201408231200.s7NC0jRd073894>