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

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