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

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