From owner-svn-src-head@FreeBSD.ORG Sat Aug 23 12:00:46 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B7240607; Sat, 23 Aug 2014 12:00:46 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 97FEE3D6C; Sat, 23 Aug 2014 12:00:46 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s7NC0kJN073898; Sat, 23 Aug 2014 12:00:46 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s7NC0jRd073894; Sat, 23 Aug 2014 12:00:45 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201408231200.s7NC0jRd073894@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Sat, 23 Aug 2014 12:00:45 +0000 (UTC) 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 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Aug 2014 12:00:46 -0000 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;