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