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

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