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

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