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
This commit is contained in:
Edward Tomasz Napierala 2014-08-23 12:00:45 +00:00
parent 30ae6e0076
commit f7ae83075a
4 changed files with 71 additions and 11 deletions

View File

@ -2,4 +2,4 @@
#
# Automounter master map, see auto_master(5) for details.
#
/net -hosts -nosuid
/net -hosts -nobrowse,nosuid

View File

@ -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

View File

@ -182,7 +182,7 @@ handle_request(const struct autofs_daemon_request *adr, char *cmdline_options,
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_daemon_request *adr, char *cmdline_options,
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_daemon_request *adr, char *cmdline_options,
if (node != NULL)
create_subtree(node, false);
}
done(0);
log_debugx("nothing to mount; exiting");
done(0);
/*
* Exit without calling exit_callback().
@ -273,6 +295,11 @@ handle_request(const struct autofs_daemon_request *adr, char *cmdline_options,
*/
options = separated_concat(options, "automounted", ',');
/*
* Remove "nobrowse", mount(8) doesn't understand it.
*/
pick_option("nobrowse", &options);
/*
* Figure out fstype.
*/
@ -309,8 +336,8 @@ handle_request(const struct autofs_daemon_request *adr, char *cmdline_options,
if (error != 0)
log_errx(1, "mount failed");
done(0);
log_debugx("mount done; exiting");
done(0);
/*
* Exit without calling exit_callback().

View File

@ -856,6 +856,36 @@ parse_map_yyin(struct node *parent, const char *map, const char *executable_key)
}
}
/*
* 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, const char *map, const char *key)
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, const char *map, const char *key)
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;