Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 21 May 2015 13:41:08 +0000 (UTC)
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r283241 - stable/10/usr.sbin/autofs
Message-ID:  <201505211341.t4LDf8hL006192@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: trasz
Date: Thu May 21 13:41:08 2015
New Revision: 283241
URL: https://svnweb.freebsd.org/changeset/base/283241

Log:
  MFC r279954:
  
  Get executable direct maps to work.
  
  Sponsored by:	The FreeBSD Foundation

Modified:
  stable/10/usr.sbin/autofs/automountd.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/autofs/automountd.c
==============================================================================
--- stable/10/usr.sbin/autofs/automountd.c	Thu May 21 13:39:38 2015	(r283240)
+++ stable/10/usr.sbin/autofs/automountd.c	Thu May 21 13:41:08 2015	(r283241)
@@ -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; "



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201505211341.t4LDf8hL006192>