Author: trasz
Date: Sun Aug 31 21:55:08 2014
New Revision: 270902
URL: http://svnweb.freebsd.org/changeset/base/270902

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

Modified:
  stable/10/etc/auto_master
  stable/10/usr.sbin/autofs/auto_master.5
  stable/10/usr.sbin/autofs/automountd.c
  stable/10/usr.sbin/autofs/common.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/etc/auto_master
==============================================================================
--- stable/10/etc/auto_master   Sun Aug 31 21:53:42 2014        (r270901)
+++ stable/10/etc/auto_master   Sun Aug 31 21:55:08 2014        (r270902)
@@ -2,4 +2,4 @@
 #
 # Automounter master map, see auto_master(5) for details.
 #
-/net           -hosts          -nosuid
+/net           -hosts          -nobrowse,nosuid

Modified: stable/10/usr.sbin/autofs/auto_master.5
==============================================================================
--- stable/10/usr.sbin/autofs/auto_master.5     Sun Aug 31 21:53:42 2014        
(r270901)
+++ stable/10/usr.sbin/autofs/auto_master.5     Sun Aug 31 21:55:08 2014        
(r270902)
@@ -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: stable/10/usr.sbin/autofs/automountd.c
==============================================================================
--- stable/10/usr.sbin/autofs/automountd.c      Sun Aug 31 21:53:42 2014        
(r270901)
+++ stable/10/usr.sbin/autofs/automountd.c      Sun Aug 31 21:55:08 2014        
(r270902)
@@ -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: stable/10/usr.sbin/autofs/common.c
==============================================================================
--- stable/10/usr.sbin/autofs/common.c  Sun Aug 31 21:53:42 2014        
(r270901)
+++ stable/10/usr.sbin/autofs/common.c  Sun Aug 31 21:55:08 2014        
(r270902)
@@ -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;
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to