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

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