Blame SOURCES/autofs-5.1.0-beta1-fix-old-style-key-lookup.patch

6bbd11
autofs-5.1.0-beta1 - fix old style key lookup
6bbd11
6bbd11
From: Ian Kent <ikent@redhat.com>
6bbd11
6bbd11
Old (old) style configuration keys all started with DEFAULT_ but
6bbd11
the configuration entry lookup requires the has of the lower case
6bbd11
name. So trying to these old style names failes because thet don't
6bbd11
has to the same value.
6bbd11
6bbd11
So change the key lookup to strip the DEFAULT_ string and retry
6bbd11
the lookup so valid entries hash properly.
6bbd11
---
6bbd11
 CHANGELOG      |    1 +
6bbd11
 lib/defaults.c |   33 +++++++++++++++++++++------------
6bbd11
 2 files changed, 22 insertions(+), 12 deletions(-)
6bbd11
6bbd11
--- autofs-5.0.7.orig/CHANGELOG
6bbd11
+++ autofs-5.0.7/CHANGELOG
6bbd11
@@ -116,6 +116,7 @@
6bbd11
 - fix map format init in lookup_init().
6bbd11
 - fix incorrect max key length in defaults get_hash().
6bbd11
 - fix xfn sets incorrect lexer state.
6bbd11
+- fix old style key lookup.
6bbd11
 
6bbd11
 25/07/2012 autofs-5.0.7
6bbd11
 =======================
6bbd11
--- autofs-5.0.7.orig/lib/defaults.c
6bbd11
+++ autofs-5.0.7/lib/defaults.c
6bbd11
@@ -673,33 +673,42 @@ static u_int32_t get_hash(const char *ke
6bbd11
 	return hash(lkey, size);
6bbd11
 }
6bbd11
 
6bbd11
-static struct conf_option *conf_lookup(const char *section, const char *key)
6bbd11
+static struct conf_option *conf_lookup_key(const char *section, const char *key)
6bbd11
 {
6bbd11
 	struct conf_option *co;
6bbd11
 	u_int32_t key_hash;
6bbd11
 	unsigned int size = CFG_TABLE_SIZE;
6bbd11
 
6bbd11
-	if (!key || !section)
6bbd11
-		return NULL;
6bbd11
-
6bbd11
-	if (strlen(key) > PATH_MAX)
6bbd11
-		return NULL;
6bbd11
-
6bbd11
 	key_hash = get_hash(key, size);
6bbd11
 	for (co = config->hash[key_hash]; co != NULL; co = co->next) {
6bbd11
 		if (strcasecmp(section, co->section))
6bbd11
 			continue;
6bbd11
 		if (!strcasecmp(key, co->name))
6bbd11
 			break;
6bbd11
+	}
6bbd11
+
6bbd11
+	return co;
6bbd11
+}
6bbd11
+
6bbd11
+static struct conf_option *conf_lookup(const char *section, const char *key)
6bbd11
+{
6bbd11
+	struct conf_option *co;
6bbd11
+
6bbd11
+	if (!key || !section)
6bbd11
+		return NULL;
6bbd11
+
6bbd11
+	if (strlen(key) > PATH_MAX)
6bbd11
+		return NULL;
6bbd11
+
6bbd11
+	co = conf_lookup_key(section, key);
6bbd11
+	if (!co) {
6bbd11
 		/*
6bbd11
 		 * Strip "DEFAULT_" and look for config entry for
6bbd11
 		 * backward compatibility with old style config names.
6bbd11
+		 * Perhaps this should be a case sensitive compare?
6bbd11
 		 */
6bbd11
-		if (strlen(key) <= 8)
6bbd11
-			continue;
6bbd11
-		if (!strncasecmp("DEFAULT_", key, 8) &&
6bbd11
-		    !strcasecmp(key + 8, co->name))
6bbd11
-			break;
6bbd11
+		if (strlen(key) > 8 && !strncasecmp("DEFAULT_", key, 8))
6bbd11
+			co = conf_lookup_key(section, key + 8);
6bbd11
 	}
6bbd11
 
6bbd11
 	return co;