Ian Kent 3685ec
autofs-5.0.3 - fix multi source messages
Ian Kent 3685ec
Ian Kent 3685ec
From: Ian Kent <raven@themaw.net>
Ian Kent 3685ec
Ian Kent 3685ec
There are incorrect "key not found" messages seen for master map
Ian Kent 3685ec
entries that have multiple sources (direct mounts).
Ian Kent 3685ec
Ian Kent 3685ec
For example, for the direct mount entries:
Ian Kent 3685ec
Ian Kent 3685ec
/-    auto.one
Ian Kent 3685ec
/-    auto.two
Ian Kent 3685ec
Ian Kent 3685ec
if a mount lookup is done and is not found in auto.one we see a
Ian Kent 3685ec
not found message even though it may be found in auto.two.
Ian Kent 3685ec
Ian Kent 3685ec
This patch moves the "key not found" reporting out to the higher
Ian Kent 3685ec
level lookup and reports status at the end of the lookup.
Ian Kent 3685ec
---
Ian Kent 3685ec
Ian Kent 3685ec
 daemon/lookup.c          |    3 +++
Ian Kent 3685ec
 modules/lookup_file.c    |   11 ++---------
Ian Kent 3685ec
 modules/lookup_ldap.c    |   10 ++--------
Ian Kent 3685ec
 modules/lookup_nisplus.c |   12 +++---------
Ian Kent 3685ec
 modules/lookup_program.c |    2 +-
Ian Kent 3685ec
 modules/lookup_yp.c      |   10 ++--------
Ian Kent 3685ec
 6 files changed, 13 insertions(+), 35 deletions(-)
Ian Kent 3685ec
Ian Kent 3685ec
Ian Kent 3685ec
diff --git a/daemon/lookup.c b/daemon/lookup.c
Ian Kent 3685ec
index 3c22a35..d33aadc 100644
Ian Kent 3685ec
--- a/daemon/lookup.c
Ian Kent 3685ec
+++ b/daemon/lookup.c
Ian Kent 3685ec
@@ -903,6 +903,9 @@ int lookup_nss_mount(struct autofs_point *ap, struct map_source *source, const c
Ian Kent 3685ec
 	send_map_update_request(ap);
Ian Kent 3685ec
 	pthread_cleanup_pop(1);
Ian Kent 3685ec
 
Ian Kent 3685ec
+	if (result == NSS_STATUS_NOTFOUND)
Ian Kent 3685ec
+		error(ap->logopt, "key \"%s\" not found in map.", name);
Ian Kent 3685ec
+
Ian Kent 3685ec
 	return !result;
Ian Kent 3685ec
 }
Ian Kent 3685ec
 
Ian Kent 3685ec
diff --git a/modules/lookup_file.c b/modules/lookup_file.c
Ian Kent 3685ec
index 894f6fd..807ceab 100644
Ian Kent 3685ec
--- a/modules/lookup_file.c
Ian Kent 3685ec
+++ b/modules/lookup_file.c
Ian Kent 3685ec
@@ -1074,7 +1074,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
Ian Kent 3685ec
 	me = cache_lookup_distinct(mc, key);
Ian Kent 3685ec
 	if (me && me->status >= time(NULL)) {
Ian Kent 3685ec
 		cache_unlock(mc);
Ian Kent 3685ec
-		return NSS_STATUS_NOTFOUND;
Ian Kent 3685ec
+		return NSS_STATUS_UNAVAIL;
Ian Kent 3685ec
 	}
Ian Kent 3685ec
 	cache_unlock(mc);
Ian Kent 3685ec
 
Ian Kent 3685ec
@@ -1105,11 +1105,6 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
Ian Kent 3685ec
 		if (status) {
Ian Kent 3685ec
 			if (status == NSS_STATUS_COMPLETED)
Ian Kent 3685ec
 				return NSS_STATUS_SUCCESS;
Ian Kent 3685ec
-
Ian Kent 3685ec
-			error(ap->logopt,
Ian Kent 3685ec
-			      MODPREFIX "key \"%s\" not found in map",
Ian Kent 3685ec
-			      name);
Ian Kent 3685ec
-
Ian Kent 3685ec
 			return NSS_STATUS_NOTFOUND;
Ian Kent 3685ec
 		}
Ian Kent 3685ec
 	}
Ian Kent 3685ec
@@ -1154,9 +1149,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
Ian Kent 3685ec
 			}
Ian Kent 3685ec
 			cache_unlock(mc);
Ian Kent 3685ec
 		}
Ian Kent 3685ec
-	} else
Ian Kent 3685ec
-		error(ap->logopt,
Ian Kent 3685ec
-		      MODPREFIX "key \"%s\" not found in map.", name);
Ian Kent 3685ec
+	}
Ian Kent 3685ec
 
Ian Kent 3685ec
 	if (ret)
Ian Kent 3685ec
 		return NSS_STATUS_TRYAGAIN;
Ian Kent 3685ec
diff --git a/modules/lookup_ldap.c b/modules/lookup_ldap.c
Ian Kent 3685ec
index 5cc2148..7777e90 100644
Ian Kent 3685ec
--- a/modules/lookup_ldap.c
Ian Kent 3685ec
+++ b/modules/lookup_ldap.c
Ian Kent 3685ec
@@ -2586,12 +2586,8 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
Ian Kent 3685ec
 
Ian Kent 3685ec
 		status = check_map_indirect(ap, lkp_key, strlen(lkp_key), ctxt);
Ian Kent 3685ec
 		free(lkp_key);
Ian Kent 3685ec
-		if (status) {
Ian Kent 3685ec
-			error(ap->logopt,
Ian Kent 3685ec
-			      MODPREFIX "key \"%s\" not found in map",
Ian Kent 3685ec
-			      name);
Ian Kent 3685ec
+		if (status)
Ian Kent 3685ec
 			return status;
Ian Kent 3685ec
-		}
Ian Kent 3685ec
 	}
Ian Kent 3685ec
 
Ian Kent 3685ec
 	cache_readlock(mc);
Ian Kent 3685ec
@@ -2633,9 +2629,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
Ian Kent 3685ec
 			}
Ian Kent 3685ec
 			cache_unlock(mc);
Ian Kent 3685ec
 		}
Ian Kent 3685ec
-	} else
Ian Kent 3685ec
-		error(ap->logopt,
Ian Kent 3685ec
-		      MODPREFIX "key \"%s\" not found in map", name);
Ian Kent 3685ec
+	}
Ian Kent 3685ec
 
Ian Kent 3685ec
 	if (ret)
Ian Kent 3685ec
 		return NSS_STATUS_TRYAGAIN;
Ian Kent 3685ec
diff --git a/modules/lookup_nisplus.c b/modules/lookup_nisplus.c
Ian Kent 3685ec
index 3c19fd3..4666161 100644
Ian Kent 3685ec
--- a/modules/lookup_nisplus.c
Ian Kent 3685ec
+++ b/modules/lookup_nisplus.c
Ian Kent 3685ec
@@ -520,12 +520,8 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
Ian Kent 3685ec
 		ap->entry->current = source;
Ian Kent 3685ec
 
Ian Kent 3685ec
 		status = check_map_indirect(ap, lkp_key, strlen(lkp_key), ctxt);
Ian Kent 3685ec
-		if (status) {
Ian Kent 3685ec
-			error(ap->logopt,
Ian Kent 3685ec
-			      MODPREFIX "key \"%s\" not found in map",
Ian Kent 3685ec
-			      name);
Ian Kent 3685ec
+		if (status)
Ian Kent 3685ec
 			return status;
Ian Kent 3685ec
-		}
Ian Kent 3685ec
 	}
Ian Kent 3685ec
 
Ian Kent 3685ec
 	cache_readlock(mc);
Ian Kent 3685ec
@@ -566,12 +562,10 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
Ian Kent 3685ec
 			}
Ian Kent 3685ec
 			cache_unlock(mc);
Ian Kent 3685ec
 		}
Ian Kent 3685ec
-	} else
Ian Kent 3685ec
-		error(ap->logopt,
Ian Kent 3685ec
-		      MODPREFIX "key \"%s\" not found in map", name);
Ian Kent 3685ec
+	}
Ian Kent 3685ec
 
Ian Kent 3685ec
 	if (ret)
Ian Kent 3685ec
-		return NSS_STATUS_NOTFOUND;
Ian Kent 3685ec
+		return NSS_STATUS_TRYAGAIN;
Ian Kent 3685ec
 
Ian Kent 3685ec
 	return NSS_STATUS_SUCCESS;
Ian Kent 3685ec
 }
Ian Kent 3685ec
diff --git a/modules/lookup_program.c b/modules/lookup_program.c
Ian Kent 3685ec
index 7c266d6..daf874d 100644
Ian Kent 3685ec
--- a/modules/lookup_program.c
Ian Kent 3685ec
+++ b/modules/lookup_program.c
Ian Kent 3685ec
@@ -390,7 +390,7 @@ out_free:
Ian Kent 3685ec
 			me->status = now + ap->negative_timeout;
Ian Kent 3685ec
 		}
Ian Kent 3685ec
 		cache_unlock(mc);
Ian Kent 3685ec
-		return NSS_STATUS_UNAVAIL;
Ian Kent 3685ec
+		return NSS_STATUS_TRYAGAIN;
Ian Kent 3685ec
 	}
Ian Kent 3685ec
 
Ian Kent 3685ec
 	return NSS_STATUS_SUCCESS;
Ian Kent 3685ec
diff --git a/modules/lookup_yp.c b/modules/lookup_yp.c
Ian Kent 3685ec
index 14f981c..ee06551 100644
Ian Kent 3685ec
--- a/modules/lookup_yp.c
Ian Kent 3685ec
+++ b/modules/lookup_yp.c
Ian Kent 3685ec
@@ -626,12 +626,8 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
Ian Kent 3685ec
 
Ian Kent 3685ec
 		status = check_map_indirect(ap, lkp_key, strlen(lkp_key), ctxt);
Ian Kent 3685ec
 		free(lkp_key);
Ian Kent 3685ec
-		if (status) {
Ian Kent 3685ec
-			error(ap->logopt,
Ian Kent 3685ec
-			      MODPREFIX "key \"%s\" not found in map",
Ian Kent 3685ec
-			      name);
Ian Kent 3685ec
+		if (status)
Ian Kent 3685ec
 			return status;
Ian Kent 3685ec
-		}
Ian Kent 3685ec
 	}
Ian Kent 3685ec
 
Ian Kent 3685ec
 	cache_readlock(mc);
Ian Kent 3685ec
@@ -672,9 +668,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
Ian Kent 3685ec
 			}
Ian Kent 3685ec
 			cache_unlock(mc);
Ian Kent 3685ec
 		}
Ian Kent 3685ec
-	 } else
Ian Kent 3685ec
-		error(ap->logopt,
Ian Kent 3685ec
-		      MODPREFIX "key \"%s\" not found in map", name);
Ian Kent 3685ec
+	 }
Ian Kent 3685ec
 
Ian Kent 3685ec
 	if (ret)
Ian Kent 3685ec
 		return NSS_STATUS_TRYAGAIN;