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

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