Blame SOURCES/autofs-5.0.9-amd-lookup-use-config-map_type-if-type-is-not-given.patch

306fa1
autofs-5.0.9 - amd lookup use config map_type if type is not given
306fa1
306fa1
From: Ian Kent <raven@themaw.net>
306fa1
306fa1
If the map type isn't given in the map defaults or the map location
306fa1
the attempt to set it from the configuration.
306fa1
306fa1
A NULL map type is valid and means use the nss source list to find
306fa1
the source of the map.
306fa1
306fa1
This approach may not always give the best result. For example, when
306fa1
a map type specified in the master map submounts will not inherit
306fa1
it and will instead use a configured global type instead. Second,
306fa1
if we want to use nss to find a map source a global map type can't
306fa1
be defined or it will override the nss source search.
306fa1
---
306fa1
 modules/parse_amd.c |   19 +++++++++++++++++++
306fa1
 1 file changed, 19 insertions(+)
306fa1
306fa1
diff --git a/modules/parse_amd.c b/modules/parse_amd.c
306fa1
index e27a195..bf673b3 100644
306fa1
--- a/modules/parse_amd.c
306fa1
+++ b/modules/parse_amd.c
306fa1
@@ -1339,12 +1339,21 @@ struct amd_entry *make_default_entry(struct autofs_point *ap,
306fa1
 	char *defaults = "opts:=rw,defaults";
306fa1
 	struct amd_entry *defaults_entry;
306fa1
 	struct list_head dflts;
306fa1
+	char *map_type;
306fa1
 
306fa1
 	INIT_LIST_HEAD(&dflts);
306fa1
 	if (amd_parse_list(ap, defaults, &dflts, &sv))
306fa1
 		return NULL;
306fa1
 	defaults_entry = list_entry(dflts.next, struct amd_entry, list);
306fa1
 	list_del_init(&defaults_entry->list);
306fa1
+	/*
306fa1
+	 * If map type isn't given try to inherit from
306fa1
+	 * parent. A NULL map type is valid and means
306fa1
+	 * use configured nss sources.
306fa1
+	 */
306fa1
+	map_type = conf_amd_get_map_type(ap->path);
306fa1
+	if (map_type)
306fa1
+		defaults_entry->map_type = strdup(map_type);
306fa1
 	/* The list should now be empty .... */
306fa1
 	free_amd_entry_list(&dflts);
306fa1
 	return defaults_entry;
306fa1
@@ -1458,6 +1467,16 @@ static struct amd_entry *get_defaults_entry(struct autofs_point *ap,
306fa1
 		if (amd_parse_list(ap, expand, &dflts, &sv))
306fa1
 			goto out;
306fa1
 		entry = select_default_entry(ap, &dflts, sv);
306fa1
+		if (!entry->map_type) {
306fa1
+			/*
306fa1
+			 * If map type isn't given try to inherit from
306fa1
+			 * parent. A NULL map type is valid and means
306fa1
+			 * use configured nss sources.
306fa1
+			 */
306fa1
+			char *map_type = conf_amd_get_map_type(ap->path);
306fa1
+			if (map_type)
306fa1
+				entry->map_type = strdup(map_type);
306fa1
+		}
306fa1
 		free(expand);
306fa1
 	}
306fa1