svn commit: r279954 - head/usr.sbin/autofs
Edward Tomasz Napierala
trasz at FreeBSD.org
Fri Mar 13 12:28:01 UTC 2015
Author: trasz
Date: Fri Mar 13 12:27:59 2015
New Revision: 279954
URL: https://svnweb.freebsd.org/changeset/base/279954
Log:
Get executable direct maps to work.
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Modified:
head/usr.sbin/autofs/automountd.c
Modified: head/usr.sbin/autofs/automountd.c
==============================================================================
--- head/usr.sbin/autofs/automountd.c Fri Mar 13 11:26:02 2015 (r279953)
+++ head/usr.sbin/autofs/automountd.c Fri Mar 13 12:27:59 2015 (r279954)
@@ -177,7 +177,7 @@ handle_request(const struct autofs_daemo
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_daemo
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_daemo
* 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_daemo
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_daemo
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_daemo
*/
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_daemo
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; "
More information about the svn-src-all
mailing list