Blame SOURCES/autofs-5.1.3-improve-debug-logging-of-lookup-key.patch

cef8f8
autofs-5.1.3 - improve debug logging of lookup key
cef8f8
cef8f8
From: Ian Kent <raven@themaw.net>
cef8f8
cef8f8
When looking up an amd format map key, if there is a prefix it
cef8f8
will be used in matching the map key.
cef8f8
cef8f8
So print the actual matched key string in debug log output.
cef8f8
cef8f8
Signed-off-by: Ian Kent <raven@themaw.net>
cef8f8
---
cef8f8
 CHANGELOG                |    1 +
cef8f8
 modules/lookup_file.c    |   14 ++++++++++----
cef8f8
 modules/lookup_hesiod.c  |   20 +++++++++++++++++---
cef8f8
 modules/lookup_ldap.c    |   15 ++++++++++++---
cef8f8
 modules/lookup_nisplus.c |   15 ++++++++++++---
cef8f8
 modules/lookup_yp.c      |   43 +++++++++++++++++++++++++------------------
cef8f8
 6 files changed, 77 insertions(+), 31 deletions(-)
cef8f8
cef8f8
--- autofs-5.0.7.orig/CHANGELOG
cef8f8
+++ autofs-5.0.7/CHANGELOG
cef8f8
@@ -266,6 +266,7 @@
cef8f8
 - handle additional nfs versions in mount_nfs.c.
cef8f8
 - improve description of mount_nfs_default_protocol.
cef8f8
 - reset master map list on startup retry.
cef8f8
+- improve debug logging of lookup key.
cef8f8
 
cef8f8
 25/07/2012 autofs-5.0.7
cef8f8
 =======================
cef8f8
--- autofs-5.0.7.orig/modules/lookup_file.c
cef8f8
+++ autofs-5.0.7/modules/lookup_file.c
cef8f8
@@ -1290,18 +1290,24 @@ do_cache_lookup:
cef8f8
 		}
cef8f8
 	}
cef8f8
 	cache_unlock(mc);
cef8f8
-	free(lkp_key);
cef8f8
 
cef8f8
-	if (!me)
cef8f8
+	if (!me) {
cef8f8
+		free(lkp_key);
cef8f8
 		return NSS_STATUS_NOTFOUND;
cef8f8
+	}
cef8f8
 
cef8f8
-	if (!mapent)
cef8f8
+	if (!mapent) {
cef8f8
+		free(lkp_key);
cef8f8
 		return NSS_STATUS_TRYAGAIN;
cef8f8
+	}
cef8f8
+
cef8f8
+	debug(ap->logopt, MODPREFIX "%s -> %s", lkp_key, mapent);
cef8f8
+
cef8f8
+	free(lkp_key);
cef8f8
 
cef8f8
 	master_source_current_wait(ap->entry);
cef8f8
 	ap->entry->current = source;
cef8f8
 
cef8f8
-	debug(ap->logopt, MODPREFIX "%s -> %s", key, mapent);
cef8f8
 	ret = ctxt->parse->parse_mount(ap, key, key_len,
cef8f8
 				       mapent, ctxt->parse->context);
cef8f8
 	if (ret) {
cef8f8
--- autofs-5.0.7.orig/modules/lookup_hesiod.c
cef8f8
+++ autofs-5.0.7/modules/lookup_hesiod.c
cef8f8
@@ -466,14 +466,28 @@ int lookup_mount(struct autofs_point *ap
cef8f8
 	}
cef8f8
 
cef8f8
 	me = match_cached_key(ap, MODPREFIX, source, lkp_key);
cef8f8
-	free(lkp_key);
cef8f8
-	if (!me)
cef8f8
+
cef8f8
+	if (!me) {
cef8f8
+		free(lkp_key);
cef8f8
 		return NSS_STATUS_NOTFOUND;
cef8f8
+	}
cef8f8
 
cef8f8
-	if (!me->mapent)
cef8f8
+	if (!me->mapent) {
cef8f8
+		free(lkp_key);
cef8f8
 		return NSS_STATUS_UNAVAIL;
cef8f8
+	}
cef8f8
 
cef8f8
 	mapent = strdup(me->mapent);
cef8f8
+	if (!mapent) {
cef8f8
+		char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
cef8f8
+		error(ap->logopt, "malloc: %s", estr);
cef8f8
+		free(lkp_key);
cef8f8
+		return NSS_STATUS_UNKNOWN;
cef8f8
+	}
cef8f8
+
cef8f8
+	debug(ap->logopt, MODPREFIX "%s -> %s", lkp_key, mapent);
cef8f8
+
cef8f8
+	free(lkp_key);
cef8f8
 
cef8f8
 	rv = ctxt->parser->parse_mount(ap, key, key_len,
cef8f8
 				       mapent, ctxt->parser->context);
cef8f8
--- autofs-5.0.7.orig/modules/lookup_ldap.c
cef8f8
+++ autofs-5.0.7/modules/lookup_ldap.c
cef8f8
@@ -3785,15 +3785,24 @@ int lookup_mount(struct autofs_point *ap
cef8f8
 		}
cef8f8
 	}
cef8f8
 	cache_unlock(mc);
cef8f8
-	free(lkp_key);
cef8f8
 
cef8f8
-	if (!mapent)
cef8f8
+	if (!me) {
cef8f8
+		free(lkp_key);
cef8f8
+		return NSS_STATUS_NOTFOUND;
cef8f8
+	}
cef8f8
+
cef8f8
+	if (!mapent) {
cef8f8
+		free(lkp_key);
cef8f8
 		return NSS_STATUS_TRYAGAIN;
cef8f8
+	}
cef8f8
+
cef8f8
+	debug(ap->logopt, MODPREFIX "%s -> %s", lkp_key, mapent);
cef8f8
+
cef8f8
+	free(lkp_key);
cef8f8
 
cef8f8
 	master_source_current_wait(ap->entry);
cef8f8
 	ap->entry->current = source;
cef8f8
 
cef8f8
-	debug(ap->logopt, MODPREFIX "%s -> %s", key, mapent);
cef8f8
 	ret = ctxt->parse->parse_mount(ap, key, key_len,
cef8f8
 				       mapent, ctxt->parse->context);
cef8f8
 	if (ret) {
cef8f8
--- autofs-5.0.7.orig/modules/lookup_nisplus.c
cef8f8
+++ autofs-5.0.7/modules/lookup_nisplus.c
cef8f8
@@ -824,15 +824,24 @@ int lookup_mount(struct autofs_point *ap
cef8f8
 		}
cef8f8
 	}
cef8f8
 	cache_unlock(mc);
cef8f8
-	free(lkp_key);
cef8f8
 
cef8f8
-	if (!mapent)
cef8f8
+	if (!me) {
cef8f8
+		free(lkp_key);
cef8f8
+		return NSS_STATUS_NOTFOUND;
cef8f8
+	}
cef8f8
+
cef8f8
+	if (!mapent) {
cef8f8
+		free(lkp_key);
cef8f8
 		return NSS_STATUS_TRYAGAIN;
cef8f8
+	}
cef8f8
+
cef8f8
+	debug(ap->logopt, MODPREFIX "%s -> %s", lkp_key, mapent);
cef8f8
+
cef8f8
+	free(lkp_key);
cef8f8
 
cef8f8
 	master_source_current_wait(ap->entry);
cef8f8
 	ap->entry->current = source;
cef8f8
 
cef8f8
-	debug(ap->logopt, MODPREFIX "%s -> %s", key, mapent);
cef8f8
 	ret = ctxt->parse->parse_mount(ap, key, key_len,
cef8f8
 				       mapent, ctxt->parse->context);
cef8f8
 	if (ret) {
cef8f8
--- autofs-5.0.7.orig/modules/lookup_yp.c
cef8f8
+++ autofs-5.0.7/modules/lookup_yp.c
cef8f8
@@ -928,28 +928,35 @@ int lookup_mount(struct autofs_point *ap
cef8f8
 		}
cef8f8
 	}
cef8f8
 	cache_unlock(mc);
cef8f8
+
cef8f8
+	if (!me) {
cef8f8
+		free(lkp_key);
cef8f8
+		return NSS_STATUS_NOTFOUND;
cef8f8
+	}
cef8f8
+
cef8f8
+	if (!mapent) {
cef8f8
+		free(lkp_key);
cef8f8
+		return NSS_STATUS_TRYAGAIN;
cef8f8
+	}
cef8f8
+
cef8f8
+	debug(ap->logopt, MODPREFIX "%s -> %s", lkp_key, mapent);
cef8f8
+
cef8f8
 	free(lkp_key);
cef8f8
 
cef8f8
-	if (mapent) {
cef8f8
-		master_source_current_wait(ap->entry);
cef8f8
-		ap->entry->current = source;
cef8f8
-
cef8f8
-		debug(ap->logopt, MODPREFIX "%s -> %s", key, mapent);
cef8f8
-		ret = ctxt->parse->parse_mount(ap, key, key_len,
cef8f8
-					       mapent, ctxt->parse->context);
cef8f8
-		if (ret) {
cef8f8
-			/* Don't update negative cache when re-connecting */
cef8f8
-			if (ap->flags & MOUNT_FLAG_REMOUNT)
cef8f8
-				return NSS_STATUS_TRYAGAIN;
cef8f8
-			cache_writelock(mc);
cef8f8
-			cache_update_negative(mc, source, key, ap->negative_timeout);
cef8f8
-			cache_unlock(mc);
cef8f8
-			return NSS_STATUS_TRYAGAIN;
cef8f8
-		}
cef8f8
-	 }
cef8f8
+	master_source_current_wait(ap->entry);
cef8f8
+	ap->entry->current = source;
cef8f8
 
cef8f8
-	if (ret)
cef8f8
+	ret = ctxt->parse->parse_mount(ap, key, key_len,
cef8f8
+				       mapent, ctxt->parse->context);
cef8f8
+	if (ret) {
cef8f8
+		/* Don't update negative cache when re-connecting */
cef8f8
+		if (ap->flags & MOUNT_FLAG_REMOUNT)
cef8f8
+			return NSS_STATUS_TRYAGAIN;
cef8f8
+		cache_writelock(mc);
cef8f8
+		cache_update_negative(mc, source, key, ap->negative_timeout);
cef8f8
+		cache_unlock(mc);
cef8f8
 		return NSS_STATUS_TRYAGAIN;
cef8f8
+	}
cef8f8
 
cef8f8
 	return NSS_STATUS_SUCCESS;
cef8f8
 }