autofs-5.1.8 - fix incorrect matching of cached wildcard key From: Ian Kent During the implementation of amd format map entry support the code to match a cached key was modified. Unfortunately there's a case were the key lookup behaves incorrectly. That case is when there are included maps in the map itself and one of the maps (usually the last) has a wildcard key entry. In this case the wildcard key may be found during lookup but the map it blongs to isn't checked so it can be incorrectly returned instead of a matching entry in a subsequent included map. Another problem case is when there's a wildcard match and a cache prune occurs while the mount is being done. In this case the matched cache entry that has been added is seen as stale and removed along with the mount point directory during the prune leading to a mount fail. Signed-off-by: Ian Kent --- CHANGELOG | 1 + lib/parse_subs.c | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 3a0351cb..58c1cd12 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -93,6 +93,7 @@ - use correct reference for IN6 macro call. - dont probe interface that cant send packet. - fix some sss error return cases. +- fix incorrect matching of cached wildcard key. 19/10/2021 autofs-5.1.8 - add xdr_exports(). diff --git a/lib/parse_subs.c b/lib/parse_subs.c index 3c95996e..de8b6773 100644 --- a/lib/parse_subs.c +++ b/lib/parse_subs.c @@ -566,8 +566,11 @@ struct mapent *match_cached_key(struct autofs_point *ap, while ((me = cache_lookup_key_next(me))) if (me->source == source) break; - if (!me) + if (!me) { me = cache_lookup_distinct(mc, "*"); + if (me && (me->source != source)) + me = NULL; + } } if (!me) @@ -579,7 +582,9 @@ struct mapent *match_cached_key(struct autofs_point *ap, */ if (!(ap->flags & MOUNT_FLAG_REMOUNT) && ap->type == LKP_INDIRECT && *me->key == '*') { - ret = cache_update(mc, source, key, me->mapent, me->age); + time_t now = monotonic_time(NULL); + + ret = cache_update(mc, source, key, me->mapent, now); if (!(ret & (CHE_OK | CHE_UPDATED))) me = NULL; }