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

6bbd11
autofs-5.1.0-beta1 - fix wildcard key lookup
6bbd11
6bbd11
From: Ian Kent <raven@themaw.net>
6bbd11
6bbd11
The changes to key matching caused wildcard key lookups for autofs
6bbd11
format maps to fail.
6bbd11
---
6bbd11
 CHANGELOG                |    1 +
6bbd11
 modules/lookup_ldap.c    |   10 ++++------
6bbd11
 modules/lookup_nisplus.c |   11 +++++------
6bbd11
 modules/lookup_program.c |    4 ++--
6bbd11
 modules/lookup_yp.c      |    6 ++----
6bbd11
 5 files changed, 14 insertions(+), 18 deletions(-)
6bbd11
6bbd11
--- autofs-5.0.7.orig/CHANGELOG
6bbd11
+++ autofs-5.0.7/CHANGELOG
6bbd11
@@ -109,6 +109,7 @@
6bbd11
 - fix deadlock in init_ldap_connection.
6bbd11
 - extend fix for crash due to thread unsafe use of libldap.
6bbd11
 - add amd map format parser.
6bbd11
+- fix wildcard key lookup.
6bbd11
 
6bbd11
 25/07/2012 autofs-5.0.7
6bbd11
 =======================
6bbd11
--- autofs-5.0.7.orig/modules/lookup_ldap.c
6bbd11
+++ autofs-5.0.7/modules/lookup_ldap.c
6bbd11
@@ -3349,12 +3349,9 @@ static int match_key(struct autofs_point
6bbd11
 	else
6bbd11
 		ret = lookup_one(ap, source, key, key_len, ctxt);
6bbd11
 
6bbd11
-	if (ret == CHE_OK || ret == CHE_UPDATED)
6bbd11
+	if (ret == CHE_OK || ret == CHE_UPDATED || !is_amd_format)
6bbd11
 		return ret;
6bbd11
 
6bbd11
-	if (!is_amd_format)
6bbd11
-		return CHE_FAIL;
6bbd11
-
6bbd11
 	lkp_key = strdup(key);
6bbd11
 	if (!lkp_key) {
6bbd11
 		char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
6bbd11
@@ -3399,6 +3396,7 @@ static int check_map_indirect(struct aut
6bbd11
 			      char *key, int key_len,
6bbd11
 			      struct lookup_context *ctxt)
6bbd11
 {
6bbd11
+	unsigned int is_amd_format = source->flags & MAP_FLAG_FORMAT_AMD;
6bbd11
 	struct mapent_cache *mc;
6bbd11
 	struct mapent *me;
6bbd11
 	time_t now = time(NULL);
6bbd11
@@ -3410,7 +3408,7 @@ static int check_map_indirect(struct aut
6bbd11
 	pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state);
6bbd11
 
6bbd11
 	pthread_mutex_lock(&ap->entry->current_mutex);
6bbd11
-	if (source->flags & MAP_FLAG_FORMAT_AMD) {
6bbd11
+	if (is_amd_format) {
6bbd11
 		unsigned long timestamp = get_amd_timestamp(ctxt);
6bbd11
 		if (timestamp > ctxt->timestamp) {
6bbd11
 			ctxt->timestamp = timestamp;
6bbd11
@@ -3457,7 +3455,7 @@ static int check_map_indirect(struct aut
6bbd11
 	}
6bbd11
 	pthread_setcancelstate(cur_state, NULL);
6bbd11
 
6bbd11
-	if (!(source->flags & MAP_FLAG_FORMAT_AMD)) {
6bbd11
+	if (!is_amd_format) {
6bbd11
 		/*
6bbd11
 		 * Check for map change and update as needed for
6bbd11
 		 * following cache lookup.
6bbd11
--- autofs-5.0.7.orig/modules/lookup_nisplus.c
6bbd11
+++ autofs-5.0.7/modules/lookup_nisplus.c
6bbd11
@@ -339,6 +339,7 @@ static int match_key(struct autofs_point
6bbd11
 		     const char *key, int key_len,
6bbd11
 		     struct lookup_context *ctxt)
6bbd11
 {
6bbd11
+	unsigned int is_amd_format = source->flags & MAP_FLAG_FORMAT_AMD;
6bbd11
 	char buf[MAX_ERR_BUF];
6bbd11
 	char *lkp_key;
6bbd11
 	char *prefix;
6bbd11
@@ -347,12 +348,9 @@ static int match_key(struct autofs_point
6bbd11
 	ret = lookup_one(ap, source, key, key_len, ctxt);
6bbd11
 	if (ret < 0)
6bbd11
 		return ret;
6bbd11
-	if (ret == CHE_OK || ret == CHE_UPDATED)
6bbd11
+	if (ret == CHE_OK || ret == CHE_UPDATED || is_amd_format)
6bbd11
 		return ret;
6bbd11
 
6bbd11
-	if (!(source->flags & MAP_FLAG_FORMAT_AMD))
6bbd11
-		return CHE_FAIL;
6bbd11
-
6bbd11
 	lkp_key = strdup(key);
6bbd11
 	if (!lkp_key) {
6bbd11
 		char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
6bbd11
@@ -504,6 +502,7 @@ static int check_map_indirect(struct aut
6bbd11
 			      char *key, int key_len,
6bbd11
 			      struct lookup_context *ctxt)
6bbd11
 {
6bbd11
+	unsigned int is_amd_format = source->flags & MAP_FLAG_FORMAT_AMD;
6bbd11
 	struct mapent_cache *mc;
6bbd11
 	struct mapent *me, *exists;
6bbd11
 	time_t now = time(NULL);
6bbd11
@@ -512,7 +511,7 @@ static int check_map_indirect(struct aut
6bbd11
 
6bbd11
 	mc = source->mc;
6bbd11
 
6bbd11
-	if (source->flags & MAP_FLAG_FORMAT_AMD) {
6bbd11
+	if (is_amd_format) {
6bbd11
 		/* Check for a /defaults entry to update the map source */
6bbd11
 		if (lookup_amd_defaults(ap, source, ctxt) == CHE_FAIL) {
6bbd11
 			warn(ap->logopt, MODPREFIX
6bbd11
@@ -559,7 +558,7 @@ static int check_map_indirect(struct aut
6bbd11
 		}
6bbd11
 		me = cache_lookup_next(mc, me);
6bbd11
 	}
6bbd11
-	if (source->flags & MAP_FLAG_FORMAT_AMD)
6bbd11
+	if (is_amd_format)
6bbd11
 		exists = match_cached_key(ap, MODPREFIX, source, key);
6bbd11
 	else
6bbd11
 		exists = cache_lookup_distinct(mc, key);
6bbd11
--- autofs-5.0.7.orig/modules/lookup_program.c
6bbd11
+++ autofs-5.0.7/modules/lookup_program.c
6bbd11
@@ -382,7 +382,7 @@ static int match_key(struct autofs_point
6bbd11
 	char *prefix;
6bbd11
 	int ret;
6bbd11
 
6bbd11
-	if (source->flags & MAP_FLAG_FORMAT_AMD) {
6bbd11
+	if (is_amd_format) {
6bbd11
 		ret = lookup_amd_defaults(ap, source, ctxt);
6bbd11
 		if (ret != NSS_STATUS_SUCCESS) {
6bbd11
 			warn(ap->logopt,
6bbd11
@@ -420,7 +420,7 @@ static int match_key(struct autofs_point
6bbd11
 	ment = lookup_one(ap, lkp_key, lkp_len, ctxt);
6bbd11
 	if (ment) {
6bbd11
 		char *start = ment;
6bbd11
-		if (source->flags & MAP_FLAG_FORMAT_AMD) {
6bbd11
+		if (is_amd_format) {
6bbd11
 			start = ment + lkp_len;
6bbd11
 			while (isblank(*start))
6bbd11
 				start++;
6bbd11
--- autofs-5.0.7.orig/modules/lookup_yp.c
6bbd11
+++ autofs-5.0.7/modules/lookup_yp.c
6bbd11
@@ -457,6 +457,7 @@ static int match_key(struct autofs_point
6bbd11
 		     const char *key, int key_len,
6bbd11
 		     struct lookup_context *ctxt)
6bbd11
 {
6bbd11
+	unsigned int is_amd_format = source->flags & MAP_FLAG_FORMAT_AMD;
6bbd11
 	char buf[MAX_ERR_BUF];
6bbd11
 	char *lkp_key;
6bbd11
 	char *prefix;
6bbd11
@@ -465,12 +466,9 @@ static int match_key(struct autofs_point
6bbd11
 	ret = lookup_one(ap, source, key, strlen(key), ctxt);
6bbd11
 	if (ret < 0)
6bbd11
 		return ret;
6bbd11
-	if (ret == CHE_OK || ret == CHE_UPDATED)
6bbd11
+	if (ret == CHE_OK || ret == CHE_UPDATED || !is_amd_format)
6bbd11
 		return ret;
6bbd11
 
6bbd11
-	if (!(source->flags & MAP_FLAG_FORMAT_AMD))
6bbd11
-		return CHE_FAIL;
6bbd11
-
6bbd11
 	lkp_key = strdup(key);
6bbd11
 	if (!lkp_key) {
6bbd11
 		char *estr = strerror_r(errno, buf, MAX_ERR_BUF);