aboutsummaryrefslogtreecommitdiffstats
path: root/meta-networking/recipes-daemons/autofs/autofs-5.0.7/autofs-5.0.7-fix-wildcard-multi-map-regression.patch
blob: 44e4a18e32d45d3b8bd07fbc7b83323bcbab7920 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
autofs-5.0.7 - fix wildcard multi map regression

From: Ian Kent <raven@themaw.net>

A recent patch that removed code to add the current map entry when
being parsed if it didn't already exist cause wildcard indirect
multi-mount map entries to fail to mount.

Indirect multi-mount map entries need the entry matched by a wildcard
lookup to be added to the map entry cache because subsequent operations
expect a distinct map entry to be present or they will fail. This is
what the code that was removed did but it did so in the wrong place
which caused a deadlock situation.
---
 CHANGELOG                |    1 +
 modules/lookup_file.c    |   23 ++++++++++++++++-------
 modules/lookup_ldap.c    |   19 +++++++++++++++----
 modules/lookup_nisplus.c |   21 ++++++++++++++++-----
 modules/lookup_sss.c     |   17 ++++++++++++++---
 modules/lookup_yp.c      |   21 ++++++++++++++++-----
 6 files changed, 78 insertions(+), 24 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 97d6f48..46ef335 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -29,6 +29,7 @@
 - modules/replicated.c: use sin6_addr.s6_addr32.
 - workaround missing GNU versionsort extension.
 - dont fail on master map self include.
+- fix wildcard multi map regression.
 
 25/07/2012 autofs-5.0.7
 =======================
diff --git a/modules/lookup_file.c b/modules/lookup_file.c
index f37bed9..65e5ee6 100644
--- a/modules/lookup_file.c
+++ b/modules/lookup_file.c
@@ -1040,7 +1040,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
 			return NSS_STATUS_UNAVAIL;
 		}
 
-		cache_readlock(mc);
+		cache_writelock(mc);
 		me = cache_lookup_first(mc);
 		if (me && st.st_mtime <= me->age) {
 			/*
@@ -1082,7 +1082,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
 		}
 	}
 
-	cache_readlock(mc);
+	cache_writelock(mc);
 do_cache_lookup:
 	me = cache_lookup(mc, key);
 	/*
@@ -1098,11 +1098,20 @@ do_cache_lookup:
 		if (!me)
 			me = cache_lookup_distinct(mc, "*");
 	}
-	if (me && me->mapent && (me->source == source || *me->key == '/')) {
-		pthread_cleanup_push(cache_lock_cleanup, mc);
-		strcpy(mapent_buf, me->mapent);
-		mapent = mapent_buf;
-		pthread_cleanup_pop(0);
+	if (me && me->mapent) {
+		/*
+		 * Add wildcard match for later validation checks and
+		 * negative cache lookups.
+		 */
+		if (ap->type == LKP_INDIRECT && *me->key == '*') {
+			ret = cache_update(mc, source, key, me->mapent, me->age);
+			if (!(ret & (CHE_OK | CHE_UPDATED)))
+				me = NULL;
+		}
+		if (me && (me->source == source || *me->key == '/')) {
+			strcpy(mapent_buf, me->mapent);
+			mapent = mapent_buf;
+		}
 	}
 	cache_unlock(mc);
 
diff --git a/modules/lookup_ldap.c b/modules/lookup_ldap.c
index 431e50d..83e3215 100644
--- a/modules/lookup_ldap.c
+++ b/modules/lookup_ldap.c
@@ -2969,7 +2969,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
 			return status;
 	}
 
-	cache_readlock(mc);
+	cache_writelock(mc);
 	me = cache_lookup(mc, key);
 	/* Stale mapent => check for entry in alternate source or wildcard */
 	if (me && !me->mapent) {
@@ -2979,9 +2979,20 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
 		if (!me)
 			me = cache_lookup_distinct(mc, "*");
 	}
-	if (me && me->mapent && (me->source == source || *me->key == '/')) {
-		strcpy(mapent_buf, me->mapent);
-		mapent = mapent_buf;
+	if (me && me->mapent) {
+		/*
+		 * Add wildcard match for later validation checks and
+		 * negative cache lookups.
+		 */
+		if (ap->type == LKP_INDIRECT && *me->key == '*') {
+			ret = cache_update(mc, source, key, me->mapent, me->age);
+			if (!(ret & (CHE_OK | CHE_UPDATED)))
+				me = NULL;
+		}
+		if (me && (me->source == source || *me->key == '/')) {
+			strcpy(mapent_buf, me->mapent);
+			mapent = mapent_buf;
+		}
 	}
 	cache_unlock(mc);
 
diff --git a/modules/lookup_nisplus.c b/modules/lookup_nisplus.c
index 9fced96..8237a1e 100644
--- a/modules/lookup_nisplus.c
+++ b/modules/lookup_nisplus.c
@@ -561,7 +561,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
 			return status;
 	}
 
-	cache_readlock(mc);
+	cache_writelock(mc);
 	me = cache_lookup(mc, key);
 	/* Stale mapent => check for entry in alternate source or wildcard */
 	if (me && !me->mapent) {
@@ -571,10 +571,21 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
 		if (!me)
 			me = cache_lookup_distinct(mc, "*");
 	}
-	if (me && me->mapent && (me->source == source || *me->key == '/')) {
-		mapent_len = strlen(me->mapent);
-		mapent = malloc(mapent_len + 1);
-		strcpy(mapent, me->mapent);
+	if (me && me->mapent) {
+		/*
+		 * Add wildcard match for later validation checks and
+		 * negative cache lookups.
+		 */
+		if (ap->type == LKP_INDIRECT && *me->key == '*') {
+			ret = cache_update(mc, source, key, me->mapent, me->age);
+			if (!(ret & (CHE_OK | CHE_UPDATED)))
+				me = NULL;
+		}
+		if (me && (me->source == source || *me->key == '/')) {
+			mapent_len = strlen(me->mapent);
+			mapent = malloc(mapent_len + 1);
+			strcpy(mapent, me->mapent);
+		}
 	}
 	cache_unlock(mc);
 
diff --git a/modules/lookup_sss.c b/modules/lookup_sss.c
index e0b84cc..5c2ed0a 100644
--- a/modules/lookup_sss.c
+++ b/modules/lookup_sss.c
@@ -645,9 +645,20 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
 		if (!me)
 			me = cache_lookup_distinct(mc, "*");
 	}
-	if (me && me->mapent && (me->source == source || *me->key == '/')) {
-		strcpy(mapent_buf, me->mapent);
-		mapent = mapent_buf;
+	if (me && me->mapent) {
+		/*
+		 * Add wildcard match for later validation checks and
+		 * negative cache lookups.
+		 */
+		if (ap->type == LKP_INDIRECT && *me->key == '*') {
+			ret = cache_update(mc, source, key, me->mapent, me->age);
+			if (!(ret & (CHE_OK | CHE_UPDATED)))
+				me = NULL;
+		}
+		if (me && (me->source == source || *me->key == '/')) {
+			strcpy(mapent_buf, me->mapent);
+			mapent = mapent_buf;
+		}
 	}
 	cache_unlock(mc);
 
diff --git a/modules/lookup_yp.c b/modules/lookup_yp.c
index 720df2e..a716e1f 100644
--- a/modules/lookup_yp.c
+++ b/modules/lookup_yp.c
@@ -662,7 +662,7 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
 			return status;
 	}
 
-	cache_readlock(mc);
+	cache_writelock(mc);
 	me = cache_lookup(mc, key);
 	/* Stale mapent => check for entry in alternate source or wildcard */
 	if (me && !me->mapent) {
@@ -672,10 +672,21 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
 		if (!me)
 			me = cache_lookup_distinct(mc, "*");
 	}
-	if (me && me->mapent && (me->source == source || *me->key == '/')) {
-		mapent_len = strlen(me->mapent);
-		mapent = alloca(mapent_len + 1);
-		strcpy(mapent, me->mapent);
+	if (me && me->mapent) {
+		/*
+		 * Add wildcard match for later validation checks and
+		 * negative cache lookups.
+		 */
+		if (ap->type == LKP_INDIRECT && *me->key == '*') {
+			ret = cache_update(mc, source, key, me->mapent, me->age);
+			if (!(ret & (CHE_OK | CHE_UPDATED)))
+				me = NULL;
+		}
+		if (me && (me->source == source || *me->key == '/')) {
+			mapent_len = strlen(me->mapent);
+			mapent = alloca(mapent_len + 1);
+			strcpy(mapent, me->mapent);
+		}
 	}
 	cache_unlock(mc);