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

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