Blame SOURCES/autofs-5.1.4-better-handle-hesiod-support-not-built-in.patch

aea863
autofs-5.1.4 - better handle hesiod support not built in
aea863
aea863
From: Ian Kent <raven@themaw.net>
aea863
aea863
The configure option --without-hesiod is not handled well.
aea863
aea863
If this option is given and hesiod is seen in the master
aea863
map parser or the amd map parser issue a message telling
aea863
the user hesiod support isn't built in.
aea863
aea863
Signed-off-by: Ian Kent <raven@themaw.net>
aea863
---
aea863
 CHANGELOG           |    1 +
aea863
 lib/master_parse.y  |   18 ++++++++++++++++--
aea863
 modules/amd_parse.y |    7 +++++++
aea863
 modules/parse_amd.c |   28 +++++++++++++++++++++++++---
aea863
 4 files changed, 49 insertions(+), 5 deletions(-)
aea863
aea863
--- autofs-5.1.4.orig/CHANGELOG
aea863
+++ autofs-5.1.4/CHANGELOG
aea863
@@ -36,6 +36,7 @@ xx/xx/2018 autofs-5.1.5
aea863
 - fix use after free in parse_ldap_config().
aea863
 - fix incorrect locking in sss lookup.
aea863
 - fix amd parser opts option handling.
aea863
+- better handle hesiod support not built in.
aea863
 
aea863
 19/12/2017 autofs-5.1.4
aea863
 - fix spec file url.
aea863
--- autofs-5.1.4.orig/lib/master_parse.y
aea863
+++ autofs-5.1.4/lib/master_parse.y
aea863
@@ -171,7 +171,14 @@ line:
aea863
 
aea863
 		if ((tmp = strchr($2, ',')))
aea863
 			*tmp++ = '\0';
aea863
-
aea863
+#ifndef WITH_HESIOD
aea863
+		/* Map type or or map type parser is hesiod */
aea863
+		if (!strcmp($2, "hesiod") || !strcmp(tmp, "hesiod")) {
aea863
+			master_error("hesiod support not built in");
aea863
+			local_free_vars();
aea863
+			YYABORT;
aea863
+		}
aea863
+#endif
aea863
 		if (type)
aea863
 			free(type);
aea863
 		type = master_strdup($2);
aea863
@@ -352,7 +359,14 @@ map:	PATH
aea863
 
aea863
 		if ((tmp = strchr($1, ',')))
aea863
 			*tmp++ = '\0';
aea863
-
aea863
+#ifndef WITH_HESIOD
aea863
+		/* Map type or or map type parser is hesiod */
aea863
+		if (!strcmp($1, "hesiod") || !strcmp(tmp, "hesiod")) {
aea863
+			master_error("hesiod support not built in");
aea863
+			local_free_vars();
aea863
+			YYABORT;
aea863
+		}
aea863
+#endif
aea863
 		if (type)
aea863
 			free(type);
aea863
 		if (strcmp($1, "exec"))
aea863
--- autofs-5.1.4.orig/modules/amd_parse.y
aea863
+++ autofs-5.1.4/modules/amd_parse.y
aea863
@@ -574,6 +574,13 @@ static int match_map_option_map_type(cha
aea863
 	    !strcmp(map_type, "nisplus") ||
aea863
 	    !strcmp(map_type, "ldap") ||
aea863
 	    !strcmp(map_type, "hesiod")) {
aea863
+#ifndef WITH_HESIOD
aea863
+		if (!strcmp(map_type, "hesiod")) {
aea863
+			amd_msg("hesiod support not built in");
aea863
+			free(map_type);
aea863
+			return 0;
aea863
+		}
aea863
+#endif
aea863
 		amd_set_value(&entry.map_type, map_type);
aea863
 	} else if (!strcmp(map_type, "exec")) {
aea863
 		/* autofs uses "program" for "exec" map type */
aea863
--- autofs-5.1.4.orig/modules/parse_amd.c
aea863
+++ autofs-5.1.4/modules/parse_amd.c
aea863
@@ -1871,15 +1871,25 @@ struct amd_entry *make_default_entry(str
aea863
 	if (amd_parse_list(ap, defaults, &dflts, &sv))
aea863
 		return NULL;
aea863
 	defaults_entry = list_entry(dflts.next, struct amd_entry, list);
aea863
-	list_del_init(&defaults_entry->list);
aea863
 	/*
aea863
 	 * If map type isn't given try to inherit from
aea863
 	 * parent. A NULL map type is valid and means
aea863
 	 * use configured nss sources.
aea863
 	 */
aea863
 	map_type = conf_amd_get_map_type(ap->path);
aea863
-	if (map_type)
aea863
+	if (map_type) {
aea863
 		defaults_entry->map_type = map_type;
aea863
+#ifndef HAVE_HESIOD
aea863
+		if (!strcmp(map_type, "hesiod")) {
aea863
+			warn(ap->logopt, MODPREFIX
aea863
+			     "hesiod support not built in, "
aea863
+			     "defaults map entry not set");
aea863
+			defaults_entry = NULL;
aea863
+		}
aea863
+#endif
aea863
+	}
aea863
+	if (defaults_entry)
aea863
+		list_del_init(&defaults_entry->list);
aea863
 	/* The list should now be empty .... */
aea863
 	free_amd_entry_list(&dflts);
aea863
 	return defaults_entry;
aea863
@@ -2005,8 +2015,20 @@ static struct amd_entry *get_defaults_en
aea863
 			 * use configured nss sources.
aea863
 			 */
aea863
 			char *map_type = conf_amd_get_map_type(ap->path);
aea863
-			if (map_type)
aea863
+			if (map_type) {
aea863
 				entry->map_type = map_type;
aea863
+#ifndef HAVE_HESIOD
aea863
+				if (!strcmp(map_type, "hesiod")) {
aea863
+					warn(ap->logopt, MODPREFIX
aea863
+					     "hesiod support not built in, "
aea863
+					     "attempting to use internal "
aea863
+					     "default");
aea863
+					free_amd_entry(entry);
aea863
+					free(expand);
aea863
+					goto out;
aea863
+				}
aea863
+#endif
aea863
+			}
aea863
 		}
aea863
 		free(expand);
aea863
 	}