aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/autofs/automountd.c
diff options
context:
space:
mode:
authorEdward Tomasz Napierala <trasz@FreeBSD.org>2015-03-13 12:27:59 +0000
committerEdward Tomasz Napierala <trasz@FreeBSD.org>2015-03-13 12:27:59 +0000
commit52df29e6a52fefd39b9ad2ea70e9a1bd5a77c50a (patch)
tree45764c8a7fff6705e37ab7760e4ee7ad60ec3081 /usr.sbin/autofs/automountd.c
parentcd3772d07611d360a12a9ce663b096ec76a593e9 (diff)
downloadsrc-52df29e6a52fefd39b9ad2ea70e9a1bd5a77c50a.tar.gz
src-52df29e6a52fefd39b9ad2ea70e9a1bd5a77c50a.zip
Get executable direct maps to work.
MFC after: 1 month Sponsored by: The FreeBSD Foundation
Notes
Notes: svn path=/head/; revision=279954
Diffstat (limited to 'usr.sbin/autofs/automountd.c')
-rw-r--r--usr.sbin/autofs/automountd.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/usr.sbin/autofs/automountd.c b/usr.sbin/autofs/automountd.c
index 9c399fd626ea..2c9b1a9faf98 100644
--- a/usr.sbin/autofs/automountd.c
+++ b/usr.sbin/autofs/automountd.c
@@ -177,7 +177,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, *nobrowse, *retrycnt, *tmp;
+ char *key, *options, *fstype, *nobrowse, *retrycnt, *tmp;
int error;
bool wildcards;
@@ -199,11 +199,25 @@ handle_request(const struct autofs_daemon_request *adr, char *cmdline_options,
map = adr->adr_from + 4; /* 4 for strlen("map "); */
root = node_new_root();
if (adr->adr_prefix[0] == '\0' || strcmp(adr->adr_prefix, "/") == 0) {
+ /*
+ * Direct map. autofs(4) doesn't have a way to determine
+ * correct map key, but since it's a direct map, we can just
+ * use adr_path instead.
+ */
parent = root;
+ key = checked_strdup(adr->adr_path);
} else {
+ /*
+ * Indirect map.
+ */
parent = node_new_map(root, checked_strdup(adr->adr_prefix),
NULL, checked_strdup(map),
checked_strdup("[kernel request]"), lineno);
+
+ if (adr->adr_key[0] == '\0')
+ key = NULL;
+ else
+ key = checked_strdup(adr->adr_key);
}
/*
@@ -213,8 +227,7 @@ handle_request(const struct autofs_daemon_request *adr, char *cmdline_options,
* 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);
+ parse_map(parent, map, key, &wildcards);
if (!wildcards)
wildcards = node_has_wildcards(parent);
if (wildcards)
@@ -222,8 +235,8 @@ handle_request(const struct autofs_daemon_request *adr, char *cmdline_options,
else
log_debugx("map does not contain wildcard entries");
- if (adr->adr_key[0] != '\0')
- node_expand_wildcard(root, adr->adr_key);
+ if (key != NULL)
+ node_expand_wildcard(root, key);
node = node_find(root, adr->adr_path);
if (node == NULL) {
@@ -248,7 +261,7 @@ handle_request(const struct autofs_daemon_request *adr, char *cmdline_options,
node->n_config_file, node->n_config_line);
nobrowse = pick_option("nobrowse", &options);
- if (nobrowse != NULL && adr->adr_key[0] == '\0') {
+ if (nobrowse != NULL && key == NULL) {
log_debugx("skipping map %s due to \"nobrowse\" "
"option; exiting", map);
done(0, true);
@@ -265,12 +278,12 @@ handle_request(const struct autofs_daemon_request *adr, char *cmdline_options,
*/
create_subtree(node, incomplete_hierarchy);
- if (incomplete_hierarchy && adr->adr_key[0] != '\0') {
+ if (incomplete_hierarchy && key != NULL) {
/*
* We still need to create the single subdirectory
* user is trying to access.
*/
- tmp = concat(adr->adr_path, '/', adr->adr_key);
+ tmp = concat(adr->adr_path, '/', key);
node = node_find(root, tmp);
if (node != NULL)
create_subtree(node, false);
@@ -288,8 +301,8 @@ handle_request(const struct autofs_daemon_request *adr, char *cmdline_options,
log_debugx("found node defined at %s:%d; it is a mountpoint",
node->n_config_file, node->n_config_line);
- node_expand_ampersand(node,
- adr->adr_key[0] != '\0' ? adr->adr_key : NULL);
+ if (key != NULL)
+ node_expand_ampersand(node, key);
error = node_expand_defined(node);
if (error != 0) {
log_errx(1, "variable expansion failed for %s; "