summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authortrasz <trasz@FreeBSD.org>2015-03-07 19:32:19 +0000
committertrasz <trasz@FreeBSD.org>2015-03-07 19:32:19 +0000
commit97710cbe33ec6723cc9fca56b97045a54a06e1a7 (patch)
tree5afa96ec0d4d07d8940b04369fd1954eb8a1cd56 /usr.sbin
parentdaec60ce10a3358229beb0a5762a9fc19a579272 (diff)
downloadFreeBSD-src-97710cbe33ec6723cc9fca56b97045a54a06e1a7.zip
FreeBSD-src-97710cbe33ec6723cc9fca56b97045a54a06e1a7.tar.gz
MFC r273127:
Make automountd(8) inform autofs(4) whether directory being handled can have wildcards. This makes it possible for autofs(4) to avoid requesting automountd(8) action on access to nonexistent nodes - unless wildcards are actually used. Note that this change breaks ABI for automountd(8). MFC r278521: Restore ABI compatibility, broken in r273127. Note that while this fixes ABI with 10.1, it breaks ABI for 11-CURRENT, so rebuild of automountd(8) is neccessary. Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/autofs/automountd.c31
-rw-r--r--usr.sbin/autofs/common.c29
-rw-r--r--usr.sbin/autofs/common.h4
3 files changed, 54 insertions, 10 deletions
diff --git a/usr.sbin/autofs/automountd.c b/usr.sbin/autofs/automountd.c
index 374e901..44143e5 100644
--- a/usr.sbin/autofs/automountd.c
+++ b/usr.sbin/autofs/automountd.c
@@ -68,13 +68,14 @@ static int autofs_fd;
static int request_id;
static void
-done(int request_error)
+done(int request_error, bool wildcards)
{
struct autofs_daemon_done add;
int error;
memset(&add, 0, sizeof(add));
add.add_id = request_id;
+ add.add_wildcards = wildcards;
add.add_error = request_error;
log_debugx("completing request %d with error %d",
@@ -172,7 +173,7 @@ static void
exit_callback(void)
{
- done(EIO);
+ done(EIO, true);
}
static void
@@ -184,6 +185,7 @@ handle_request(const struct autofs_daemon_request *adr, char *cmdline_options,
FILE *f;
char *options, *fstype, *nobrowse, *retrycnt, *tmp;
int error;
+ bool wildcards;
log_debugx("got request %d: from %s, path %s, prefix \"%s\", "
"key \"%s\", options \"%s\"", adr->adr_id, adr->adr_from,
@@ -209,9 +211,26 @@ handle_request(const struct autofs_daemon_request *adr, char *cmdline_options,
checked_strdup(adr->adr_options), checked_strdup(map),
checked_strdup("[kernel request]"), lineno);
}
- parse_map(parent, map, adr->adr_key[0] != '\0' ? adr->adr_key : NULL);
+
+ /*
+ * "Wildcards" here actually means "make autofs(4) request
+ * automountd(8) action if the node being looked up does not
+ * exist, even though the parent is marked as cached". This
+ * needs to be done for maps with wildcard entries, but also
+ * for special and executable maps.
+ */
+ parse_map(parent, map, adr->adr_key[0] != '\0' ? adr->adr_key : NULL,
+ &wildcards);
+ if (!wildcards)
+ wildcards = node_has_wildcards(parent);
+ if (wildcards)
+ log_debugx("map may contain wildcard entries");
+ else
+ log_debugx("map does not contain wildcard entries");
+
if (adr->adr_key[0] != '\0')
node_expand_wildcard(root, adr->adr_key);
+
node = node_find(root, adr->adr_path);
if (node == NULL) {
log_errx(1, "map %s does not contain key for \"%s\"; "
@@ -236,7 +255,7 @@ handle_request(const struct autofs_daemon_request *adr, char *cmdline_options,
if (nobrowse != NULL && adr->adr_key[0] == '\0') {
log_debugx("skipping map %s due to \"nobrowse\" "
"option; exiting", map);
- done(0);
+ done(0, true);
/*
* Exit without calling exit_callback().
@@ -263,7 +282,7 @@ handle_request(const struct autofs_daemon_request *adr, char *cmdline_options,
}
log_debugx("nothing to mount; exiting");
- done(0);
+ done(0, wildcards);
/*
* Exit without calling exit_callback().
@@ -337,7 +356,7 @@ handle_request(const struct autofs_daemon_request *adr, char *cmdline_options,
log_errx(1, "mount failed");
log_debugx("mount done; exiting");
- done(0);
+ done(0, wildcards);
/*
* Exit without calling exit_callback().
diff --git a/usr.sbin/autofs/common.c b/usr.sbin/autofs/common.c
index e6db682..6fd8a05 100644
--- a/usr.sbin/autofs/common.c
+++ b/usr.sbin/autofs/common.c
@@ -498,6 +498,19 @@ node_is_direct_map(const struct node *n)
return (true);
}
+bool
+node_has_wildcards(const struct node *n)
+{
+ const struct node *child;
+
+ TAILQ_FOREACH(child, &n->n_children, n_next) {
+ if (strcmp(child->n_key, "*") == 0)
+ return (true);
+ }
+
+ return (false);
+}
+
static void
node_expand_maps(struct node *n, bool indirect)
{
@@ -526,7 +539,7 @@ node_expand_maps(struct node *n, bool indirect)
log_debugx("map \"%s\" is a direct map, parsing",
child->n_map);
}
- parse_map(child, child->n_map, NULL);
+ parse_map(child, child->n_map, NULL, NULL);
}
}
@@ -996,7 +1009,8 @@ parse_included_map(struct node *parent, const char *map)
}
void
-parse_map(struct node *parent, const char *map, const char *key)
+parse_map(struct node *parent, const char *map, const char *key,
+ bool *wildcards)
{
char *path = NULL;
int error, ret;
@@ -1007,8 +1021,14 @@ parse_map(struct node *parent, const char *map, const char *key)
log_debugx("parsing map \"%s\"", map);
- if (map[0] == '-')
+ if (wildcards != NULL)
+ *wildcards = false;
+
+ if (map[0] == '-') {
+ if (wildcards != NULL)
+ *wildcards = true;
return (parse_special_map(parent, map, key));
+ }
if (map[0] == '/') {
path = checked_strdup(map);
@@ -1035,6 +1055,9 @@ parse_map(struct node *parent, const char *map, const char *key)
if (executable) {
log_debugx("map \"%s\" is executable", map);
+ if (wildcards != NULL)
+ *wildcards = true;
+
if (key != NULL) {
yyin = auto_popen(path, key, NULL);
} else {
diff --git a/usr.sbin/autofs/common.h b/usr.sbin/autofs/common.h
index bc0b6f6..16a8d73 100644
--- a/usr.sbin/autofs/common.h
+++ b/usr.sbin/autofs/common.h
@@ -80,6 +80,7 @@ struct node *node_new_map(struct node *parent, char *key, char *options,
char *map, const char *config_file, int config_line);
struct node *node_find(struct node *root, const char *mountpoint);
bool node_is_direct_map(const struct node *n);
+bool node_has_wildcards(const struct node *n);
char *node_path(const struct node *n);
char *node_options(const struct node *n);
void node_expand_ampersand(struct node *root, const char *key);
@@ -88,7 +89,8 @@ int node_expand_defined(struct node *root);
void node_expand_indirect_maps(struct node *n);
void node_print(const struct node *n);
void parse_master(struct node *root, const char *path);
-void parse_map(struct node *parent, const char *map, const char *args);
+void parse_map(struct node *parent, const char *map, const char *args,
+ bool *wildcards);
char *defined_expand(const char *string);
void defined_init(void);
void defined_parse_and_add(char *def);
OpenPOWER on IntegriCloud