1
#! /bin/sh /usr/share/dpatch/dpatch-run
2
## 01UPSTREAM_autofs-5.0.3-lookup-next-soucre-stale-entry.patch
3
## DP: Supplied by upstream.
8
autofs-5.0.3 - multi-map doesn't pickup NIS updates automatically
10
From: Ian Kent <raven@themaw.net>
12
In a multi-map configuration, autofs doesn't pick up NIS updates
13
automatically. This is caused by the lookup not checking alternate
14
sources for the given key (or wildcard) when doing a key lookup.
19
modules/lookup_file.c | 11 ++++++++---
20
modules/lookup_ldap.c | 11 ++++++++---
21
modules/lookup_nisplus.c | 11 ++++++++---
22
modules/lookup_yp.c | 11 ++++++++---
23
6 files changed, 35 insertions(+), 12 deletions(-)
26
diff --git a/CHANGELOG b/CHANGELOG
27
index 268fca6..3ed84d3 100644
31
- fix incorrect pthreads condition handling for mount requests.
32
- add check for exports automatically mounted by NFS kernel client.
33
- update nsswitch parser to ignore nsswitch sources that aren't supported.
34
+- check for map key in (possible) alternate map sources when doing lookup.
36
14/01/2008 autofs-5.0.3
37
-----------------------
38
diff --git a/lib/cache.c b/lib/cache.c
39
index 55586a3..d5abab0 100644
42
@@ -700,6 +700,8 @@ int cache_update(struct mapent_cache *mc, struct map_source *ms, const char *key
45
me = cache_lookup(mc, key);
46
+ while (me && me->source != ms)
47
+ me = cache_lookup_key_next(me);
48
if (!me || (*me->key == '*' && *key != '*')) {
49
ret = cache_add(mc, ms, key, mapent, age);
51
diff --git a/modules/lookup_file.c b/modules/lookup_file.c
52
index 466690a..894f6fd 100644
53
--- a/modules/lookup_file.c
54
+++ b/modules/lookup_file.c
55
@@ -1116,9 +1116,14 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
58
me = cache_lookup(mc, key);
59
- /* Stale mapent => check for wildcard */
60
- if (me && !me->mapent)
61
- me = cache_lookup_distinct(mc, "*");
62
+ /* Stale mapent => check for entry in alternate source or wildcard */
63
+ if (me && !me->mapent) {
64
+ while ((me = cache_lookup_key_next(me)))
65
+ if (me->source == source)
68
+ me = cache_lookup_distinct(mc, "*");
70
if (me && (me->source == source || *me->key == '/')) {
71
pthread_cleanup_push(cache_lock_cleanup, mc);
72
mapent_len = strlen(me->mapent);
73
diff --git a/modules/lookup_ldap.c b/modules/lookup_ldap.c
74
index ded26f7..5cc2148 100644
75
--- a/modules/lookup_ldap.c
76
+++ b/modules/lookup_ldap.c
77
@@ -2596,9 +2596,14 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
80
me = cache_lookup(mc, key);
81
- /* Stale mapent => check for wildcard */
82
- if (me && !me->mapent)
83
- me = cache_lookup_distinct(mc, "*");
84
+ /* Stale mapent => check for entry in alternate source or wildcard */
85
+ if (me && !me->mapent) {
86
+ while ((me = cache_lookup_key_next(me)))
87
+ if (me->source == source)
90
+ me = cache_lookup_distinct(mc, "*");
92
if (me && (me->source == source || *me->key == '/')) {
93
mapent_len = strlen(me->mapent);
94
mapent = alloca(mapent_len + 1);
95
diff --git a/modules/lookup_nisplus.c b/modules/lookup_nisplus.c
96
index 628ffcf..3c19fd3 100644
97
--- a/modules/lookup_nisplus.c
98
+++ b/modules/lookup_nisplus.c
99
@@ -530,9 +530,14 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
102
me = cache_lookup(mc, key);
103
- /* Stale mapent => check for wildcard */
104
- if (me && !me->mapent)
105
- me = cache_lookup_distinct(mc, "*");
106
+ /* Stale mapent => check for entry in alternate source or wildcard */
107
+ if (me && !me->mapent) {
108
+ while ((me = cache_lookup_key_next(me)))
109
+ if (me->source == source)
112
+ me = cache_lookup_distinct(mc, "*");
114
if (me && (me->source == source || *me->key == '/')) {
115
mapent_len = strlen(me->mapent);
116
mapent = alloca(mapent_len + 1);
117
diff --git a/modules/lookup_yp.c b/modules/lookup_yp.c
118
index 0fc84f8..14f981c 100644
119
--- a/modules/lookup_yp.c
120
+++ b/modules/lookup_yp.c
121
@@ -636,9 +636,14 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
124
me = cache_lookup(mc, key);
125
- /* Stale mapent => check for wildcard */
126
- if (me && !me->mapent)
127
- me = cache_lookup_distinct(mc, "*");
128
+ /* Stale mapent => check for entry in alternate source or wildcard */
129
+ if (me && !me->mapent) {
130
+ while ((me = cache_lookup_key_next(me)))
131
+ if (me->source == source)
134
+ me = cache_lookup_distinct(mc, "*");
136
if (me && (me->source == source || *me->key == '/')) {
137
mapent_len = strlen(me->mapent);
138
mapent = alloca(mapent_len + 1);