autofs-5.0.3 - multi-map doesn't pickup NIS updates automatically
From: Ian Kent <raven@themaw.net>
In a multi-map configuration, autofs doesn't pick up NIS updates
automatically. This is caused by the lookup not checking alternate
sources for the given key (or wildcard) when doing a key lookup.
---
lib/cache.c | 2 ++
modules/lookup_file.c | 11 ++++++++---
modules/lookup_ldap.c | 11 ++++++++---
modules/lookup_nisplus.c | 11 ++++++++---
modules/lookup_yp.c | 11 ++++++++---
5 files changed, 34 insertions(+), 12 deletions(-)
--- autofs-5.0.2.orig/lib/cache.c
+++ autofs-5.0.2/lib/cache.c
@@ -700,6 +700,8 @@ int cache_update(struct mapent_cache *mc
int ret = CHE_OK;
me = cache_lookup(mc, key);
+ while (me && me->source != ms)
+ me = cache_lookup_key_next(me);
if (!me || (*me->key == '*' && *key != '*')) {
ret = cache_add(mc, ms, key, mapent, age);
if (!ret) {
--- autofs-5.0.2.orig/modules/lookup_file.c
+++ autofs-5.0.2/modules/lookup_file.c
@@ -1116,9 +1116,14 @@ int lookup_mount(struct autofs_point *ap
cache_readlock(mc);
me = cache_lookup(mc, key);
- /* Stale mapent => check for wildcard */
- if (me && !me->mapent)
- me = cache_lookup_distinct(mc, "*");
+ /* Stale mapent => check for entry in alternate source or wildcard */
+ if (me && !me->mapent) {
+ while ((me = cache_lookup_key_next(me)))
+ if (me->source == source)
+ break;
+ if (!me)
+ me = cache_lookup_distinct(mc, "*");
+ }
if (me && (me->source == source || *me->key == '/')) {
pthread_cleanup_push(cache_lock_cleanup, mc);
mapent_len = strlen(me->mapent);
--- autofs-5.0.2.orig/modules/lookup_ldap.c
+++ autofs-5.0.2/modules/lookup_ldap.c
@@ -2596,9 +2596,14 @@ int lookup_mount(struct autofs_point *ap
cache_readlock(mc);
me = cache_lookup(mc, key);
- /* Stale mapent => check for wildcard */
- if (me && !me->mapent)
- me = cache_lookup_distinct(mc, "*");
+ /* Stale mapent => check for entry in alternate source or wildcard */
+ if (me && !me->mapent) {
+ while ((me = cache_lookup_key_next(me)))
+ if (me->source == source)
+ break;
+ if (!me)
+ me = cache_lookup_distinct(mc, "*");
+ }
if (me && (me->source == source || *me->key == '/')) {
mapent_len = strlen(me->mapent);
mapent = alloca(mapent_len + 1);
--- autofs-5.0.2.orig/modules/lookup_nisplus.c
+++ autofs-5.0.2/modules/lookup_nisplus.c
@@ -530,9 +530,14 @@ int lookup_mount(struct autofs_point *ap
cache_readlock(mc);
me = cache_lookup(mc, key);
- /* Stale mapent => check for wildcard */
- if (me && !me->mapent)
- me = cache_lookup_distinct(mc, "*");
+ /* Stale mapent => check for entry in alternate source or wildcard */
+ if (me && !me->mapent) {
+ while ((me = cache_lookup_key_next(me)))
+ if (me->source == source)
+ break;
+ if (!me)
+ me = cache_lookup_distinct(mc, "*");
+ }
if (me && (me->source == source || *me->key == '/')) {
mapent_len = strlen(me->mapent);
mapent = alloca(mapent_len + 1);
--- autofs-5.0.2.orig/modules/lookup_yp.c
+++ autofs-5.0.2/modules/lookup_yp.c
@@ -628,9 +628,14 @@ int lookup_mount(struct autofs_point *ap
cache_readlock(mc);
me = cache_lookup(mc, key);
- /* Stale mapent => check for wildcard */
- if (me && !me->mapent)
- me = cache_lookup_distinct(mc, "*");
+ /* Stale mapent => check for entry in alternate source or wildcard */
+ if (me && !me->mapent) {
+ while ((me = cache_lookup_key_next(me)))
+ if (me->source == source)
+ break;
+ if (!me)
+ me = cache_lookup_distinct(mc, "*");
+ }
if (me && (me->source == source || *me->key == '/')) {
mapent_len = strlen(me->mapent);
mapent = alloca(mapent_len + 1);