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

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