]>
Commit | Line | Data |
---|---|---|
ad6a5263 ER |
1 | Index: lighttpd.spec.in |
2 | =================================================================== | |
54b68997 ER |
3 | --- lighttpd.spec.in (.../tags/lighttpd-1.4.19) (revision 2303) |
4 | +++ lighttpd.spec.in (.../branches/lighttpd-1.4.x) (revision 2303) | |
ad6a5263 ER |
5 | @@ -1,83 +0,0 @@ |
6 | -Summary: A fast webserver with minimal memory-footprint (lighttpd) | |
7 | -Name: lighttpd | |
8 | -Version: @VERSION@ | |
9 | -Release: 1 | |
10 | -Source: http://jan.kneschke.de/projects/lighttpd/download/lighttpd-%version.tar.gz | |
11 | -Packager: Jan Kneschke <jan@kneschke.de> | |
12 | -License: BSD | |
13 | -Group: Networking/Daemons | |
14 | -URL: http://www.lighttpd.net/ | |
15 | -Requires: pcre >= 3.1 zlib | |
16 | -BuildRequires: libtool zlib-devel | |
17 | -BuildRoot: %{_tmppath}/%{name}-root | |
18 | - | |
19 | -%description | |
20 | -lighttpd is intented to be a frontend for ad-servers which have to deliver | |
21 | -small files concurrently to many connections. | |
22 | - | |
23 | -Available rpmbuild rebuild options: | |
24 | ---with: ssl mysql lua memcache | |
25 | - | |
26 | -%prep | |
27 | -%setup -q | |
28 | - | |
29 | -%build | |
30 | -rm -rf %{buildroot} | |
31 | -%configure \ | |
32 | - %{?_with_mysql: --with-mysql} \ | |
33 | - %{?_with_lua: --with-lua} \ | |
34 | - %{?_with_memcache: --with-memcache} \ | |
35 | - %{?_with_ssl: --with-openssl} | |
36 | -make | |
37 | - | |
38 | -%install | |
39 | -%makeinstall | |
40 | - | |
41 | -mkdir -p %{buildroot}%{_sysconfdir}/{init.d,sysconfig} | |
42 | -if [ -f /etc/redhat-release -o -f /etc/fedora-release ]; then | |
43 | - install -m 755 doc/rc.lighttpd.redhat %{buildroot}%{_sysconfdir}/init.d/lighttpd | |
44 | -else | |
45 | - install -m 755 doc/rc.lighttpd %{buildroot}%{_sysconfdir}/init.d/lighttpd | |
46 | -fi | |
47 | -install -m 644 doc/sysconfig.lighttpd %{buildroot}%{_sysconfdir}/sysconfig/lighttpd | |
48 | - | |
49 | -%clean | |
50 | -rm -rf %{buildroot} | |
51 | - | |
52 | -%post | |
53 | -## read http://www.fedora.us/docs/spec.html next time :) | |
54 | -if [ "$1" = "1" ]; then | |
55 | - # real install, not upgrade | |
56 | - /sbin/chkconfig --add lighttpd | |
57 | -fi | |
58 | - | |
59 | -%preun | |
60 | -if [ "$1" = "0"]; then | |
61 | - # real uninstall, not upgrade | |
62 | - %{_sysconfdir}/init.d/lighttpd stop | |
63 | - /sbin/chkconfig --del lighttpd | |
64 | -fi | |
65 | - | |
66 | -%files | |
67 | -%defattr(-,root,root) | |
68 | -%doc doc/lighttpd.conf doc/lighttpd.user README INSTALL ChangeLog COPYING AUTHORS | |
69 | -%doc doc/*.txt | |
70 | -%config(noreplace) %attr(0755,root,root) %{_sysconfdir}/init.d/lighttpd | |
71 | -%config(noreplace) %attr(0644,root,root) %{_sysconfdir}/sysconfig/lighttpd | |
72 | -%{_mandir}/* | |
73 | -%{_libdir}/* | |
74 | -%{_sbindir}/* | |
75 | -%{_bindir}/* | |
76 | - | |
77 | -%changelog | |
78 | -* Thu Sep 30 2004 12:41 <jan@kneschke.de> 1.3.1 | |
79 | -- upgraded to 1.3.1 | |
80 | - | |
81 | -* Tue Jun 29 2004 17:26 <jan@kneschke.de> 1.2.3 | |
82 | -- rpmlint'ed the package | |
83 | -- added URL | |
84 | -- added (noreplace) to start-script | |
85 | -- change group to Networking/Daemon (like apache) | |
86 | - | |
87 | -* Sun Feb 23 2003 15:04 <jan@kneschke.de> | |
88 | -- initial version | |
1e1cc0d1 ER |
89 | Index: configure.in |
90 | =================================================================== | |
ad6a5263 ER |
91 | Index: src/mod_ssi_exprparser.h |
92 | =================================================================== | |
54b68997 ER |
93 | --- src/mod_ssi_exprparser.h (.../tags/lighttpd-1.4.19) (revision 2303) |
94 | +++ src/mod_ssi_exprparser.h (.../branches/lighttpd-1.4.x) (revision 2303) | |
ad6a5263 ER |
95 | @@ -1,12 +0,0 @@ |
96 | -#define TK_AND 1 | |
97 | -#define TK_OR 2 | |
98 | -#define TK_EQ 3 | |
99 | -#define TK_NE 4 | |
100 | -#define TK_GT 5 | |
101 | -#define TK_GE 6 | |
102 | -#define TK_LT 7 | |
103 | -#define TK_LE 8 | |
104 | -#define TK_NOT 9 | |
105 | -#define TK_LPARAN 10 | |
106 | -#define TK_RPARAN 11 | |
107 | -#define TK_VALUE 12 | |
09cf44bb ER |
108 | Index: src/configfile-glue.c |
109 | =================================================================== | |
54b68997 ER |
110 | --- src/configfile-glue.c (.../tags/lighttpd-1.4.19) (revision 2303) |
111 | +++ src/configfile-glue.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
112 | @@ -155,7 +155,7 @@ | |
113 | /* touched */ | |
114 | touched = data_string_init(); | |
115 | ||
116 | - buffer_copy_string(touched->value, ""); | |
117 | + buffer_copy_string_len(touched->value, CONST_STR_LEN("")); | |
118 | buffer_copy_string_buffer(touched->key, du->key); | |
119 | ||
120 | array_insert_unique(srv->config_touched, (data_unset *)touched); | |
121 | @@ -260,7 +260,7 @@ | |
122 | if (ck_colon) { | |
123 | /* condition "host:port" but client send "host" */ | |
124 | buffer_copy_string_buffer(srv->cond_check_buf, l); | |
125 | - BUFFER_APPEND_STRING_CONST(srv->cond_check_buf, ":"); | |
126 | + buffer_append_string_len(srv->cond_check_buf, CONST_STR_LEN(":")); | |
127 | buffer_append_long(srv->cond_check_buf, sock_addr_get_port(&(srv_sock->addr))); | |
128 | l = srv->cond_check_buf; | |
129 | } else if (!ck_colon) { | |
49b4da39 ER |
130 | @@ -529,7 +529,7 @@ |
131 | int config_append_cond_match_buffer(connection *con, data_config *dc, buffer *buf, int n) | |
132 | { | |
133 | cond_cache_t *cache = &con->cond_cache[dc->context_ndx]; | |
134 | - if (n > cache->patterncount) { | |
135 | + if (n >= cache->patterncount) { | |
136 | return 0; | |
a34aaa25 | 137 | } |
36650255 | 138 | |
ad6a5263 ER |
139 | Index: src/mod_cgi.c |
140 | =================================================================== | |
54b68997 ER |
141 | --- src/mod_cgi.c (.../tags/lighttpd-1.4.19) (revision 2303) |
142 | +++ src/mod_cgi.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
143 | @@ -912,7 +912,7 @@ | |
144 | buffer_reset(p->tmp_buf); | |
145 | ||
146 | if (0 != strcasecmp(ds->key->ptr, "CONTENT-TYPE")) { | |
147 | - buffer_copy_string(p->tmp_buf, "HTTP_"); | |
148 | + buffer_copy_string_len(p->tmp_buf, CONST_STR_LEN("HTTP_")); | |
149 | p->tmp_buf->used--; /* strip \0 after HTTP_ */ | |
150 | } | |
151 | ||
152 | @@ -949,7 +949,7 @@ | |
153 | ||
154 | for (j = 0; j < ds->key->used - 1; j++) { | |
155 | p->tmp_buf->ptr[p->tmp_buf->used++] = | |
156 | - isalpha((unsigned char)ds->key->ptr[j]) ? | |
157 | + light_isalnum((unsigned char)ds->key->ptr[j]) ? | |
158 | toupper((unsigned char)ds->key->ptr[j]) : '_'; | |
159 | } | |
160 | p->tmp_buf->ptr[p->tmp_buf->used++] = '\0'; | |
ad6a5263 ER |
161 | @@ -987,6 +987,8 @@ |
162 | *c = '/'; | |
163 | } | |
164 | ||
165 | + openDevNull(STDERR_FILENO); | |
166 | + | |
167 | /* we don't need the client socket */ | |
168 | for (i = 3; i < 256; i++) { | |
169 | if (i != srv->errorlog_fd) close(i); | |
170 | @@ -995,7 +997,7 @@ | |
171 | /* exec the cgi */ | |
172 | execve(args[0], args, env.ptr); | |
173 | ||
174 | - log_error_write(srv, __FILE__, __LINE__, "sss", "CGI failed:", strerror(errno), args[0]); | |
175 | + /* log_error_write(srv, __FILE__, __LINE__, "sss", "CGI failed:", strerror(errno), args[0]); */ | |
176 | ||
177 | /* */ | |
178 | SEGFAULT(); | |
179 | @@ -1058,8 +1060,9 @@ | |
180 | switch(errno) { | |
181 | case ENOSPC: | |
182 | con->http_status = 507; | |
183 | - | |
184 | break; | |
185 | + case EINTR: | |
186 | + continue; | |
187 | default: | |
188 | con->http_status = 403; | |
189 | break; | |
190 | @@ -1071,8 +1074,9 @@ | |
191 | switch(errno) { | |
192 | case ENOSPC: | |
193 | con->http_status = 507; | |
194 | - | |
195 | break; | |
196 | + case EINTR: | |
197 | + continue; | |
198 | default: | |
199 | con->http_status = 403; | |
200 | break; | |
201 | @@ -1087,6 +1091,8 @@ | |
202 | c->offset += r; | |
203 | cq->bytes_out += r; | |
204 | } else { | |
205 | + log_error_write(srv, __FILE__, __LINE__, "ss", "write() failed due to: ", strerror(errno)); | |
206 | + con->http_status = 500; | |
207 | break; | |
208 | } | |
209 | chunkqueue_remove_finished_chunks(cq); | |
54b68997 ER |
210 | @@ -1174,6 +1180,8 @@ |
211 | plugin_data *p = p_d; | |
212 | buffer *fn = con->physical.path; | |
213 | ||
214 | + if (con->mode != DIRECT) return HANDLER_GO_ON; | |
215 | + | |
216 | if (fn->used == 0) return HANDLER_GO_ON; | |
217 | ||
218 | mod_cgi_patch_connection(srv, con, p); | |
219 | @@ -1189,6 +1197,7 @@ | |
220 | ||
221 | if (0 == strncmp(fn->ptr + s_len - ct_len, ds->key->ptr, ct_len)) { | |
222 | if (cgi_create_env(srv, con, p, ds->value)) { | |
223 | + con->mode = DIRECT; | |
224 | con->http_status = 500; | |
225 | ||
226 | buffer_reset(con->physical.path); | |
227 | Index: src/mod_secure_download.c | |
228 | =================================================================== | |
229 | --- src/mod_secure_download.c (.../tags/lighttpd-1.4.19) (revision 2303) | |
230 | +++ src/mod_secure_download.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
231 | @@ -204,6 +204,8 @@ | |
232 | time_t ts = 0; | |
233 | size_t i; | |
234 | ||
235 | + if (con->mode != DIRECT) return HANDLER_GO_ON; | |
236 | + | |
237 | if (con->uri.path->used == 0) return HANDLER_GO_ON; | |
238 | ||
239 | mod_secdownload_patch_connection(srv, con, p); | |
240 | @@ -243,8 +245,8 @@ | |
241 | } | |
242 | ||
243 | /* timed-out */ | |
244 | - if (srv->cur_ts - ts > p->conf.timeout || | |
245 | - srv->cur_ts - ts < -p->conf.timeout) { | |
246 | + if ( (srv->cur_ts > ts && srv->cur_ts - ts > p->conf.timeout) || | |
247 | + (srv->cur_ts < ts && ts - srv->cur_ts > p->conf.timeout) ) { | |
248 | /* "Gone" as the url will never be valid again instead of "408 - Timeout" where the request may be repeated */ | |
249 | con->http_status = 410; | |
250 | ||
251 | @@ -268,7 +270,7 @@ | |
252 | ||
253 | buffer_copy_string_hex(p->md5, (char *)HA1, 16); | |
254 | ||
255 | - if (0 != strncmp(md5_str, p->md5->ptr, 32)) { | |
256 | + if (0 != strncasecmp(md5_str, p->md5->ptr, 32)) { | |
257 | con->http_status = 403; | |
258 | ||
259 | log_error_write(srv, __FILE__, __LINE__, "sss", | |
260 | Index: src/array.c | |
261 | =================================================================== | |
262 | --- src/array.c (.../tags/lighttpd-1.4.19) (revision 2303) | |
263 | +++ src/array.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
264 | @@ -330,30 +330,30 @@ | |
265 | a = array_init(); | |
266 | ||
267 | ds = data_string_init(); | |
268 | - buffer_copy_string(ds->key, "abc"); | |
269 | - buffer_copy_string(ds->value, "alfrag"); | |
270 | + buffer_copy_string_len(ds->key, CONST_STR_LEN("abc")); | |
271 | + buffer_copy_string_len(ds->value, CONST_STR_LEN("alfrag")); | |
272 | ||
273 | array_insert_unique(a, (data_unset *)ds); | |
274 | ||
275 | ds = data_string_init(); | |
276 | - buffer_copy_string(ds->key, "abc"); | |
277 | - buffer_copy_string(ds->value, "hameplman"); | |
278 | + buffer_copy_string_len(ds->key, CONST_STR_LEN("abc")); | |
279 | + buffer_copy_string_len(ds->value, CONST_STR_LEN("hameplman")); | |
280 | ||
281 | array_insert_unique(a, (data_unset *)ds); | |
282 | ||
283 | ds = data_string_init(); | |
284 | - buffer_copy_string(ds->key, "123"); | |
285 | - buffer_copy_string(ds->value, "alfrag"); | |
286 | + buffer_copy_string_len(ds->key, CONST_STR_LEN("123")); | |
287 | + buffer_copy_string_len(ds->value, CONST_STR_LEN("alfrag")); | |
288 | ||
289 | array_insert_unique(a, (data_unset *)ds); | |
290 | ||
291 | dc = data_count_init(); | |
292 | - buffer_copy_string(dc->key, "def"); | |
293 | + buffer_copy_string_len(dc->key, CONST_STR_LEN("def")); | |
294 | ||
295 | array_insert_unique(a, (data_unset *)dc); | |
296 | ||
297 | dc = data_count_init(); | |
298 | - buffer_copy_string(dc->key, "def"); | |
299 | + buffer_copy_string_len(dc->key, CONST_STR_LEN("def")); | |
300 | ||
301 | array_insert_unique(a, (data_unset *)dc); | |
302 | ||
303 | Index: src/base.h | |
304 | =================================================================== | |
305 | --- src/base.h (.../tags/lighttpd-1.4.19) (revision 2303) | |
306 | +++ src/base.h (.../branches/lighttpd-1.4.x) (revision 2303) | |
307 | @@ -259,6 +259,7 @@ | |
308 | unsigned short log_request_handling; | |
309 | unsigned short log_response_header; | |
310 | unsigned short log_condition_handling; | |
311 | + unsigned short log_ssl_noise; | |
312 | ||
313 | ||
314 | /* server wide */ | |
ad6a5263 ER |
315 | Index: src/mod_rewrite.c |
316 | =================================================================== | |
54b68997 ER |
317 | --- src/mod_rewrite.c (.../tags/lighttpd-1.4.19) (revision 2303) |
318 | +++ src/mod_rewrite.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
319 | @@ -350,7 +350,11 @@ | |
320 | ||
321 | if (!p->conf.rewrite) return HANDLER_GO_ON; | |
322 | ||
323 | - buffer_copy_string_buffer(p->match_buf, con->request.uri); | |
324 | + buffer_copy_string_buffer(p->match_buf, con->uri.path); | |
325 | + if (con->uri.query->used > 0) { | |
326 | + buffer_append_string_len(p->match_buf, CONST_STR_LEN("?")); | |
327 | + buffer_append_string_buffer(p->match_buf, con->uri.query); | |
328 | + } | |
329 | ||
330 | for (i = 0; i < p->conf.rewrite->used; i++) { | |
331 | pcre *match; | |
332 | @@ -385,8 +389,7 @@ | |
ad6a5263 ER |
333 | |
334 | start = 0; end = pattern_len; | |
335 | for (k = 0; k < pattern_len; k++) { | |
336 | - if ((pattern[k] == '$' || pattern[k] == '%') && | |
337 | - isdigit((unsigned char)pattern[k + 1])) { | |
338 | + if (pattern[k] == '$' || pattern[k] == '%') { | |
339 | /* got one */ | |
340 | ||
341 | size_t num = pattern[k + 1] - '0'; | |
54b68997 | 342 | @@ -395,7 +398,10 @@ |
ad6a5263 ER |
343 | |
344 | buffer_append_string_len(con->request.uri, pattern + start, end - start); | |
345 | ||
346 | - if (pattern[k] == '$') { | |
347 | + if (!isdigit((unsigned char)pattern[k + 1])) { | |
348 | + /* enable escape: "%%" => "%", "%a" => "%a", "$$" => "$" */ | |
349 | + buffer_append_string_len(con->request.uri, pattern+k, pattern[k] == pattern[k+1] ? 1 : 2); | |
350 | + } else if (pattern[k] == '$') { | |
351 | /* n is always > 0 */ | |
352 | if (num < (size_t)n) { | |
353 | buffer_append_string(con->request.uri, list[num]); | |
354 | Index: src/lempar.c | |
355 | =================================================================== | |
54b68997 ER |
356 | --- src/lempar.c (.../tags/lighttpd-1.4.19) (revision 2303) |
357 | +++ src/lempar.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
ad6a5263 ER |
358 | @@ -210,7 +210,7 @@ |
359 | */ | |
360 | const char *ParseTokenName(int tokenType){ | |
361 | #ifndef NDEBUG | |
362 | - if( tokenType>0 && tokenType<(sizeof(yyTokenName)/sizeof(yyTokenName[0])) ){ | |
363 | + if( tokenType>0 && (size_t)tokenType<(sizeof(yyTokenName)/sizeof(yyTokenName[0])) ){ | |
364 | return yyTokenName[tokenType]; | |
365 | }else{ | |
366 | return "Unknown"; | |
367 | @@ -335,7 +335,7 @@ | |
368 | return YY_NO_ACTION; | |
369 | } | |
370 | i += iLookAhead; | |
371 | - if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){ | |
372 | + if( i<0 || (size_t)i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){ | |
373 | #ifdef YYFALLBACK | |
374 | int iFallback; /* Fallback token */ | |
375 | if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0]) | |
376 | @@ -378,7 +378,7 @@ | |
377 | return YY_NO_ACTION; | |
378 | } | |
379 | i += iLookAhead; | |
380 | - if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){ | |
381 | + if( i<0 || (size_t)i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){ | |
382 | return yy_default[stateno]; | |
383 | }else{ | |
384 | return yy_action[i]; | |
385 | @@ -456,7 +456,7 @@ | |
386 | yymsp = &yypParser->yystack[yypParser->yyidx]; | |
387 | #ifndef NDEBUG | |
388 | if( yyTraceFILE && yyruleno>=0 | |
389 | - && yyruleno<sizeof(yyRuleName)/sizeof(yyRuleName[0]) ){ | |
390 | + && (size_t)yyruleno<sizeof(yyRuleName)/sizeof(yyRuleName[0]) ){ | |
391 | fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt, | |
392 | yyRuleName[yyruleno]); | |
393 | } | |
394 | @@ -511,6 +511,8 @@ | |
395 | int yymajor, /* The major type of the error token */ | |
396 | YYMINORTYPE yyminor /* The minor type of the error token */ | |
397 | ){ | |
398 | + UNUSED(yymajor); | |
399 | + UNUSED(yyminor); | |
400 | ParseARG_FETCH; | |
401 | #define TOKEN (yyminor.yy0) | |
402 | %% | |
a34aaa25 ER |
403 | Index: src/connections.c |
404 | =================================================================== | |
54b68997 ER |
405 | --- src/connections.c (.../tags/lighttpd-1.4.19) (revision 2303) |
406 | +++ src/connections.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
49b4da39 | 407 | @@ -199,6 +199,7 @@ |
a34aaa25 | 408 | |
49b4da39 | 409 | /* don't resize the buffer if we were in SSL_ERROR_WANT_* */ |
a34aaa25 | 410 | |
49b4da39 ER |
411 | + ERR_clear_error(); |
412 | do { | |
413 | if (!con->ssl_error_want_reuse_buffer) { | |
414 | b = buffer_init(); | |
54b68997 ER |
415 | @@ -275,9 +276,19 @@ |
416 | /* fall thourgh */ | |
417 | default: | |
418 | while((ssl_err = ERR_get_error())) { | |
419 | + switch (ERR_GET_REASON(ssl_err)) { | |
420 | + case SSL_R_SSL_HANDSHAKE_FAILURE: | |
421 | + case SSL_R_TLSV1_ALERT_UNKNOWN_CA: | |
422 | + case SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN: | |
423 | + case SSL_R_SSLV3_ALERT_BAD_CERTIFICATE: | |
424 | + if (!con->conf.log_ssl_noise) continue; | |
425 | + break; | |
426 | + default: | |
427 | + break; | |
428 | + } | |
429 | /* get all errors from the error-queue */ | |
430 | log_error_write(srv, __FILE__, __LINE__, "sds", "SSL:", | |
431 | - r, ERR_error_string(ssl_err, NULL)); | |
432 | + r, ERR_error_string(ssl_err, NULL)); | |
433 | } | |
434 | break; | |
435 | } | |
436 | @@ -299,6 +310,8 @@ | |
ad6a5263 ER |
437 | |
438 | return 0; | |
439 | #else | |
440 | + UNUSED(srv); | |
441 | + UNUSED(con); | |
442 | return -1; | |
443 | #endif | |
444 | } | |
54b68997 | 445 | @@ -427,21 +440,22 @@ |
ad6a5263 ER |
446 | } |
447 | ||
448 | switch(con->http_status) { | |
449 | - case 400: /* class: header + custom body */ | |
450 | - case 401: | |
451 | - case 403: | |
452 | - case 404: | |
453 | - case 408: | |
454 | - case 409: | |
455 | - case 411: | |
456 | - case 416: | |
457 | - case 423: | |
458 | - case 500: | |
459 | - case 501: | |
460 | - case 503: | |
461 | - case 505: | |
462 | + case 204: /* class: header only */ | |
463 | + case 205: | |
464 | + case 304: | |
465 | + /* disable chunked encoding again as we have no body */ | |
466 | + con->response.transfer_encoding &= ~HTTP_TRANSFER_ENCODING_CHUNKED; | |
467 | + con->parsed_response &= ~HTTP_CONTENT_LENGTH; | |
468 | + chunkqueue_reset(con->write_queue); | |
469 | + | |
470 | + con->file_finished = 1; | |
471 | + break; | |
472 | + default: /* class: header + body */ | |
473 | if (con->mode != DIRECT) break; | |
474 | ||
475 | + /* only custom body for 4xx and 5xx */ | |
476 | + if (con->http_status < 400 || con->http_status >= 600) break; | |
477 | + | |
478 | con->file_finished = 0; | |
479 | ||
480 | buffer_reset(con->physical.path); | |
54b68997 | 481 | @@ -451,7 +465,8 @@ |
ad6a5263 ER |
482 | stat_cache_entry *sce = NULL; |
483 | ||
484 | buffer_copy_string_buffer(con->physical.path, con->conf.errorfile_prefix); | |
485 | - buffer_append_string(con->physical.path, get_http_status_body_name(con->http_status)); | |
486 | + buffer_append_long(con->physical.path, con->http_status); | |
487 | + buffer_append_string_len(con->physical.path, CONST_STR_LEN(".html")); | |
488 | ||
489 | if (HANDLER_ERROR != stat_cache_get_entry(srv, con, con->physical.path, &sce)) { | |
490 | con->file_finished = 1; | |
54b68997 ER |
491 | @@ -470,57 +485,34 @@ |
492 | b = chunkqueue_get_append_buffer(con->write_queue); | |
493 | ||
494 | /* build default error-page */ | |
495 | - buffer_copy_string(b, | |
496 | + buffer_copy_string_len(b, CONST_STR_LEN( | |
497 | "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n" | |
498 | "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n" | |
499 | " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n" | |
500 | "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n" | |
501 | " <head>\n" | |
502 | - " <title>"); | |
503 | + " <title>")); | |
504 | buffer_append_long(b, con->http_status); | |
505 | - buffer_append_string(b, " - "); | |
506 | + buffer_append_string_len(b, CONST_STR_LEN(" - ")); | |
507 | buffer_append_string(b, get_http_status_name(con->http_status)); | |
508 | ||
509 | - buffer_append_string(b, | |
510 | + buffer_append_string_len(b, CONST_STR_LEN( | |
511 | "</title>\n" | |
512 | " </head>\n" | |
513 | " <body>\n" | |
514 | - " <h1>"); | |
515 | + " <h1>")); | |
516 | buffer_append_long(b, con->http_status); | |
517 | - buffer_append_string(b, " - "); | |
518 | + buffer_append_string_len(b, CONST_STR_LEN(" - ")); | |
519 | buffer_append_string(b, get_http_status_name(con->http_status)); | |
520 | ||
521 | - buffer_append_string(b,"</h1>\n" | |
522 | + buffer_append_string_len(b, CONST_STR_LEN("</h1>\n" | |
523 | " </body>\n" | |
524 | "</html>\n" | |
525 | - ); | |
526 | + )); | |
ad6a5263 ER |
527 | |
528 | response_header_overwrite(srv, con, CONST_STR_LEN("Content-Type"), CONST_STR_LEN("text/html")); | |
529 | } | |
530 | - /* fall through */ | |
531 | - case 207: | |
532 | - case 200: /* class: header + body */ | |
533 | - case 201: | |
534 | - case 300: | |
535 | - case 301: | |
536 | - case 302: | |
537 | - case 303: | |
538 | - case 307: | |
539 | break; | |
540 | - | |
541 | - case 206: /* write_queue is already prepared */ | |
542 | - break; | |
543 | - case 204: | |
544 | - case 205: /* class: header only */ | |
545 | - case 304: | |
546 | - default: | |
547 | - /* disable chunked encoding again as we have no body */ | |
548 | - con->response.transfer_encoding &= ~HTTP_TRANSFER_ENCODING_CHUNKED; | |
549 | - con->parsed_response &= ~HTTP_CONTENT_LENGTH; | |
550 | - chunkqueue_reset(con->write_queue); | |
551 | - | |
552 | - con->file_finished = 1; | |
553 | - break; | |
554 | } | |
555 | ||
556 | if (con->file_finished) { | |
54b68997 | 557 | @@ -544,7 +536,7 @@ |
ad6a5263 ER |
558 | data_string *ds; |
559 | /* no Content-Body, no Content-Length */ | |
560 | if (NULL != (ds = (data_string*) array_get_element(con->response.headers, "Content-Length"))) { | |
561 | - buffer_reset(ds->value); // Headers with empty values are ignored for output | |
562 | + buffer_reset(ds->value); /* Headers with empty values are ignored for output */ | |
563 | } | |
564 | } else if (qlen > 0 || con->request.http_method != HTTP_METHOD_HEAD) { | |
565 | /* qlen = 0 is important for Redirects (301, ...) as they MAY have | |
54b68997 | 566 | @@ -846,7 +838,7 @@ |
ad6a5263 ER |
567 | } |
568 | ||
569 | /* The cond_cache gets reset in response.c */ | |
570 | -// config_cond_cache_reset(srv, con); | |
571 | + /* config_cond_cache_reset(srv, con); */ | |
572 | ||
573 | #ifdef USE_OPENSSL | |
574 | if (con->ssl_error_want_reuse_buffer) { | |
54b68997 | 575 | @@ -1668,21 +1660,51 @@ |
a34aaa25 | 576 | } |
a34aaa25 | 577 | #ifdef USE_OPENSSL |
49b4da39 ER |
578 | if (srv_sock->is_ssl) { |
579 | - int ret; | |
580 | + int ret, ssl_r; | |
581 | + unsigned long err; | |
582 | + ERR_clear_error(); | |
583 | switch ((ret = SSL_shutdown(con->ssl))) { | |
584 | case 1: | |
585 | /* ok */ | |
a34aaa25 | 586 | break; |
49b4da39 ER |
587 | case 0: |
588 | - SSL_shutdown(con->ssl); | |
589 | - break; | |
590 | + ERR_clear_error(); | |
591 | + if (-1 != (ret = SSL_shutdown(con->ssl))) break; | |
592 | + | |
593 | + /* fall through */ | |
594 | default: | |
595 | - log_error_write(srv, __FILE__, __LINE__, "sds", "SSL:", | |
596 | - SSL_get_error(con->ssl, ret), | |
597 | - ERR_error_string(ERR_get_error(), NULL)); | |
598 | - return -1; | |
a34aaa25 | 599 | + |
49b4da39 ER |
600 | + switch ((ssl_r = SSL_get_error(con->ssl, ret))) { |
601 | + case SSL_ERROR_WANT_WRITE: | |
602 | + case SSL_ERROR_WANT_READ: | |
603 | + break; | |
604 | + case SSL_ERROR_SYSCALL: | |
605 | + /* perhaps we have error waiting in our error-queue */ | |
606 | + if (0 != (err = ERR_get_error())) { | |
607 | + do { | |
608 | + log_error_write(srv, __FILE__, __LINE__, "sdds", "SSL:", | |
609 | + ssl_r, ret, | |
610 | + ERR_error_string(err, NULL)); | |
611 | + } while((err = ERR_get_error())); | |
612 | + } else { | |
613 | + log_error_write(srv, __FILE__, __LINE__, "sddds", "SSL (error):", | |
614 | + ssl_r, ret, errno, | |
615 | + strerror(errno)); | |
616 | + } | |
617 | + | |
618 | + break; | |
619 | + default: | |
620 | + while((err = ERR_get_error())) { | |
621 | + log_error_write(srv, __FILE__, __LINE__, "sdds", "SSL:", | |
622 | + ssl_r, ret, | |
623 | + ERR_error_string(err, NULL)); | |
624 | + } | |
625 | + | |
626 | + break; | |
1e1cc0d1 ER |
627 | + } |
628 | } | |
7db9a1b1 | 629 | } |
49b4da39 | 630 | + ERR_clear_error(); |
7db9a1b1 | 631 | #endif |
7db9a1b1 | 632 | |
49b4da39 | 633 | switch(con->mode) { |
54b68997 ER |
634 | Index: src/mod_staticfile.c |
635 | =================================================================== | |
636 | --- src/mod_staticfile.c (.../tags/lighttpd-1.4.19) (revision 2303) | |
637 | +++ src/mod_staticfile.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
638 | @@ -282,22 +282,22 @@ | |
639 | ||
640 | b = chunkqueue_get_append_buffer(con->write_queue); | |
641 | ||
642 | - buffer_copy_string(b, "\r\n--"); | |
643 | + buffer_copy_string_len(b, CONST_STR_LEN("\r\n--")); | |
644 | buffer_append_string(b, boundary); | |
645 | ||
646 | /* write Content-Range */ | |
647 | - buffer_append_string(b, "\r\nContent-Range: bytes "); | |
648 | + buffer_append_string_len(b, CONST_STR_LEN("\r\nContent-Range: bytes ")); | |
649 | buffer_append_off_t(b, start); | |
650 | - buffer_append_string(b, "-"); | |
651 | + buffer_append_string_len(b, CONST_STR_LEN("-")); | |
652 | buffer_append_off_t(b, end); | |
653 | - buffer_append_string(b, "/"); | |
654 | + buffer_append_string_len(b, CONST_STR_LEN("/")); | |
655 | buffer_append_off_t(b, sce->st.st_size); | |
656 | ||
657 | - buffer_append_string(b, "\r\nContent-Type: "); | |
658 | + buffer_append_string_len(b, CONST_STR_LEN("\r\nContent-Type: ")); | |
659 | buffer_append_string_buffer(b, content_type); | |
660 | ||
661 | /* write END-OF-HEADER */ | |
662 | - buffer_append_string(b, "\r\n\r\n"); | |
663 | + buffer_append_string_len(b, CONST_STR_LEN("\r\n\r\n")); | |
664 | ||
665 | con->response.content_length += b->used - 1; | |
666 | ||
667 | @@ -325,7 +325,7 @@ | |
668 | ||
669 | /* set header-fields */ | |
670 | ||
671 | - buffer_copy_string(p->range_buf, "multipart/byteranges; boundary="); | |
672 | + buffer_copy_string_len(p->range_buf, CONST_STR_LEN("multipart/byteranges; boundary=")); | |
673 | buffer_append_string(p->range_buf, boundary); | |
674 | ||
675 | /* overwrite content-type */ | |
676 | @@ -333,11 +333,11 @@ | |
677 | } else { | |
678 | /* add Content-Range-header */ | |
679 | ||
680 | - buffer_copy_string(p->range_buf, "bytes "); | |
681 | + buffer_copy_string_len(p->range_buf, CONST_STR_LEN("bytes ")); | |
682 | buffer_append_off_t(p->range_buf, start); | |
683 | - buffer_append_string(p->range_buf, "-"); | |
684 | + buffer_append_string_len(p->range_buf, CONST_STR_LEN("-")); | |
685 | buffer_append_off_t(p->range_buf, end); | |
686 | - buffer_append_string(p->range_buf, "/"); | |
687 | + buffer_append_string_len(p->range_buf, CONST_STR_LEN("/")); | |
688 | buffer_append_off_t(p->range_buf, sce->st.st_size); | |
689 | ||
690 | response_header_insert(srv, con, CONST_STR_LEN("Content-Range"), CONST_BUF_LEN(p->range_buf)); | |
691 | Index: src/network.c | |
692 | =================================================================== | |
693 | --- src/network.c (.../tags/lighttpd-1.4.19) (revision 2303) | |
694 | +++ src/network.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
695 | @@ -494,7 +494,7 @@ | |
696 | b = buffer_init(); | |
697 | ||
698 | buffer_copy_string_buffer(b, srv->srvconf.bindhost); | |
699 | - buffer_append_string(b, ":"); | |
700 | + buffer_append_string_len(b, CONST_STR_LEN(":")); | |
701 | buffer_append_long(b, srv->srvconf.port); | |
702 | ||
703 | if (0 != network_server_init(srv, b, srv->config_storage[0])) { | |
ad6a5263 ER |
704 | Index: src/configfile.c |
705 | =================================================================== | |
54b68997 ER |
706 | --- src/configfile.c (.../tags/lighttpd-1.4.19) (revision 2303) |
707 | +++ src/configfile.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
ad6a5263 ER |
708 | @@ -7,6 +7,7 @@ |
709 | #include <string.h> | |
710 | #include <stdio.h> | |
711 | #include <ctype.h> | |
712 | +#include <limits.h> | |
713 | #include <assert.h> | |
714 | ||
715 | #include "server.h" | |
54b68997 ER |
716 | @@ -74,24 +75,25 @@ |
717 | { "debug.log-request-handling", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 32 */ | |
718 | { "debug.log-response-header", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 33 */ | |
719 | { "debug.log-request-header", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 34 */ | |
720 | + { "debug.log-ssl-noise", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 35 */ | |
721 | ||
722 | - { "server.protocol-http11", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 35 */ | |
723 | - { "debug.log-request-header-on-error", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 36 */ | |
724 | - { "debug.log-state-handling", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 37 */ | |
725 | - { "ssl.ca-file", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_SERVER }, /* 38 */ | |
726 | + { "server.protocol-http11", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 36 */ | |
727 | + { "debug.log-request-header-on-error", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 37 */ | |
728 | + { "debug.log-state-handling", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 38 */ | |
729 | + { "ssl.ca-file", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_SERVER }, /* 39 */ | |
730 | ||
731 | - { "server.errorlog-use-syslog", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 39 */ | |
732 | - { "server.range-requests", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 40 */ | |
733 | - { "server.stat-cache-engine", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 41 */ | |
734 | - { "server.max-connections", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_SERVER }, /* 42 */ | |
735 | - { "server.network-backend", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 43 */ | |
736 | - { "server.upload-dirs", NULL, T_CONFIG_ARRAY, T_CONFIG_SCOPE_CONNECTION }, /* 44 */ | |
737 | - { "server.core-files", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 45 */ | |
738 | - { "ssl.cipher-list", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_SERVER }, /* 46 */ | |
739 | - { "ssl.use-sslv2", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 47 */ | |
740 | - { "etag.use-inode", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 48 */ | |
741 | - { "etag.use-mtime", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 49 */ | |
742 | - { "etag.use-size", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 50 */ | |
743 | + { "server.errorlog-use-syslog", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 40 */ | |
744 | + { "server.range-requests", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 41 */ | |
745 | + { "server.stat-cache-engine", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 42 */ | |
746 | + { "server.max-connections", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_SERVER }, /* 43 */ | |
747 | + { "server.network-backend", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 44 */ | |
748 | + { "server.upload-dirs", NULL, T_CONFIG_ARRAY, T_CONFIG_SCOPE_CONNECTION }, /* 45 */ | |
749 | + { "server.core-files", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 46 */ | |
750 | + { "ssl.cipher-list", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_SERVER }, /* 47 */ | |
751 | + { "ssl.use-sslv2", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 48 */ | |
752 | + { "etag.use-inode", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 49 */ | |
753 | + { "etag.use-mtime", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 50 */ | |
754 | + { "etag.use-size", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 51 */ | |
755 | { "server.host", "use server.bind instead", T_CONFIG_DEPRECATED, T_CONFIG_SCOPE_UNSET }, | |
756 | { "server.docroot", "use server.document-root instead", T_CONFIG_DEPRECATED, T_CONFIG_SCOPE_UNSET }, | |
757 | { "server.virtual-root", "load mod_simple_vhost and use simple-vhost.server-root instead", T_CONFIG_DEPRECATED, T_CONFIG_SCOPE_UNSET }, | |
758 | @@ -120,18 +122,18 @@ | |
759 | ||
760 | cv[13].destination = &(srv->srvconf.max_worker); | |
761 | cv[23].destination = &(srv->srvconf.max_fds); | |
762 | - cv[36].destination = &(srv->srvconf.log_request_header_on_error); | |
763 | - cv[37].destination = &(srv->srvconf.log_state_handling); | |
764 | + cv[37].destination = &(srv->srvconf.log_request_header_on_error); | |
765 | + cv[38].destination = &(srv->srvconf.log_state_handling); | |
766 | ||
767 | - cv[39].destination = &(srv->srvconf.errorlog_use_syslog); | |
768 | + cv[40].destination = &(srv->srvconf.errorlog_use_syslog); | |
769 | ||
770 | stat_cache_string = buffer_init(); | |
771 | - cv[41].destination = stat_cache_string; | |
772 | - cv[43].destination = srv->srvconf.network_backend; | |
773 | - cv[44].destination = srv->srvconf.upload_tempdirs; | |
774 | - cv[45].destination = &(srv->srvconf.enable_cores); | |
775 | + cv[42].destination = stat_cache_string; | |
776 | + cv[44].destination = srv->srvconf.network_backend; | |
777 | + cv[45].destination = srv->srvconf.upload_tempdirs; | |
778 | + cv[46].destination = &(srv->srvconf.enable_cores); | |
779 | ||
780 | - cv[42].destination = &(srv->srvconf.max_conns); | |
781 | + cv[43].destination = &(srv->srvconf.max_conns); | |
782 | cv[12].destination = &(srv->srvconf.max_request_size); | |
783 | srv->config_storage = calloc(1, srv->config_context->used * sizeof(specific_config *)); | |
784 | ||
785 | @@ -204,16 +206,17 @@ | |
786 | cv[32].destination = &(s->log_request_handling); | |
787 | cv[33].destination = &(s->log_response_header); | |
788 | cv[34].destination = &(s->log_request_header); | |
789 | + cv[35].destination = &(s->log_ssl_noise); | |
790 | ||
791 | - cv[35].destination = &(s->allow_http11); | |
792 | - cv[38].destination = s->ssl_ca_file; | |
793 | - cv[40].destination = &(s->range_requests); | |
794 | + cv[36].destination = &(s->allow_http11); | |
795 | + cv[39].destination = s->ssl_ca_file; | |
796 | + cv[41].destination = &(s->range_requests); | |
797 | ||
798 | - cv[46].destination = s->ssl_cipher_list; | |
799 | - cv[47].destination = &(s->ssl_use_sslv2); | |
800 | - cv[48].destination = &(s->etag_use_inode); | |
801 | - cv[49].destination = &(s->etag_use_mtime); | |
802 | - cv[50].destination = &(s->etag_use_size); | |
803 | + cv[47].destination = s->ssl_cipher_list; | |
804 | + cv[48].destination = &(s->ssl_use_sslv2); | |
805 | + cv[49].destination = &(s->etag_use_inode); | |
806 | + cv[50].destination = &(s->etag_use_mtime); | |
807 | + cv[51].destination = &(s->etag_use_size); | |
808 | ||
809 | srv->config_storage[i] = s; | |
810 | ||
811 | @@ -279,6 +282,7 @@ | |
812 | PATCH(log_request_handling); | |
813 | PATCH(log_condition_handling); | |
814 | PATCH(log_file_not_found); | |
815 | + PATCH(log_ssl_noise); | |
816 | ||
817 | PATCH(range_requests); | |
818 | PATCH(force_lowercase_filenames); | |
819 | @@ -305,9 +309,6 @@ | |
ad6a5263 ER |
820 | data_config *dc = (data_config *)srv->config_context->data[i]; |
821 | specific_config *s = srv->config_storage[i]; | |
822 | ||
823 | - /* not our stage */ | |
824 | - if (comp != dc->comp) continue; | |
825 | - | |
826 | /* condition didn't match */ | |
827 | if (!config_check_cond(srv, con, dc)) continue; | |
828 | ||
54b68997 ER |
829 | @@ -371,6 +372,8 @@ |
830 | PATCH(log_condition_handling); | |
831 | } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("debug.log-file-not-found"))) { | |
832 | PATCH(log_file_not_found); | |
833 | + } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("debug.log-ssl-noise"))) { | |
834 | + PATCH(log_ssl_noise); | |
835 | } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("server.protocol-http11"))) { | |
836 | PATCH(allow_http11); | |
837 | } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("server.force-lowercase-filenames"))) { | |
838 | @@ -410,8 +413,8 @@ | |
ad6a5263 ER |
839 | |
840 | #if 0 | |
841 | static int tokenizer_open(server *srv, tokenizer_t *t, buffer *basedir, const char *fn) { | |
842 | - if (buffer_is_empty(basedir) && | |
843 | - (fn[0] == '/' || fn[0] == '\\') && | |
844 | + if (buffer_is_empty(basedir) || | |
845 | + (fn[0] == '/' || fn[0] == '\\') || | |
846 | (fn[0] == '.' && (fn[1] == '/' || fn[1] == '\\'))) { | |
847 | t->file = buffer_init_string(fn); | |
848 | } else { | |
54b68997 ER |
849 | @@ -480,7 +483,7 @@ |
850 | if (t->input[t->offset + 1] == '>') { | |
851 | t->offset += 2; | |
852 | ||
853 | - buffer_copy_string(token, "=>"); | |
854 | + buffer_copy_string_len(token, CONST_STR_LEN("=>")); | |
855 | ||
856 | tid = TK_ARRAY_ASSIGN; | |
857 | } else { | |
858 | @@ -494,13 +497,13 @@ | |
859 | if (t->input[t->offset + 1] == '=') { | |
860 | t->offset += 2; | |
861 | ||
862 | - buffer_copy_string(token, "=="); | |
863 | + buffer_copy_string_len(token, CONST_STR_LEN("==")); | |
864 | ||
865 | tid = TK_EQ; | |
866 | } else if (t->input[t->offset + 1] == '~') { | |
867 | t->offset += 2; | |
868 | ||
869 | - buffer_copy_string(token, "=~"); | |
870 | + buffer_copy_string_len(token, CONST_STR_LEN("=~")); | |
871 | ||
872 | tid = TK_MATCH; | |
873 | } else { | |
874 | @@ -533,13 +536,13 @@ | |
875 | if (t->input[t->offset + 1] == '=') { | |
876 | t->offset += 2; | |
877 | ||
878 | - buffer_copy_string(token, "!="); | |
879 | + buffer_copy_string_len(token, CONST_STR_LEN("!=")); | |
880 | ||
881 | tid = TK_NE; | |
882 | } else if (t->input[t->offset + 1] == '~') { | |
883 | t->offset += 2; | |
884 | ||
885 | - buffer_copy_string(token, "!~"); | |
886 | + buffer_copy_string_len(token, CONST_STR_LEN("!~")); | |
887 | ||
888 | tid = TK_NOMATCH; | |
889 | } else { | |
890 | @@ -594,7 +597,7 @@ | |
891 | } | |
892 | t->in_key = 1; | |
893 | tid = TK_EOL; | |
894 | - buffer_copy_string(token, "(EOL)"); | |
895 | + buffer_copy_string_len(token, CONST_STR_LEN("(EOL)")); | |
896 | } else { | |
897 | config_skip_newline(t); | |
898 | t->line_pos = 1; | |
899 | @@ -605,7 +608,7 @@ | |
900 | if (t->in_brace > 0) { | |
901 | tid = TK_COMMA; | |
902 | ||
903 | - buffer_copy_string(token, "(COMMA)"); | |
904 | + buffer_copy_string_len(token, CONST_STR_LEN("(COMMA)")); | |
905 | } | |
906 | ||
907 | t->offset++; | |
908 | @@ -614,7 +617,7 @@ | |
909 | case '"': | |
910 | /* search for the terminating " */ | |
911 | start = t->input + t->offset + 1; | |
912 | - buffer_copy_string(token, ""); | |
913 | + buffer_copy_string_len(token, CONST_STR_LEN("")); | |
914 | ||
915 | for (i = 1; t->input[t->offset + i]; i++) { | |
916 | if (t->input[t->offset + i] == '\\' && | |
917 | @@ -660,7 +663,7 @@ | |
918 | ||
919 | tid = TK_LPARAN; | |
920 | ||
921 | - buffer_copy_string(token, "("); | |
922 | + buffer_copy_string_len(token, CONST_STR_LEN("(")); | |
923 | break; | |
924 | case ')': | |
925 | t->offset++; | |
926 | @@ -668,7 +671,7 @@ | |
927 | ||
928 | tid = TK_RPARAN; | |
929 | ||
930 | - buffer_copy_string(token, ")"); | |
931 | + buffer_copy_string_len(token, CONST_STR_LEN(")")); | |
932 | break; | |
933 | case '$': | |
934 | t->offset++; | |
935 | @@ -677,19 +680,19 @@ | |
936 | t->in_cond = 1; | |
937 | t->in_key = 0; | |
938 | ||
939 | - buffer_copy_string(token, "$"); | |
940 | + buffer_copy_string_len(token, CONST_STR_LEN("$")); | |
941 | ||
942 | break; | |
943 | ||
944 | case '+': | |
945 | if (t->input[t->offset + 1] == '=') { | |
946 | t->offset += 2; | |
947 | - buffer_copy_string(token, "+="); | |
948 | + buffer_copy_string_len(token, CONST_STR_LEN("+=")); | |
949 | tid = TK_APPEND; | |
950 | } else { | |
951 | t->offset++; | |
952 | tid = TK_PLUS; | |
953 | - buffer_copy_string(token, "+"); | |
954 | + buffer_copy_string_len(token, CONST_STR_LEN("+")); | |
955 | } | |
956 | break; | |
957 | ||
958 | @@ -698,7 +701,7 @@ | |
959 | ||
960 | tid = TK_LCURLY; | |
961 | ||
962 | - buffer_copy_string(token, "{"); | |
963 | + buffer_copy_string_len(token, CONST_STR_LEN("{")); | |
964 | ||
965 | break; | |
966 | ||
967 | @@ -707,7 +710,7 @@ | |
968 | ||
969 | tid = TK_RCURLY; | |
970 | ||
971 | - buffer_copy_string(token, "}"); | |
972 | + buffer_copy_string_len(token, CONST_STR_LEN("}")); | |
973 | ||
974 | break; | |
975 | ||
976 | @@ -716,7 +719,7 @@ | |
977 | ||
978 | tid = TK_LBRACKET; | |
979 | ||
980 | - buffer_copy_string(token, "["); | |
981 | + buffer_copy_string_len(token, CONST_STR_LEN("[")); | |
982 | ||
983 | break; | |
984 | ||
985 | @@ -725,7 +728,7 @@ | |
986 | ||
987 | tid = TK_RBRACKET; | |
988 | ||
989 | - buffer_copy_string(token, "]"); | |
990 | + buffer_copy_string_len(token, CONST_STR_LEN("]")); | |
991 | ||
992 | break; | |
993 | case '#': | |
994 | @@ -884,8 +887,8 @@ | |
ad6a5263 ER |
995 | int ret; |
996 | buffer *filename; | |
997 | ||
998 | - if (buffer_is_empty(context->basedir) && | |
999 | - (fn[0] == '/' || fn[0] == '\\') && | |
1000 | + if (buffer_is_empty(context->basedir) || | |
1001 | + (fn[0] == '/' || fn[0] == '\\') || | |
1002 | (fn[0] == '.' && (fn[1] == '/' || fn[1] == '\\'))) { | |
1003 | filename = buffer_init_string(fn); | |
1004 | } else { | |
54b68997 | 1005 | @@ -912,15 +915,39 @@ |
ad6a5263 ER |
1006 | return ret; |
1007 | } | |
1008 | ||
1009 | +static char* getCWD() { | |
1010 | + char *s, *s1; | |
1011 | + size_t len; | |
1012 | +#ifdef PATH_MAX | |
1013 | + len = PATH_MAX; | |
1014 | +#else | |
1015 | + len = 4096; | |
1016 | +#endif | |
1017 | + | |
1018 | + s = malloc(len); | |
1019 | + if (!s) return NULL; | |
1020 | + while (NULL == getcwd(s, len)) { | |
1021 | + if (errno != ERANGE || SSIZE_MAX - len < len) return NULL; | |
1022 | + len *= 2; | |
1023 | + s1 = realloc(s, len); | |
1024 | + if (!s1) { | |
1025 | + free(s); | |
1026 | + return NULL; | |
1027 | + } | |
1028 | + s = s1; | |
1029 | + } | |
1030 | + return s; | |
1031 | +} | |
1032 | + | |
1033 | int config_parse_cmd(server *srv, config_t *context, const char *cmd) { | |
1034 | proc_handler_t proc; | |
1035 | tokenizer_t t; | |
1036 | int ret; | |
1037 | buffer *source; | |
1038 | buffer *out; | |
1039 | - char oldpwd[PATH_MAX]; | |
1040 | + char *oldpwd; | |
1041 | ||
1042 | - if (NULL == getcwd(oldpwd, sizeof(oldpwd))) { | |
1043 | + if (NULL == (oldpwd = getCWD())) { | |
1044 | log_error_write(srv, __FILE__, __LINE__, "s", | |
1045 | "cannot get cwd", strerror(errno)); | |
1046 | return -1; | |
54b68997 | 1047 | @@ -945,6 +972,7 @@ |
ad6a5263 ER |
1048 | buffer_free(source); |
1049 | buffer_free(out); | |
1050 | chdir(oldpwd); | |
1051 | + free(oldpwd); | |
1052 | return ret; | |
1053 | } | |
1054 | ||
54b68997 ER |
1055 | @@ -986,7 +1014,7 @@ |
1056 | } | |
1057 | ||
1058 | dc = data_config_init(); | |
1059 | - buffer_copy_string(dc->key, "global"); | |
1060 | + buffer_copy_string_len(dc->key, CONST_STR_LEN("global")); | |
1061 | ||
1062 | assert(context.all_configs->used == 0); | |
1063 | dc->context_ndx = context.all_configs->used; | |
1064 | @@ -997,14 +1025,14 @@ | |
1065 | srv->config = dc->value; | |
1066 | dpid = data_integer_init(); | |
1067 | dpid->value = getpid(); | |
1068 | - buffer_copy_string(dpid->key, "var.PID"); | |
1069 | + buffer_copy_string_len(dpid->key, CONST_STR_LEN("var.PID")); | |
1070 | array_insert_unique(srv->config, (data_unset *)dpid); | |
1071 | ||
1072 | dcwd = data_string_init(); | |
1073 | buffer_prepare_copy(dcwd->value, 1024); | |
1074 | if (NULL != getcwd(dcwd->value->ptr, dcwd->value->size - 1)) { | |
1075 | dcwd->value->used = strlen(dcwd->value->ptr) + 1; | |
1076 | - buffer_copy_string(dcwd->key, "var.CWD"); | |
1077 | + buffer_copy_string_len(dcwd->key, CONST_STR_LEN("var.CWD")); | |
1078 | array_insert_unique(srv->config, (data_unset *)dcwd); | |
1079 | } | |
1080 | ||
1081 | @@ -1038,7 +1066,7 @@ | |
1082 | /* prepend default modules */ | |
1083 | if (NULL == array_get_element(modules->value, "mod_indexfile")) { | |
1084 | ds = data_string_init(); | |
1085 | - buffer_copy_string(ds->value, "mod_indexfile"); | |
1086 | + buffer_copy_string_len(ds->value, CONST_STR_LEN("mod_indexfile")); | |
1087 | array_insert_unique(prepends->value, (data_unset *)ds); | |
1088 | } | |
1089 | ||
1090 | @@ -1051,13 +1079,13 @@ | |
1091 | /* append default modules */ | |
1092 | if (NULL == array_get_element(modules->value, "mod_dirlisting")) { | |
1093 | ds = data_string_init(); | |
1094 | - buffer_copy_string(ds->value, "mod_dirlisting"); | |
1095 | + buffer_copy_string_len(ds->value, CONST_STR_LEN("mod_dirlisting")); | |
1096 | array_insert_unique(modules->value, (data_unset *)ds); | |
1097 | } | |
1098 | ||
1099 | if (NULL == array_get_element(modules->value, "mod_staticfile")) { | |
1100 | ds = data_string_init(); | |
1101 | - buffer_copy_string(ds->value, "mod_staticfile"); | |
1102 | + buffer_copy_string_len(ds->value, CONST_STR_LEN("mod_staticfile")); | |
1103 | array_insert_unique(modules->value, (data_unset *)ds); | |
1104 | } | |
1105 | } else { | |
1106 | @@ -1067,18 +1095,18 @@ | |
1107 | ||
1108 | /* server.modules is not set */ | |
1109 | ds = data_string_init(); | |
1110 | - buffer_copy_string(ds->value, "mod_indexfile"); | |
1111 | + buffer_copy_string_len(ds->value, CONST_STR_LEN("mod_indexfile")); | |
1112 | array_insert_unique(modules->value, (data_unset *)ds); | |
1113 | ||
1114 | ds = data_string_init(); | |
1115 | - buffer_copy_string(ds->value, "mod_dirlisting"); | |
1116 | + buffer_copy_string_len(ds->value, CONST_STR_LEN("mod_dirlisting")); | |
1117 | array_insert_unique(modules->value, (data_unset *)ds); | |
1118 | ||
1119 | ds = data_string_init(); | |
1120 | - buffer_copy_string(ds->value, "mod_staticfile"); | |
1121 | + buffer_copy_string_len(ds->value, CONST_STR_LEN("mod_staticfile")); | |
1122 | array_insert_unique(modules->value, (data_unset *)ds); | |
1123 | ||
1124 | - buffer_copy_string(modules->key, "server.modules"); | |
1125 | + buffer_copy_string_len(modules->key, CONST_STR_LEN("server.modules")); | |
1126 | array_insert_unique(srv->config, (data_unset *)modules); | |
1127 | } | |
1128 | ||
1129 | Index: src/mod_trigger_b4_dl.c | |
1130 | =================================================================== | |
1131 | --- src/mod_trigger_b4_dl.c (.../tags/lighttpd-1.4.19) (revision 2303) | |
1132 | +++ src/mod_trigger_b4_dl.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
1133 | @@ -316,6 +316,8 @@ | |
1134 | # define N 10 | |
1135 | int ovec[N * 3]; | |
1136 | ||
1137 | + if (con->mode != DIRECT) return HANDLER_GO_ON; | |
1138 | + | |
1139 | if (con->uri.path->used == 0) return HANDLER_GO_ON; | |
1140 | ||
1141 | mod_trigger_b4_dl_patch_connection(srv, con, p); | |
1142 | @@ -425,8 +427,8 @@ | |
1143 | /* not found, redirect */ | |
1144 | ||
1145 | response_header_insert(srv, con, CONST_STR_LEN("Location"), CONST_BUF_LEN(p->conf.deny_url)); | |
1146 | - | |
1147 | con->http_status = 307; | |
1148 | + con->file_finished = 1; | |
1149 | ||
1150 | return HANDLER_FINISHED; | |
1151 | } | |
1152 | @@ -440,6 +442,7 @@ | |
1153 | ||
1154 | response_header_insert(srv, con, CONST_STR_LEN("Location"), CONST_BUF_LEN(p->conf.deny_url)); | |
1155 | con->http_status = 307; | |
1156 | + con->file_finished = 1; | |
1157 | ||
1158 | if (p->conf.db) { | |
1159 | if (0 != gdbm_delete(p->conf.db, key)) { | |
1160 | @@ -490,6 +493,7 @@ | |
1161 | response_header_insert(srv, con, CONST_STR_LEN("Location"), CONST_BUF_LEN(p->conf.deny_url)); | |
1162 | ||
1163 | con->http_status = 307; | |
1164 | + con->file_finished = 1; | |
1165 | ||
1166 | return HANDLER_FINISHED; | |
1167 | } | |
1168 | Index: src/mod_evhost.c | |
1169 | =================================================================== | |
1170 | --- src/mod_evhost.c (.../tags/lighttpd-1.4.19) (revision 2303) | |
1171 | +++ src/mod_evhost.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
1172 | @@ -95,7 +95,7 @@ | |
1173 | s->path_pieces = realloc(s->path_pieces,(s->len+1) * sizeof(*s->path_pieces)); | |
1174 | s->path_pieces[s->len] = buffer_init(); | |
1175 | ||
1176 | - buffer_append_memory(s->path_pieces[s->len],pos,ptr-pos); | |
1177 | + buffer_copy_string_len(s->path_pieces[s->len],pos,ptr-pos); | |
1178 | ||
1179 | s->len += 1; | |
1180 | } | |
1181 | @@ -181,7 +181,7 @@ | |
1182 | } | |
1183 | ||
1184 | ds = data_string_init(); | |
1185 | - buffer_copy_string(ds->key,"%0"); | |
1186 | + buffer_copy_string_len(ds->key,CONST_STR_LEN("%0")); | |
1187 | ||
1188 | /* if we stopped at a dot, skip the dot */ | |
1189 | if (*ptr == '.') ptr++; | |
1190 | @@ -197,7 +197,7 @@ | |
1191 | if (ptr != colon - 1) { | |
1192 | /* is something between the dots */ | |
1193 | ds = data_string_init(); | |
1194 | - buffer_copy_string(ds->key,"%"); | |
1195 | + buffer_copy_string_len(ds->key,CONST_STR_LEN("%")); | |
1196 | buffer_append_long(ds->key, i++); | |
1197 | buffer_copy_string_len(ds->value,ptr+1,colon-ptr-1); | |
1198 | ||
1199 | @@ -210,7 +210,7 @@ | |
1200 | /* if the . is not the first charactor of the hostname */ | |
1201 | if (colon != ptr) { | |
1202 | ds = data_string_init(); | |
1203 | - buffer_copy_string(ds->key,"%"); | |
1204 | + buffer_copy_string_len(ds->key,CONST_STR_LEN("%")); | |
1205 | buffer_append_long(ds->key, i++); | |
1206 | buffer_copy_string_len(ds->value,ptr,colon-ptr); | |
1207 | ||
1208 | @@ -286,7 +286,7 @@ | |
1209 | ||
1210 | if (*(ptr+1) == '%') { | |
1211 | /* %% */ | |
1212 | - BUFFER_APPEND_STRING_CONST(p->tmp_buf,"%"); | |
1213 | + buffer_append_string_len(p->tmp_buf,CONST_STR_LEN("%")); | |
1214 | } else if (NULL != (ds = (data_string *)array_get_element(parsed_host,p->conf.path_pieces[i]->ptr))) { | |
1215 | if (ds->value->used) { | |
1216 | buffer_append_string_buffer(p->tmp_buf,ds->value); | |
1217 | Index: src/chunk.c | |
1218 | =================================================================== | |
1219 | --- src/chunk.c (.../tags/lighttpd-1.4.19) (revision 2303) | |
1220 | +++ src/chunk.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
1221 | @@ -296,7 +296,7 @@ | |
1222 | ||
1223 | buffer_copy_string_buffer(template, ds->value); | |
1224 | BUFFER_APPEND_SLASH(template); | |
1225 | - BUFFER_APPEND_STRING_CONST(template, "lighttpd-upload-XXXXXX"); | |
1226 | + buffer_append_string_len(template, CONST_STR_LEN("lighttpd-upload-XXXXXX")); | |
1227 | ||
1228 | if (-1 != (c->file.fd = mkstemp(template->ptr))) { | |
1229 | /* only trigger the unlink if we created the temp-file successfully */ | |
ad6a5263 ER |
1230 | Index: src/lemon.c |
1231 | =================================================================== | |
54b68997 ER |
1232 | --- src/lemon.c (.../tags/lighttpd-1.4.19) (revision 2303) |
1233 | +++ src/lemon.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
ad6a5263 ER |
1234 | @@ -12,6 +12,19 @@ |
1235 | #include <ctype.h> | |
1236 | #include <stdlib.h> | |
1237 | ||
1238 | +#ifdef HAVE_CONFIG_H | |
1239 | +#include "config.h" | |
1240 | +#endif | |
1241 | + | |
1242 | +#ifdef HAVE_STDINT_H | |
1243 | +# include <stdint.h> | |
1244 | +#endif | |
1245 | +#ifdef HAVE_INTTYPES_H | |
1246 | +# include <inttypes.h> | |
1247 | +#endif | |
1248 | + | |
1249 | +#define UNUSED(x) ( (void)(x) ) | |
1250 | + | |
1251 | extern void qsort(); | |
1252 | extern double strtod(); | |
1253 | extern long strtol(); | |
1254 | @@ -983,6 +996,7 @@ | |
1255 | { | |
1256 | struct symbol *spx, *spy; | |
1257 | int errcnt = 0; | |
1258 | + UNUSED(errsym); | |
1259 | assert( apx->sp==apy->sp ); /* Otherwise there would be no conflict */ | |
1260 | if( apx->type==SHIFT && apy->type==REDUCE ){ | |
1261 | spx = apx->sp; | |
1262 | @@ -1347,6 +1361,7 @@ | |
1263 | struct lemon lem; | |
1264 | char *def_tmpl_name = "lempar.c"; | |
1265 | ||
1266 | + UNUSED(argc); | |
1267 | OptInit(argv,options,stderr); | |
1268 | if( version ){ | |
1269 | printf("Lemon version 1.0\n"); | |
1270 | @@ -1651,7 +1666,7 @@ | |
1271 | }else if( op[j].type==OPT_FLAG ){ | |
1272 | *((int*)op[j].arg) = v; | |
1273 | }else if( op[j].type==OPT_FFLAG ){ | |
1274 | - (*(void(*)())(op[j].arg))(v); | |
1275 | + (*(void(*)())(intptr_t)(op[j].arg))(v); | |
1276 | }else{ | |
1277 | if( err ){ | |
1278 | fprintf(err,"%smissing argument on switch.\n",emsg); | |
1279 | @@ -1733,19 +1748,19 @@ | |
1280 | *(double*)(op[j].arg) = dv; | |
1281 | break; | |
1282 | case OPT_FDBL: | |
1283 | - (*(void(*)())(op[j].arg))(dv); | |
1284 | + (*(void(*)())(intptr_t)(op[j].arg))(dv); | |
1285 | break; | |
1286 | case OPT_INT: | |
1287 | *(int*)(op[j].arg) = lv; | |
1288 | break; | |
1289 | case OPT_FINT: | |
1290 | - (*(void(*)())(op[j].arg))((int)lv); | |
1291 | + (*(void(*)())(intptr_t)(op[j].arg))((int)lv); | |
1292 | break; | |
1293 | case OPT_STR: | |
1294 | *(char**)(op[j].arg) = sv; | |
1295 | break; | |
1296 | case OPT_FSTR: | |
1297 | - (*(void(*)())(op[j].arg))(sv); | |
1298 | + (*(void(*)())(intptr_t)(op[j].arg))(sv); | |
1299 | break; | |
1300 | } | |
1301 | } | |
1302 | @@ -2286,10 +2301,10 @@ | |
1303 | ** token is passed to the function "parseonetoken" which builds all | |
1304 | ** the appropriate data structures in the global state vector "gp". | |
1305 | */ | |
1306 | +struct pstate ps; | |
1307 | void Parse(gp) | |
1308 | struct lemon *gp; | |
1309 | { | |
1310 | - struct pstate ps; | |
1311 | FILE *fp; | |
1312 | char *filebuf; | |
1313 | size_t filesize; | |
54b68997 ER |
1314 | Index: src/mod_skeleton.c |
1315 | =================================================================== | |
1316 | --- src/mod_skeleton.c (.../tags/lighttpd-1.4.19) (revision 2303) | |
1317 | +++ src/mod_skeleton.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
1318 | @@ -169,6 +169,8 @@ | |
1319 | ||
1320 | UNUSED(srv); | |
1321 | ||
1322 | + if (con->mode != DIRECT) return HANDLER_GO_ON; | |
1323 | + | |
1324 | if (con->uri.path->used == 0) return HANDLER_GO_ON; | |
1325 | ||
1326 | mod_skeleton_patch_connection(srv, con, p); | |
ad6a5263 ER |
1327 | Index: src/mod_scgi.c |
1328 | =================================================================== | |
54b68997 ER |
1329 | --- src/mod_scgi.c (.../tags/lighttpd-1.4.19) (revision 2303) |
1330 | +++ src/mod_scgi.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
ad6a5263 ER |
1331 | @@ -202,6 +202,15 @@ |
1332 | * | |
1333 | */ | |
1334 | ||
1335 | + /* | |
1336 | + * workaround for program when prefix="/" | |
1337 | + * | |
1338 | + * rule to build PATH_INFO is hardcoded for when check_local is disabled | |
1339 | + * enable this option to use the workaround | |
1340 | + * | |
1341 | + */ | |
1342 | + | |
1343 | + unsigned short fix_root_path_name; | |
1344 | ssize_t load; /* replace by host->load */ | |
1345 | ||
1346 | size_t max_id; /* corresponds most of the time to | |
1347 | @@ -233,6 +242,7 @@ | |
1348 | typedef struct { | |
1349 | buffer *key; /* like .php */ | |
1350 | ||
1351 | + int note_is_sent; | |
1352 | scgi_extension_host **hosts; | |
1353 | ||
1354 | size_t used; | |
54b68997 ER |
1355 | @@ -583,6 +593,7 @@ |
1356 | ||
1357 | static int env_add(char_array *env, const char *key, size_t key_len, const char *val, size_t val_len) { | |
1358 | char *dst; | |
1359 | + size_t i; | |
1360 | ||
1361 | if (!key || !val) return -1; | |
1362 | ||
1363 | @@ -592,6 +603,15 @@ | |
1364 | /* add the \0 from the value */ | |
1365 | memcpy(dst + key_len + 1, val, val_len + 1); | |
1366 | ||
1367 | + for (i = 0; i < env->used; i++) { | |
1368 | + if (0 == strncmp(dst, env->ptr[i], key_len + 1)) { | |
1369 | + /* don't care about free as we are in a forked child which is going to exec(...) */ | |
1370 | + /* free(env->ptr[i]); */ | |
1371 | + env->ptr[i] = dst; | |
1372 | + return 0; | |
1373 | + } | |
1374 | + } | |
1375 | + | |
1376 | if (env->size == 0) { | |
1377 | env->size = 16; | |
1378 | env->ptr = malloc(env->size * sizeof(*env->ptr)); | |
1379 | @@ -749,11 +769,20 @@ | |
1380 | env.size = 0; | |
1381 | env.used = 0; | |
1382 | ||
1383 | + if (scgi_fd != 0) { | |
1384 | + close(0); | |
1385 | + dup2(scgi_fd, 0); | |
1386 | + close(scgi_fd); | |
1387 | + scgi_fd = 0; | |
1388 | + } | |
1389 | + | |
1390 | /* we don't need the client socket */ | |
1391 | for (fd = 3; fd < 256; fd++) { | |
1392 | - if (fd != 2 && fd != scgi_fd) close(fd); | |
1393 | + close(fd); | |
1394 | } | |
1395 | ||
1396 | + openDevNull(STDERR_FILENO); | |
1397 | + | |
1398 | /* build clean environment */ | |
1399 | if (host->bin_env_copy->used) { | |
1400 | for (i = 0; i < host->bin_env_copy->used; i++) { | |
1401 | @@ -794,7 +823,7 @@ | |
1402 | env.ptr[env.used] = NULL; | |
1403 | ||
1404 | b = buffer_init(); | |
1405 | - buffer_copy_string(b, "exec "); | |
1406 | + buffer_copy_string_len(b, CONST_STR_LEN("exec ")); | |
1407 | buffer_append_string_buffer(b, host->bin_path); | |
1408 | ||
1409 | /* exec the cgi */ | |
1410 | @@ -968,6 +997,7 @@ | |
ad6a5263 ER |
1411 | |
1412 | { "bin-environment", NULL, T_CONFIG_ARRAY, T_CONFIG_SCOPE_CONNECTION }, /* 11 */ | |
1413 | { "bin-copy-environment", NULL, T_CONFIG_ARRAY, T_CONFIG_SCOPE_CONNECTION }, /* 12 */ | |
1414 | + { "fix-root-scriptname", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 13 */ | |
1415 | ||
1416 | ||
1417 | { NULL, NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET } | |
54b68997 | 1418 | @@ -990,6 +1020,7 @@ |
ad6a5263 ER |
1419 | df->max_load_per_proc = 1; |
1420 | df->idle_timeout = 60; | |
1421 | df->disable_time = 60; | |
1422 | + df->fix_root_path_name = 0; | |
1423 | ||
1424 | fcv[0].destination = df->host; | |
1425 | fcv[1].destination = df->docroot; | |
54b68997 | 1426 | @@ -1006,6 +1037,7 @@ |
ad6a5263 ER |
1427 | |
1428 | fcv[11].destination = df->bin_env; | |
1429 | fcv[12].destination = df->bin_env_copy; | |
1430 | + fcv[13].destination = &(df->fix_root_path_name); | |
1431 | ||
1432 | ||
1433 | if (0 != config_insert_values_internal(srv, da_host->value, fcv)) { | |
54b68997 ER |
1434 | @@ -1084,7 +1116,7 @@ |
1435 | proc->port = df->port + pno; | |
1436 | } else { | |
1437 | buffer_copy_string_buffer(proc->socket, df->unixsocket); | |
1438 | - buffer_append_string(proc->socket, "-"); | |
1439 | + buffer_append_string_len(proc->socket, CONST_STR_LEN("-")); | |
1440 | buffer_append_long(proc->socket, pno); | |
1441 | } | |
1442 | ||
1443 | @@ -1155,11 +1187,6 @@ | |
1444 | p = hctx->plugin_data; | |
1445 | con = hctx->remote_conn; | |
1446 | ||
1447 | - if (con->mode != p->id) { | |
1448 | - WP(); | |
1449 | - return; | |
1450 | - } | |
1451 | - | |
1452 | if (hctx->fd != -1) { | |
1453 | fdevent_event_del(srv->ev, &(hctx->fde_ndx), hctx->fd); | |
1454 | fdevent_unregister(srv->ev, hctx->fd); | |
1455 | @@ -1366,7 +1393,7 @@ | |
1456 | buffer_reset(srv->tmp_buf); | |
1457 | ||
1458 | if (0 != strcasecmp(ds->key->ptr, "CONTENT-TYPE")) { | |
1459 | - BUFFER_COPY_STRING_CONST(srv->tmp_buf, "HTTP_"); | |
1460 | + buffer_copy_string_len(srv->tmp_buf, CONST_STR_LEN("HTTP_")); | |
1461 | srv->tmp_buf->used--; | |
1462 | } | |
1463 | ||
1464 | @@ -1394,7 +1421,7 @@ | |
1465 | buffer_prepare_append(srv->tmp_buf, ds->key->used + 2); | |
1466 | for (j = 0; j < ds->key->used - 1; j++) { | |
1467 | srv->tmp_buf->ptr[srv->tmp_buf->used++] = | |
1468 | - isalpha((unsigned char)ds->key->ptr[j]) ? | |
1469 | + light_isalnum((unsigned char)ds->key->ptr[j]) ? | |
1470 | toupper((unsigned char)ds->key->ptr[j]) : '_'; | |
1471 | } | |
1472 | srv->tmp_buf->ptr[srv->tmp_buf->used++] = '\0'; | |
1473 | @@ -1673,9 +1700,8 @@ | |
1474 | ||
1475 | status = strtol(s+9, NULL, 10); | |
1476 | ||
1477 | - if (con->http_status >= 100 && | |
1478 | - con->http_status < 1000) { | |
1479 | - /* we expected 3 digits and didn't got them */ | |
1480 | + if (status >= 100 && status < 1000) { | |
1481 | + /* we expected 3 digits got them */ | |
1482 | con->parsed_response |= HTTP_STATUS; | |
1483 | con->http_status = status; | |
1484 | } | |
1485 | @@ -2438,15 +2464,11 @@ | |
1486 | p = hctx->plugin_data; | |
1487 | con = hctx->remote_conn; | |
1488 | ||
1489 | - if (con->mode != p->id) return HANDLER_GO_ON; | |
1490 | - | |
1491 | log_error_write(srv, __FILE__, __LINE__, "ssdsd", | |
1492 | "emergency exit: scgi:", | |
1493 | "connection-fd:", con->fd, | |
1494 | "fcgi-fd:", hctx->fd); | |
1495 | ||
1496 | - | |
1497 | - | |
1498 | scgi_connection_cleanup(srv, hctx); | |
1499 | ||
1500 | return HANDLER_FINISHED; | |
1501 | @@ -2668,11 +2690,13 @@ | |
ad6a5263 ER |
1502 | plugin_data *p = p_d; |
1503 | size_t s_len; | |
1504 | int used = -1; | |
1505 | - int ndx; | |
1506 | size_t k; | |
1507 | buffer *fn; | |
1508 | scgi_extension *extension = NULL; | |
1509 | + scgi_extension_host *host = NULL; | |
1510 | ||
54b68997 ER |
1511 | + if (con->mode != DIRECT) return HANDLER_GO_ON; |
1512 | + | |
ad6a5263 ER |
1513 | /* Possibly, we processed already this request */ |
1514 | if (con->file_started == 1) return HANDLER_GO_ON; | |
54b68997 ER |
1515 | |
1516 | @@ -2712,95 +2736,59 @@ | |
ad6a5263 ER |
1517 | } |
1518 | ||
1519 | /* get best server */ | |
1520 | - for (k = 0, ndx = -1; k < extension->used; k++) { | |
1521 | - scgi_extension_host *host = extension->hosts[k]; | |
1522 | + for (k = 0; k < extension->used; k++) { | |
1523 | + scgi_extension_host *h = extension->hosts[k]; | |
1524 | ||
1525 | - /* we should have at least one proc that can do somthing */ | |
1526 | - if (host->active_procs == 0) continue; | |
1527 | + /* we should have at least one proc that can do something */ | |
1528 | + if (h->active_procs == 0) { | |
1529 | + continue; | |
1530 | + } | |
1531 | ||
1532 | - if (used == -1 || host->load < used) { | |
1533 | - used = host->load; | |
1534 | + if (used == -1 || h->load < used) { | |
1535 | + used = h->load; | |
1536 | ||
1537 | - ndx = k; | |
1538 | + host = h; | |
1539 | } | |
1540 | } | |
1541 | ||
1542 | - /* found a server */ | |
1543 | - if (ndx != -1) { | |
1544 | - scgi_extension_host *host = extension->hosts[ndx]; | |
1545 | + if (!host) { | |
1546 | + /* sorry, we don't have a server alive for this ext */ | |
1547 | + buffer_reset(con->physical.path); | |
1548 | + con->http_status = 500; | |
1549 | ||
1550 | - /* | |
1551 | - * if check-local is disabled, use the uri.path handler | |
1552 | - * | |
1553 | - */ | |
1554 | + /* only send the 'no handler' once */ | |
1555 | + if (!extension->note_is_sent) { | |
1556 | + extension->note_is_sent = 1; | |
1557 | ||
1558 | - /* init handler-context */ | |
1559 | - if (uri_path_handler) { | |
1560 | - if (host->check_local == 0) { | |
1561 | - handler_ctx *hctx; | |
1562 | - char *pathinfo; | |
1563 | + log_error_write(srv, __FILE__, __LINE__, "sbsbs", | |
1564 | + "all handlers for ", con->uri.path, | |
1565 | + "on", extension->key, | |
1566 | + "are down."); | |
1567 | + } | |
1568 | ||
1569 | - hctx = handler_ctx_init(); | |
1570 | + return HANDLER_FINISHED; | |
1571 | + } | |
1572 | ||
1573 | - hctx->remote_conn = con; | |
1574 | - hctx->plugin_data = p; | |
1575 | - hctx->host = host; | |
1576 | - hctx->proc = NULL; | |
1577 | + /* a note about no handler is not sent yet */ | |
1578 | + extension->note_is_sent = 0; | |
1579 | ||
1580 | - hctx->conf.exts = p->conf.exts; | |
1581 | - hctx->conf.debug = p->conf.debug; | |
1582 | + /* | |
1583 | + * if check-local is disabled, use the uri.path handler | |
1584 | + * | |
1585 | + */ | |
1586 | ||
1587 | - con->plugin_ctx[p->id] = hctx; | |
1588 | + /* init handler-context */ | |
1589 | + if (uri_path_handler) { | |
1590 | + if (host->check_local == 0) { | |
1591 | + handler_ctx *hctx; | |
1592 | + char *pathinfo; | |
1593 | ||
1594 | - host->load++; | |
1595 | - | |
1596 | - con->mode = p->id; | |
1597 | - | |
1598 | - if (con->conf.log_request_handling) { | |
1599 | - log_error_write(srv, __FILE__, __LINE__, "s", "handling it in mod_scgi"); | |
1600 | - } | |
1601 | - | |
1602 | - /* the prefix is the SCRIPT_NAME, | |
1603 | - * everthing from start to the next slash | |
1604 | - * this is important for check-local = "disable" | |
1605 | - * | |
1606 | - * if prefix = /admin.fcgi | |
1607 | - * | |
1608 | - * /admin.fcgi/foo/bar | |
1609 | - * | |
1610 | - * SCRIPT_NAME = /admin.fcgi | |
1611 | - * PATH_INFO = /foo/bar | |
1612 | - * | |
1613 | - * if prefix = /fcgi-bin/ | |
1614 | - * | |
1615 | - * /fcgi-bin/foo/bar | |
1616 | - * | |
1617 | - * SCRIPT_NAME = /fcgi-bin/foo | |
1618 | - * PATH_INFO = /bar | |
1619 | - * | |
1620 | - */ | |
1621 | - | |
1622 | - /* the rewrite is only done for /prefix/? matches */ | |
1623 | - if (extension->key->ptr[0] == '/' && | |
1624 | - con->uri.path->used > extension->key->used && | |
1625 | - NULL != (pathinfo = strchr(con->uri.path->ptr + extension->key->used - 1, '/'))) { | |
1626 | - /* rewrite uri.path and pathinfo */ | |
1627 | - | |
1628 | - buffer_copy_string(con->request.pathinfo, pathinfo); | |
1629 | - | |
1630 | - con->uri.path->used -= con->request.pathinfo->used - 1; | |
1631 | - con->uri.path->ptr[con->uri.path->used - 1] = '\0'; | |
1632 | - } | |
1633 | - } | |
1634 | - return HANDLER_GO_ON; | |
1635 | - } else { | |
1636 | - handler_ctx *hctx; | |
1637 | hctx = handler_ctx_init(); | |
1638 | ||
1639 | hctx->remote_conn = con; | |
1640 | hctx->plugin_data = p; | |
1641 | hctx->host = host; | |
1642 | - hctx->proc = NULL; | |
1643 | + hctx->proc = NULL; | |
1644 | ||
1645 | hctx->conf.exts = p->conf.exts; | |
1646 | hctx->conf.debug = p->conf.debug; | |
54b68997 | 1647 | @@ -2812,22 +2800,69 @@ |
ad6a5263 ER |
1648 | con->mode = p->id; |
1649 | ||
1650 | if (con->conf.log_request_handling) { | |
1651 | - log_error_write(srv, __FILE__, __LINE__, "s", "handling it in mod_fastcgi"); | |
1652 | + log_error_write(srv, __FILE__, __LINE__, "s", | |
1653 | + "handling it in mod_fastcgi"); | |
1654 | } | |
1655 | ||
1656 | - return HANDLER_GO_ON; | |
1657 | + /* the prefix is the SCRIPT_NAME, | |
1658 | + * everything from start to the next slash | |
1659 | + * this is important for check-local = "disable" | |
1660 | + * | |
1661 | + * if prefix = /admin.fcgi | |
1662 | + * | |
1663 | + * /admin.fcgi/foo/bar | |
1664 | + * | |
1665 | + * SCRIPT_NAME = /admin.fcgi | |
1666 | + * PATH_INFO = /foo/bar | |
1667 | + * | |
1668 | + * if prefix = /fcgi-bin/ | |
1669 | + * | |
1670 | + * /fcgi-bin/foo/bar | |
1671 | + * | |
1672 | + * SCRIPT_NAME = /fcgi-bin/foo | |
1673 | + * PATH_INFO = /bar | |
1674 | + * | |
1675 | + */ | |
1676 | + | |
1677 | + /* the rewrite is only done for /prefix/? matches */ | |
1678 | + if (extension->key->ptr[0] == '/' && | |
1679 | + con->uri.path->used > extension->key->used && | |
1680 | + NULL != (pathinfo = strchr(con->uri.path->ptr + extension->key->used - 1, '/'))) { | |
1681 | + /* rewrite uri.path and pathinfo */ | |
1682 | + | |
1683 | + buffer_copy_string(con->request.pathinfo, pathinfo); | |
1684 | + | |
1685 | + con->uri.path->used -= con->request.pathinfo->used - 1; | |
1686 | + con->uri.path->ptr[con->uri.path->used - 1] = '\0'; | |
1687 | + } else if (host->fix_root_path_name && extension->key->ptr[0] == '/' && extension->key->ptr[1] == '\0') { | |
1688 | + buffer_copy_string(con->request.pathinfo, con->uri.path->ptr); | |
1689 | + con->uri.path->used = 1; | |
1690 | + con->uri.path->ptr[con->uri.path->used - 1] = '\0'; | |
1691 | + } | |
1692 | } | |
1693 | } else { | |
1694 | - /* no handler found */ | |
1695 | - buffer_reset(con->physical.path); | |
1696 | - con->http_status = 500; | |
1697 | + handler_ctx *hctx; | |
1698 | + hctx = handler_ctx_init(); | |
1699 | ||
1700 | - log_error_write(srv, __FILE__, __LINE__, "sb", | |
1701 | - "no fcgi-handler found for:", | |
1702 | - fn); | |
1703 | + hctx->remote_conn = con; | |
1704 | + hctx->plugin_data = p; | |
1705 | + hctx->host = host; | |
1706 | + hctx->proc = NULL; | |
1707 | ||
1708 | - return HANDLER_FINISHED; | |
1709 | + hctx->conf.exts = p->conf.exts; | |
1710 | + hctx->conf.debug = p->conf.debug; | |
1711 | + | |
1712 | + con->plugin_ctx[p->id] = hctx; | |
1713 | + | |
1714 | + host->load++; | |
1715 | + | |
1716 | + con->mode = p->id; | |
1717 | + | |
1718 | + if (con->conf.log_request_handling) { | |
1719 | + log_error_write(srv, __FILE__, __LINE__, "s", "handling it in mod_fastcgi"); | |
1720 | + } | |
1721 | } | |
1722 | + | |
1723 | return HANDLER_GO_ON; | |
1724 | } | |
1725 | ||
54b68997 ER |
1726 | @@ -2949,7 +2984,7 @@ |
1727 | fp->port = host->port + fp->id; | |
1728 | } else { | |
1729 | buffer_copy_string_buffer(fp->socket, host->unixsocket); | |
1730 | - buffer_append_string(fp->socket, "-"); | |
1731 | + buffer_append_string_len(fp->socket, CONST_STR_LEN("-")); | |
1732 | buffer_append_long(fp->socket, fp->id); | |
1733 | } | |
1734 | ||
1735 | Index: src/mod_mysql_vhost.c | |
1736 | =================================================================== | |
1737 | --- src/mod_mysql_vhost.c (.../tags/lighttpd-1.4.19) (revision 2303) | |
1738 | +++ src/mod_mysql_vhost.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
1739 | @@ -410,6 +410,7 @@ | |
1740 | ||
1741 | ERR500: if (result) mysql_free_result(result); | |
1742 | con->http_status = 500; /* Internal Error */ | |
1743 | + con->mode = DIRECT; | |
1744 | return HANDLER_FINISHED; | |
1745 | } | |
1746 | ||
1747 | Index: src/mod_flv_streaming.c | |
1748 | =================================================================== | |
1749 | --- src/mod_flv_streaming.c (.../tags/lighttpd-1.4.19) (revision 2303) | |
1750 | +++ src/mod_flv_streaming.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
1751 | @@ -193,6 +193,8 @@ | |
1752 | ||
1753 | UNUSED(srv); | |
1754 | ||
1755 | + if (con->mode != DIRECT) return HANDLER_GO_ON; | |
1756 | + | |
1757 | if (buffer_is_empty(con->physical.path)) return HANDLER_GO_ON; | |
1758 | ||
1759 | mod_flv_streaming_patch_connection(srv, con, p); | |
1760 | @@ -245,7 +247,7 @@ | |
1761 | ||
1762 | /* we are safe now, let's build a flv header */ | |
1763 | b = chunkqueue_get_append_buffer(con->write_queue); | |
1764 | - BUFFER_COPY_STRING_CONST(b, "FLV\x1\x1\0\0\0\x9\0\0\0\x9"); | |
1765 | + buffer_copy_string_len(b, CONST_STR_LEN("FLV\x1\x1\0\0\0\x9\0\0\0\x9")); | |
1766 | ||
1767 | http_chunk_append_file(srv, con, con->physical.path, start, sce->st.st_size - start); | |
1768 | ||
ad6a5263 ER |
1769 | Index: src/lighttpd-angel.c |
1770 | =================================================================== | |
54b68997 ER |
1771 | --- src/lighttpd-angel.c (.../tags/lighttpd-1.4.19) (revision 2303) |
1772 | +++ src/lighttpd-angel.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
ad6a5263 ER |
1773 | @@ -28,9 +28,12 @@ |
1774 | static volatile sig_atomic_t graceful_restart = 0; | |
1775 | static volatile pid_t pid = -1; | |
1776 | ||
1777 | +#define UNUSED(x) ( (void)(x) ) | |
1778 | + | |
1779 | static void sigaction_handler(int sig, siginfo_t *si, void *context) { | |
1780 | int exitcode; | |
1781 | ||
1782 | + UNUSED(context); | |
1783 | switch (sig) { | |
1784 | case SIGINT: | |
1785 | case SIGTERM: | |
1786 | @@ -60,6 +63,8 @@ | |
1787 | int is_shutdown = 0; | |
1788 | struct sigaction act; | |
1789 | ||
1790 | + UNUSED(argc); | |
1791 | + | |
1792 | /** | |
1793 | * we are running as root BEWARE | |
1794 | */ | |
1795 | Index: src/mod_rrdtool.c | |
1796 | =================================================================== | |
54b68997 ER |
1797 | --- src/mod_rrdtool.c (.../tags/lighttpd-1.4.19) (revision 2303) |
1798 | +++ src/mod_rrdtool.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
ad6a5263 ER |
1799 | @@ -148,6 +148,8 @@ |
1800 | args[i++] = dash; | |
1801 | args[i++] = NULL; | |
1802 | ||
1803 | + openDevNull(STDERR_FILENO); | |
1804 | + | |
1805 | /* we don't need the client socket */ | |
1806 | for (i = 3; i < 256; i++) { | |
1807 | close(i); | |
1808 | @@ -156,7 +158,7 @@ | |
1809 | /* exec the cgi */ | |
1810 | execv(args[0], args); | |
1811 | ||
1812 | - log_error_write(srv, __FILE__, __LINE__, "sss", "spawing rrdtool failed: ", strerror(errno), args[0]); | |
1813 | + /* log_error_write(srv, __FILE__, __LINE__, "sss", "spawing rrdtool failed: ", strerror(errno), args[0]); */ | |
1814 | ||
1815 | /* */ | |
1816 | SEGFAULT(); | |
54b68997 ER |
1817 | @@ -202,24 +204,25 @@ |
1818 | int r ; | |
1819 | /* create a new one */ | |
1820 | ||
1821 | - BUFFER_COPY_STRING_CONST(p->cmd, "create "); | |
1822 | + buffer_copy_string_len(p->cmd, CONST_STR_LEN("create ")); | |
1823 | buffer_append_string_buffer(p->cmd, s->path_rrd); | |
1824 | - buffer_append_string(p->cmd, " --step 60 "); | |
1825 | - buffer_append_string(p->cmd, "DS:InOctets:ABSOLUTE:600:U:U "); | |
1826 | - buffer_append_string(p->cmd, "DS:OutOctets:ABSOLUTE:600:U:U "); | |
1827 | - buffer_append_string(p->cmd, "DS:Requests:ABSOLUTE:600:U:U "); | |
1828 | - buffer_append_string(p->cmd, "RRA:AVERAGE:0.5:1:600 "); | |
1829 | - buffer_append_string(p->cmd, "RRA:AVERAGE:0.5:6:700 "); | |
1830 | - buffer_append_string(p->cmd, "RRA:AVERAGE:0.5:24:775 "); | |
1831 | - buffer_append_string(p->cmd, "RRA:AVERAGE:0.5:288:797 "); | |
1832 | - buffer_append_string(p->cmd, "RRA:MAX:0.5:1:600 "); | |
1833 | - buffer_append_string(p->cmd, "RRA:MAX:0.5:6:700 "); | |
1834 | - buffer_append_string(p->cmd, "RRA:MAX:0.5:24:775 "); | |
1835 | - buffer_append_string(p->cmd, "RRA:MAX:0.5:288:797 "); | |
1836 | - buffer_append_string(p->cmd, "RRA:MIN:0.5:1:600 "); | |
1837 | - buffer_append_string(p->cmd, "RRA:MIN:0.5:6:700 "); | |
1838 | - buffer_append_string(p->cmd, "RRA:MIN:0.5:24:775 "); | |
1839 | - buffer_append_string(p->cmd, "RRA:MIN:0.5:288:797\n"); | |
1840 | + buffer_append_string_len(p->cmd, CONST_STR_LEN( | |
1841 | + " --step 60 " | |
1842 | + "DS:InOctets:ABSOLUTE:600:U:U " | |
1843 | + "DS:OutOctets:ABSOLUTE:600:U:U " | |
1844 | + "DS:Requests:ABSOLUTE:600:U:U " | |
1845 | + "RRA:AVERAGE:0.5:1:600 " | |
1846 | + "RRA:AVERAGE:0.5:6:700 " | |
1847 | + "RRA:AVERAGE:0.5:24:775 " | |
1848 | + "RRA:AVERAGE:0.5:288:797 " | |
1849 | + "RRA:MAX:0.5:1:600 " | |
1850 | + "RRA:MAX:0.5:6:700 " | |
1851 | + "RRA:MAX:0.5:24:775 " | |
1852 | + "RRA:MAX:0.5:288:797 " | |
1853 | + "RRA:MIN:0.5:1:600 " | |
1854 | + "RRA:MIN:0.5:6:700 " | |
1855 | + "RRA:MIN:0.5:24:775 " | |
1856 | + "RRA:MIN:0.5:288:797\n")); | |
1857 | ||
1858 | if (-1 == (r = write(p->write_fd, p->cmd->ptr, p->cmd->used - 1))) { | |
1859 | log_error_write(srv, __FILE__, __LINE__, "ss", | |
1860 | @@ -372,15 +375,15 @@ | |
1861 | ||
1862 | if (HANDLER_GO_ON != mod_rrdtool_create_rrd(srv, p, s)) return HANDLER_ERROR; | |
1863 | ||
1864 | - BUFFER_COPY_STRING_CONST(p->cmd, "update "); | |
1865 | + buffer_copy_string_len(p->cmd, CONST_STR_LEN("update ")); | |
1866 | buffer_append_string_buffer(p->cmd, s->path_rrd); | |
1867 | - BUFFER_APPEND_STRING_CONST(p->cmd, " N:"); | |
1868 | + buffer_append_string_len(p->cmd, CONST_STR_LEN(" N:")); | |
1869 | buffer_append_off_t(p->cmd, s->bytes_read); | |
1870 | - BUFFER_APPEND_STRING_CONST(p->cmd, ":"); | |
1871 | + buffer_append_string_len(p->cmd, CONST_STR_LEN(":")); | |
1872 | buffer_append_off_t(p->cmd, s->bytes_written); | |
1873 | - BUFFER_APPEND_STRING_CONST(p->cmd, ":"); | |
1874 | + buffer_append_string_len(p->cmd, CONST_STR_LEN(":")); | |
1875 | buffer_append_long(p->cmd, s->requests); | |
1876 | - BUFFER_APPEND_STRING_CONST(p->cmd, "\n"); | |
1877 | + buffer_append_string_len(p->cmd, CONST_STR_LEN("\n")); | |
1878 | ||
1879 | if (-1 == (r = write(p->write_fd, p->cmd->ptr, p->cmd->used - 1))) { | |
1880 | p->rrdtool_running = 0; | |
1881 | Index: src/mod_ssi_expr.c | |
1882 | =================================================================== | |
1883 | --- src/mod_ssi_expr.c (.../tags/lighttpd-1.4.19) (revision 2303) | |
1884 | +++ src/mod_ssi_expr.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
1885 | @@ -59,7 +59,7 @@ | |
1886 | t->offset++; | |
1887 | t->line_pos++; | |
1888 | ||
1889 | - buffer_copy_string(token, "(=)"); | |
1890 | + buffer_copy_string_len(token, CONST_STR_LEN("(=)")); | |
1891 | ||
1892 | break; | |
1893 | case '>': | |
1894 | @@ -69,14 +69,14 @@ | |
1895 | ||
1896 | tid = TK_GE; | |
1897 | ||
1898 | - buffer_copy_string(token, "(>=)"); | |
1899 | + buffer_copy_string_len(token, CONST_STR_LEN("(>=)")); | |
1900 | } else { | |
1901 | t->offset += 1; | |
1902 | t->line_pos += 1; | |
1903 | ||
1904 | tid = TK_GT; | |
1905 | ||
1906 | - buffer_copy_string(token, "(>)"); | |
1907 | + buffer_copy_string_len(token, CONST_STR_LEN("(>)")); | |
1908 | } | |
1909 | ||
1910 | break; | |
1911 | @@ -87,14 +87,14 @@ | |
1912 | ||
1913 | tid = TK_LE; | |
1914 | ||
1915 | - buffer_copy_string(token, "(<=)"); | |
1916 | + buffer_copy_string_len(token, CONST_STR_LEN("(<=)")); | |
1917 | } else { | |
1918 | t->offset += 1; | |
1919 | t->line_pos += 1; | |
1920 | ||
1921 | tid = TK_LT; | |
1922 | ||
1923 | - buffer_copy_string(token, "(<)"); | |
1924 | + buffer_copy_string_len(token, CONST_STR_LEN("(<)")); | |
1925 | } | |
1926 | ||
1927 | break; | |
1928 | @@ -106,14 +106,14 @@ | |
1929 | ||
1930 | tid = TK_NE; | |
1931 | ||
1932 | - buffer_copy_string(token, "(!=)"); | |
1933 | + buffer_copy_string_len(token, CONST_STR_LEN("(!=)")); | |
1934 | } else { | |
1935 | t->offset += 1; | |
1936 | t->line_pos += 1; | |
1937 | ||
1938 | tid = TK_NOT; | |
1939 | ||
1940 | - buffer_copy_string(token, "(!)"); | |
1941 | + buffer_copy_string_len(token, CONST_STR_LEN("(!)")); | |
1942 | } | |
1943 | ||
1944 | break; | |
1945 | @@ -124,7 +124,7 @@ | |
1946 | ||
1947 | tid = TK_AND; | |
1948 | ||
1949 | - buffer_copy_string(token, "(&&)"); | |
1950 | + buffer_copy_string_len(token, CONST_STR_LEN("(&&)")); | |
1951 | } else { | |
1952 | log_error_write(srv, __FILE__, __LINE__, "sds", | |
1953 | "pos:", t->line_pos, | |
1954 | @@ -140,7 +140,7 @@ | |
1955 | ||
1956 | tid = TK_OR; | |
1957 | ||
1958 | - buffer_copy_string(token, "(||)"); | |
1959 | + buffer_copy_string_len(token, CONST_STR_LEN("(||)")); | |
1960 | } else { | |
1961 | log_error_write(srv, __FILE__, __LINE__, "sds", | |
1962 | "pos:", t->line_pos, | |
1963 | @@ -183,7 +183,7 @@ | |
1964 | ||
1965 | tid = TK_LPARAN; | |
1966 | ||
1967 | - buffer_copy_string(token, "("); | |
1968 | + buffer_copy_string_len(token, CONST_STR_LEN("(")); | |
1969 | break; | |
1970 | case ')': | |
1971 | t->offset++; | |
1972 | @@ -191,7 +191,7 @@ | |
1973 | ||
1974 | tid = TK_RPARAN; | |
1975 | ||
1976 | - buffer_copy_string(token, ")"); | |
1977 | + buffer_copy_string_len(token, CONST_STR_LEN(")")); | |
1978 | break; | |
1979 | case '$': | |
1980 | if (t->input[t->offset + 1] == '{') { | |
1981 | @@ -219,7 +219,7 @@ | |
1982 | } else if (NULL != (ds = (data_string *)array_get_element(p->ssi_vars, token->ptr))) { | |
1983 | buffer_copy_string_buffer(token, ds->value); | |
1984 | } else { | |
1985 | - buffer_copy_string(token, ""); | |
1986 | + buffer_copy_string_len(token, CONST_STR_LEN("")); | |
1987 | } | |
1988 | ||
1989 | t->offset += i; | |
1990 | Index: src/stat_cache.c | |
1991 | =================================================================== | |
1992 | --- src/stat_cache.c (.../tags/lighttpd-1.4.19) (revision 2303) | |
1993 | +++ src/stat_cache.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
1994 | @@ -445,7 +445,9 @@ | |
1995 | /* dir-check */ | |
1996 | if (srv->srvconf.stat_cache_engine == STAT_CACHE_ENGINE_FAM) { | |
1997 | if (0 != buffer_copy_dirname(sc->dir_name, name)) { | |
1998 | - SEGFAULT(); | |
1999 | + log_error_write(srv, __FILE__, __LINE__, "sb", | |
2000 | + "no '/' found in filename:", name); | |
2001 | + return HANDLER_ERROR; | |
2002 | } | |
2003 | ||
2004 | buffer_copy_string_buffer(sc->hash_key, sc->dir_name); | |
49b4da39 ER |
2005 | Index: src/response.c |
2006 | =================================================================== | |
54b68997 ER |
2007 | --- src/response.c (.../tags/lighttpd-1.4.19) (revision 2303) |
2008 | +++ src/response.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
2009 | @@ -35,21 +35,25 @@ | |
2010 | b = chunkqueue_get_prepend_buffer(con->write_queue); | |
2011 | ||
2012 | if (con->request.http_version == HTTP_VERSION_1_1) { | |
2013 | - BUFFER_COPY_STRING_CONST(b, "HTTP/1.1 "); | |
2014 | + buffer_copy_string_len(b, CONST_STR_LEN("HTTP/1.1 ")); | |
2015 | } else { | |
2016 | - BUFFER_COPY_STRING_CONST(b, "HTTP/1.0 "); | |
2017 | + buffer_copy_string_len(b, CONST_STR_LEN("HTTP/1.0 ")); | |
2018 | } | |
2019 | buffer_append_long(b, con->http_status); | |
2020 | - BUFFER_APPEND_STRING_CONST(b, " "); | |
2021 | + buffer_append_string_len(b, CONST_STR_LEN(" ")); | |
2022 | buffer_append_string(b, get_http_status_name(con->http_status)); | |
2023 | ||
2024 | if (con->request.http_version != HTTP_VERSION_1_1 || con->keep_alive == 0) { | |
2025 | - BUFFER_APPEND_STRING_CONST(b, "\r\nConnection: "); | |
2026 | - buffer_append_string(b, con->keep_alive ? "keep-alive" : "close"); | |
2027 | + buffer_append_string_len(b, CONST_STR_LEN("\r\nConnection: ")); | |
2028 | + if (con->keep_alive) { | |
2029 | + buffer_append_string_len(b, CONST_STR_LEN("keep-alive")); | |
2030 | + } else { | |
2031 | + buffer_append_string_len(b, CONST_STR_LEN("close")); | |
2032 | + } | |
2033 | } | |
2034 | ||
2035 | if (con->response.transfer_encoding & HTTP_TRANSFER_ENCODING_CHUNKED) { | |
2036 | - BUFFER_APPEND_STRING_CONST(b, "\r\nTransfer-Encoding: chunked"); | |
2037 | + buffer_append_string_len(b, CONST_STR_LEN("\r\nTransfer-Encoding: chunked")); | |
2038 | } | |
2039 | ||
2040 | ||
2041 | @@ -60,14 +64,15 @@ | |
2042 | ds = (data_string *)con->response.headers->data[i]; | |
2043 | ||
2044 | if (ds->value->used && ds->key->used && | |
2045 | - 0 != strncmp(ds->key->ptr, "X-LIGHTTPD-", sizeof("X-LIGHTTPD-") - 1) && | |
2046 | - 0 != strncmp(ds->key->ptr, "X-Sendfile", sizeof("X-Sendfile") - 1)) { | |
2047 | - if (buffer_is_equal_string(ds->key, CONST_STR_LEN("Date"))) have_date = 1; | |
2048 | - if (buffer_is_equal_string(ds->key, CONST_STR_LEN("Server"))) have_server = 1; | |
2049 | + 0 != strncasecmp(ds->key->ptr, CONST_STR_LEN("X-LIGHTTPD-")) && | |
2050 | + 0 != strcasecmp(ds->key->ptr, "X-Sendfile")) { | |
2051 | + if (0 == strcasecmp(ds->key->ptr, "Date")) have_date = 1; | |
2052 | + if (0 == strcasecmp(ds->key->ptr, "Server")) have_server = 1; | |
2053 | + if (0 == strcasecmp(ds->key->ptr, "Content-Encoding") && 304 == con->http_status) continue; | |
2054 | ||
2055 | - BUFFER_APPEND_STRING_CONST(b, "\r\n"); | |
2056 | + buffer_append_string_len(b, CONST_STR_LEN("\r\n")); | |
2057 | buffer_append_string_buffer(b, ds->key); | |
2058 | - BUFFER_APPEND_STRING_CONST(b, ": "); | |
2059 | + buffer_append_string_len(b, CONST_STR_LEN(": ")); | |
2060 | #if 0 | |
2061 | /** | |
2062 | * the value might contain newlines, encode them with at least one white-space | |
2063 | @@ -81,7 +86,7 @@ | |
2064 | ||
2065 | if (!have_date) { | |
2066 | /* HTTP/1.1 requires a Date: header */ | |
2067 | - BUFFER_APPEND_STRING_CONST(b, "\r\nDate: "); | |
2068 | + buffer_append_string_len(b, CONST_STR_LEN("\r\nDate: ")); | |
2069 | ||
2070 | /* cache the generated timestamp */ | |
2071 | if (srv->cur_ts != srv->last_generated_date_ts) { | |
2072 | @@ -100,14 +105,14 @@ | |
2073 | ||
49b4da39 ER |
2074 | if (!have_server) { |
2075 | if (buffer_is_empty(con->conf.server_tag)) { | |
54b68997 | 2076 | - BUFFER_APPEND_STRING_CONST(b, "\r\nServer: " PACKAGE_NAME "/" PACKAGE_VERSION); |
7db9a1b1 | 2077 | - } else { |
54b68997 ER |
2078 | - BUFFER_APPEND_STRING_CONST(b, "\r\nServer: "); |
2079 | + buffer_append_string_len(b, CONST_STR_LEN("\r\nServer: " PACKAGE_NAME "/" PACKAGE_VERSION)); | |
49b4da39 | 2080 | + } else if (con->conf.server_tag->used > 1) { |
54b68997 | 2081 | + buffer_append_string_len(b, CONST_STR_LEN("\r\nServer: ")); |
49b4da39 | 2082 | buffer_append_string_encoded(b, CONST_BUF_LEN(con->conf.server_tag), ENCODING_HTTP_HEADER); |
7db9a1b1 | 2083 | } |
54b68997 ER |
2084 | } |
2085 | ||
2086 | - BUFFER_APPEND_STRING_CONST(b, "\r\n\r\n"); | |
2087 | + buffer_append_string_len(b, CONST_STR_LEN("\r\n\r\n")); | |
2088 | ||
2089 | ||
2090 | con->bytes_header = b->used - 1; | |
2091 | @@ -152,7 +157,7 @@ | |
ad6a5263 ER |
2092 | * */ |
2093 | ||
2094 | config_cond_cache_reset(srv, con); | |
2095 | - config_setup_connection(srv, con); // Perhaps this could be removed at other places. | |
2096 | + config_setup_connection(srv, con); /* Perhaps this could be removed at other places. */ | |
2097 | ||
2098 | if (con->conf.log_condition_handling) { | |
2099 | log_error_write(srv, __FILE__, __LINE__, "s", "run condition"); | |
54b68997 ER |
2100 | @@ -181,7 +186,11 @@ |
2101 | * | |
2102 | */ | |
2103 | ||
2104 | - buffer_copy_string(con->uri.scheme, con->conf.is_ssl ? "https" : "http"); | |
2105 | + if (con->conf.is_ssl) { | |
2106 | + buffer_copy_string_len(con->uri.scheme, CONST_STR_LEN("https")); | |
2107 | + } else { | |
2108 | + buffer_copy_string_len(con->uri.scheme, CONST_STR_LEN("http")); | |
2109 | + } | |
2110 | buffer_copy_string_buffer(con->uri.authority, con->request.http_host); | |
2111 | buffer_to_lower(con->uri.authority); | |
2112 | ||
2113 | @@ -224,27 +233,6 @@ | |
2114 | } | |
2115 | ||
2116 | ||
2117 | - /** | |
2118 | - * | |
2119 | - * call plugins | |
2120 | - * | |
2121 | - * - based on the raw URL | |
2122 | - * | |
2123 | - */ | |
2124 | - | |
2125 | - switch(r = plugins_call_handle_uri_raw(srv, con)) { | |
2126 | - case HANDLER_GO_ON: | |
2127 | - break; | |
2128 | - case HANDLER_FINISHED: | |
2129 | - case HANDLER_COMEBACK: | |
2130 | - case HANDLER_WAIT_FOR_EVENT: | |
2131 | - case HANDLER_ERROR: | |
2132 | - return r; | |
2133 | - default: | |
2134 | - log_error_write(srv, __FILE__, __LINE__, "sd", "handle_uri_raw: unknown return value", r); | |
2135 | - break; | |
2136 | - } | |
2137 | - | |
2138 | /* build filename | |
2139 | * | |
2140 | * - decode url-encodings (e.g. %20 -> ' ') | |
2141 | @@ -252,7 +240,6 @@ | |
2142 | */ | |
2143 | ||
2144 | ||
2145 | - | |
2146 | if (con->request.http_method == HTTP_METHOD_OPTIONS && | |
2147 | con->uri.path_raw->ptr[0] == '*' && con->uri.path_raw->ptr[1] == '\0') { | |
2148 | /* OPTIONS * ... */ | |
2149 | @@ -268,10 +255,32 @@ | |
2150 | log_error_write(srv, __FILE__, __LINE__, "sb", "URI-path : ", con->uri.path); | |
2151 | } | |
2152 | ||
2153 | + | |
2154 | /** | |
2155 | * | |
2156 | * call plugins | |
2157 | * | |
2158 | + * - based on the raw URL | |
2159 | + * | |
2160 | + */ | |
2161 | + | |
2162 | + switch(r = plugins_call_handle_uri_raw(srv, con)) { | |
2163 | + case HANDLER_GO_ON: | |
2164 | + break; | |
2165 | + case HANDLER_FINISHED: | |
2166 | + case HANDLER_COMEBACK: | |
2167 | + case HANDLER_WAIT_FOR_EVENT: | |
2168 | + case HANDLER_ERROR: | |
2169 | + return r; | |
2170 | + default: | |
2171 | + log_error_write(srv, __FILE__, __LINE__, "sd", "handle_uri_raw: unknown return value", r); | |
2172 | + break; | |
2173 | + } | |
2174 | + | |
2175 | + /** | |
2176 | + * | |
2177 | + * call plugins | |
2178 | + * | |
2179 | * - based on the clean URL | |
2180 | * | |
2181 | */ | |
ad6a5263 ER |
2182 | Index: src/plugin.c |
2183 | =================================================================== | |
54b68997 ER |
2184 | --- src/plugin.c (.../tags/lighttpd-1.4.19) (revision 2303) |
2185 | +++ src/plugin.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
2186 | @@ -131,12 +131,12 @@ | |
2187 | ||
2188 | buffer_copy_string_buffer(srv->tmp_buf, srv->srvconf.modules_dir); | |
2189 | ||
2190 | - buffer_append_string(srv->tmp_buf, "/"); | |
2191 | + buffer_append_string_len(srv->tmp_buf, CONST_STR_LEN("/")); | |
2192 | buffer_append_string(srv->tmp_buf, modules); | |
2193 | #if defined(__WIN32) || defined(__CYGWIN__) | |
2194 | - buffer_append_string(srv->tmp_buf, ".dll"); | |
2195 | + buffer_append_string_len(srv->tmp_buf, CONST_STR_LEN(".dll")); | |
2196 | #else | |
2197 | - buffer_append_string(srv->tmp_buf, ".so"); | |
2198 | + buffer_append_string_len(srv->tmp_buf, CONST_STR_LEN(".so")); | |
2199 | #endif | |
2200 | ||
2201 | p = plugin_init(); | |
2202 | @@ -173,7 +173,7 @@ | |
2203 | #endif | |
2204 | buffer_reset(srv->tmp_buf); | |
2205 | buffer_copy_string(srv->tmp_buf, modules); | |
2206 | - buffer_append_string(srv->tmp_buf, "_plugin_init"); | |
2207 | + buffer_append_string_len(srv->tmp_buf, CONST_STR_LEN("_plugin_init")); | |
2208 | ||
2209 | #ifdef __WIN32 | |
2210 | init = GetProcAddress(p->lib, srv->tmp_buf->ptr); | |
ad6a5263 ER |
2211 | @@ -197,7 +197,7 @@ |
2212 | ||
2213 | #else | |
2214 | #if 1 | |
2215 | - init = (int (*)(plugin *))dlsym(p->lib, srv->tmp_buf->ptr); | |
2216 | + init = (int (*)(plugin *))(intptr_t)dlsym(p->lib, srv->tmp_buf->ptr); | |
2217 | #else | |
2218 | *(void **)(&init) = dlsym(p->lib, srv->tmp_buf->ptr); | |
2219 | #endif | |
2220 | Index: src/SConscript | |
2221 | =================================================================== | |
54b68997 ER |
2222 | --- src/SConscript (.../tags/lighttpd-1.4.19) (revision 2303) |
2223 | +++ src/SConscript (.../branches/lighttpd-1.4.x) (revision 2303) | |
ad6a5263 ER |
2224 | @@ -43,6 +43,7 @@ |
2225 | 'mod_cgi' : { 'src' : [ 'mod_cgi.c' ] }, | |
2226 | 'mod_fastcgi' : { 'src' : [ 'mod_fastcgi.c' ] }, | |
2227 | 'mod_scgi' : { 'src' : [ 'mod_scgi.c' ] }, | |
2228 | + 'mod_extforward' : { 'src' : [ 'mod_extforward.c' ] }, | |
2229 | 'mod_staticfile' : { 'src' : [ 'mod_staticfile.c' ] }, | |
2230 | 'mod_dirlisting' : { 'src' : [ 'mod_dirlisting.c' ], 'lib' : [ env['LIBPCRE'] ] }, | |
2231 | 'mod_indexfile' : { 'src' : [ 'mod_indexfile.c' ] }, | |
54b68997 ER |
2232 | Index: src/buffer.c |
2233 | =================================================================== | |
2234 | --- src/buffer.c (.../tags/lighttpd-1.4.19) (revision 2303) | |
2235 | +++ src/buffer.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
2236 | @@ -55,6 +55,8 @@ | |
2237 | free(b->ptr); | |
2238 | b->ptr = NULL; | |
2239 | b->size = 0; | |
2240 | + } else if (b->size) { | |
2241 | + b->ptr[0] = '\0'; | |
2242 | } | |
2243 | ||
2244 | b->used = 0; | |
2245 | @@ -626,6 +628,7 @@ | |
2246 | return 0; | |
2247 | } | |
2248 | ||
2249 | +/* everything except: ! ( ) * - . 0-9 A-Z _ a-z */ | |
2250 | const char encoded_chars_rel_uri_part[] = { | |
2251 | /* | |
2252 | 0 1 2 3 4 5 6 7 8 9 A B C D E F | |
2253 | @@ -633,11 +636,11 @@ | |
2254 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 00 - 0F control chars */ | |
2255 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 10 - 1F */ | |
2256 | 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, /* 20 - 2F space " # $ % & ' + , / */ | |
2257 | - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, /* 30 - 3F : ; = ? @ < > */ | |
2258 | - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 40 - 4F */ | |
2259 | - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 50 - 5F */ | |
2260 | - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 60 - 6F */ | |
2261 | - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, /* 70 - 7F DEL */ | |
2262 | + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, /* 30 - 3F : ; < = > ? */ | |
2263 | + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 40 - 4F @ */ | |
2264 | + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, /* 50 - 5F [ \ ] ^ */ | |
2265 | + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 60 - 6F ` */ | |
2266 | + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, /* 70 - 7F { | } ~ DEL */ | |
2267 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 80 - 8F */ | |
2268 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 90 - 9F */ | |
2269 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* A0 - AF */ | |
2270 | @@ -648,18 +651,19 @@ | |
2271 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* F0 - FF */ | |
2272 | }; | |
2273 | ||
2274 | +/* everything except: ! ( ) * - . / 0-9 A-Z _ a-z */ | |
2275 | const char encoded_chars_rel_uri[] = { | |
2276 | /* | |
2277 | 0 1 2 3 4 5 6 7 8 9 A B C D E F | |
2278 | */ | |
2279 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 00 - 0F control chars */ | |
2280 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 10 - 1F */ | |
2281 | - 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, /* 20 - 2F space " # $ % & ' + , / */ | |
2282 | - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, /* 30 - 3F : ; = ? @ < > */ | |
2283 | - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 40 - 4F */ | |
2284 | - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 50 - 5F */ | |
2285 | - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 60 - 6F */ | |
2286 | - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, /* 70 - 7F DEL */ | |
2287 | + 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, /* 20 - 2F space " # $ % & ' + , */ | |
2288 | + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, /* 30 - 3F : ; < = > ? */ | |
2289 | + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 40 - 4F @ */ | |
2290 | + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, /* 50 - 5F [ \ ] ^ */ | |
2291 | + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 60 - 6F ` */ | |
2292 | + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, /* 70 - 7F { | } ~ DEL */ | |
2293 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 80 - 8F */ | |
2294 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 90 - 9F */ | |
2295 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* A0 - AF */ | |
2296 | Index: src/mod_userdir.c | |
2297 | =================================================================== | |
2298 | --- src/mod_userdir.c (.../tags/lighttpd-1.4.19) (revision 2303) | |
2299 | +++ src/mod_userdir.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
2300 | @@ -262,6 +262,9 @@ | |
2301 | return HANDLER_GO_ON; | |
2302 | } | |
2303 | } | |
2304 | + if (con->conf.force_lowercase_filenames) { | |
2305 | + buffer_to_lower(p->username); | |
2306 | + } | |
2307 | ||
2308 | buffer_copy_string_buffer(p->temp_path, p->conf.basepath); | |
2309 | BUFFER_APPEND_SLASH(p->temp_path); | |
2310 | @@ -284,8 +287,24 @@ | |
2311 | } | |
2312 | } | |
2313 | ||
2314 | + /* the physical rel_path is basically the same as uri.path; | |
2315 | + * but it is converted to lowercase in case of force_lowercase_filenames and some special handling | |
2316 | + * for trailing '.', ' ' and '/' on windows | |
2317 | + * we assume that no docroot/physical handler changed this | |
2318 | + * (docroot should only set the docroot/server name, phyiscal should only change the phyiscal.path; | |
2319 | + * the exception mod_secure_download doesn't work with userdir anyway) | |
2320 | + */ | |
2321 | BUFFER_APPEND_SLASH(p->temp_path); | |
2322 | - buffer_append_string(p->temp_path, rel_url + 1); /* skip the / */ | |
2323 | + /* if no second '/' is found, we assume that it was stripped from the uri.path for the special handling | |
2324 | + * on windows. | |
2325 | + * we do not care about the trailing slash here on windows, as we already ensured it is a directory | |
2326 | + * | |
2327 | + * TODO: what to do with trailing dots in usernames on windows? they may result in the same directory | |
2328 | + * as a username without them. | |
2329 | + */ | |
2330 | + if (NULL != (rel_url = strchr(con->physical.rel_path->ptr + 2, '/'))) { | |
2331 | + buffer_append_string(p->temp_path, rel_url + 1); /* skip the / */ | |
2332 | + } | |
2333 | buffer_copy_string_buffer(con->physical.path, p->temp_path); | |
2334 | ||
2335 | buffer_reset(p->temp_path); | |
2336 | Index: src/mod_proxy.c | |
2337 | =================================================================== | |
2338 | --- src/mod_proxy.c (.../tags/lighttpd-1.4.19) (revision 2303) | |
2339 | +++ src/mod_proxy.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
2340 | @@ -432,10 +432,10 @@ | |
2341 | ||
2342 | /* request line */ | |
2343 | buffer_copy_string(b, get_http_method_name(con->request.http_method)); | |
2344 | - BUFFER_APPEND_STRING_CONST(b, " "); | |
2345 | + buffer_append_string_len(b, CONST_STR_LEN(" ")); | |
2346 | ||
2347 | buffer_append_string_buffer(b, con->request.uri); | |
2348 | - BUFFER_APPEND_STRING_CONST(b, " HTTP/1.0\r\n"); | |
2349 | + buffer_append_string_len(b, CONST_STR_LEN(" HTTP/1.0\r\n")); | |
2350 | ||
2351 | proxy_append_header(con, "X-Forwarded-For", (char *)inet_ntop_cache_get_ip(srv, &(con->dst_addr))); | |
2352 | /* http_host is NOT is just a pointer to a buffer | |
2353 | @@ -456,13 +456,13 @@ | |
2354 | if (buffer_is_equal_string(ds->key, CONST_STR_LEN("Connection"))) continue; | |
2355 | ||
2356 | buffer_append_string_buffer(b, ds->key); | |
2357 | - BUFFER_APPEND_STRING_CONST(b, ": "); | |
2358 | + buffer_append_string_len(b, CONST_STR_LEN(": ")); | |
2359 | buffer_append_string_buffer(b, ds->value); | |
2360 | - BUFFER_APPEND_STRING_CONST(b, "\r\n"); | |
2361 | + buffer_append_string_len(b, CONST_STR_LEN("\r\n")); | |
2362 | } | |
2363 | } | |
2364 | ||
2365 | - BUFFER_APPEND_STRING_CONST(b, "\r\n"); | |
2366 | + buffer_append_string_len(b, CONST_STR_LEN("\r\n")); | |
2367 | ||
2368 | hctx->wb->bytes_in += b->used - 1; | |
2369 | /* body */ | |
2370 | @@ -1060,6 +1060,8 @@ | |
2371 | data_array *extension = NULL; | |
2372 | size_t path_info_offset; | |
2373 | ||
2374 | + if (con->mode != DIRECT) return HANDLER_GO_ON; | |
2375 | + | |
2376 | /* Possibly, we processed already this request */ | |
2377 | if (con->file_started == 1) return HANDLER_GO_ON; | |
2378 | ||
2379 | @@ -1118,7 +1120,13 @@ | |
2380 | log_error_write(srv, __FILE__, __LINE__, "s", "proxy - ext found"); | |
2381 | } | |
2382 | ||
2383 | - switch(p->conf.balance) { | |
2384 | + if (extension->value->used == 1) { | |
2385 | + if ( ((data_proxy *)extension->value->data[0])->is_disabled ) { | |
2386 | + ndx = -1; | |
2387 | + } else { | |
2388 | + ndx = 0; | |
2389 | + } | |
2390 | + } else if (extension->value->used != 0) switch(p->conf.balance) { | |
2391 | case PROXY_BALANCE_HASH: | |
2392 | /* hash balancing */ | |
2393 | ||
2394 | @@ -1175,7 +1183,9 @@ | |
2395 | } | |
2396 | ||
2397 | break; | |
2398 | - case PROXY_BALANCE_RR: | |
2399 | + case PROXY_BALANCE_RR: { | |
2400 | + data_proxy *host; | |
2401 | + | |
2402 | /* round robin */ | |
2403 | if (p->conf.debug) { | |
2404 | log_error_write(srv, __FILE__, __LINE__, "s", | |
2405 | @@ -1185,31 +1195,32 @@ | |
2406 | /* just to be sure */ | |
2407 | assert(extension->value->used < INT_MAX); | |
2408 | ||
2409 | - for (k = 0, ndx = -1, max_usage = INT_MAX; k < extension->value->used; k++) { | |
2410 | - data_proxy *host = (data_proxy *)extension->value->data[k]; | |
2411 | + host = (data_proxy *)extension->value->data[0]; | |
2412 | ||
2413 | - if (host->is_disabled) continue; | |
2414 | + /* Use last_used_ndx from first host in list */ | |
2415 | + k = ndx = host->last_used_ndx; | |
2416 | + if (ndx < 0) ndx = 0; | |
2417 | ||
2418 | - /* first usable ndx */ | |
2419 | - if (max_usage == INT_MAX) { | |
2420 | - max_usage = k; | |
2421 | - } | |
2422 | + /* Search first active host after last_used_ndx */ | |
2423 | + while ( ndx < (int) extension->value->used | |
2424 | + && (host = (data_proxy *)extension->value->data[ndx])->is_disabled ) ndx++; | |
2425 | ||
2426 | - /* get next ndx */ | |
2427 | - if ((int)k > host->last_used_ndx) { | |
2428 | - ndx = k; | |
2429 | - host->last_used_ndx = k; | |
2430 | - | |
2431 | - break; | |
2432 | + if (ndx >= (int) extension->value->used) { | |
2433 | + /* didn't found a higher id, wrap to the start */ | |
2434 | + for (ndx = 0; ndx < (int) k; ndx++) { | |
2435 | + host = (data_proxy *)extension->value->data[ndx]; | |
2436 | + if (!host->is_disabled) break; | |
2437 | } | |
2438 | - } | |
2439 | ||
2440 | - /* didn't found a higher id, wrap to the start */ | |
2441 | - if (ndx == -1 && max_usage != INT_MAX) { | |
2442 | - ndx = max_usage; | |
2443 | + /* No active host found */ | |
2444 | + if (host->is_disabled) ndx = -1; | |
2445 | } | |
2446 | ||
2447 | + /* Save new index for next round */ | |
2448 | + ((data_proxy *)extension->value->data[0])->last_used_ndx = ndx; | |
2449 | + | |
2450 | break; | |
2451 | + } | |
2452 | default: | |
2453 | break; | |
2454 | } | |
49b4da39 | 2455 | Index: src/mod_extforward.c |
94d9baaf | 2456 | =================================================================== |
54b68997 ER |
2457 | --- src/mod_extforward.c (.../tags/lighttpd-1.4.19) (revision 2303) |
2458 | +++ src/mod_extforward.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
49b4da39 ER |
2459 | @@ -281,8 +281,9 @@ |
2460 | static const char *last_not_in_array(array *a, plugin_data *p) | |
2461 | { | |
2462 | array *forwarder = p->conf.forwarder; | |
2463 | + int i; | |
a34aaa25 | 2464 | |
49b4da39 ER |
2465 | - for (int i = a->used - 1; i >= 0; i--) { |
2466 | + for (i = a->used - 1; i >= 0; i--) { | |
2467 | data_string *ds = (data_string *)a->data[i]; | |
2468 | const char *ip = ds->value->ptr; | |
94d9baaf | 2469 | |
ad6a5263 ER |
2470 | Index: src/Makefile.am |
2471 | =================================================================== | |
54b68997 ER |
2472 | --- src/Makefile.am (.../tags/lighttpd-1.4.19) (revision 2303) |
2473 | +++ src/Makefile.am (.../branches/lighttpd-1.4.x) (revision 2303) | |
2474 | @@ -3,7 +3,7 @@ | |
2475 | noinst_PROGRAMS=proc_open lemon # simple-fcgi #graphic evalo bench ajp ssl error_test adserver gen-license | |
2476 | sbin_PROGRAMS=lighttpd lighttpd-angel | |
2477 | bin_PROGRAMS=spawn-fcgi | |
2478 | -LEMON=$(top_builddir)/src/lemon | |
2479 | +LEMON=$(top_builddir)/src/lemon$(EXEEXT) | |
2480 | ||
2481 | lemon_SOURCES=lemon.c | |
2482 | ||
2483 | @@ -15,21 +15,26 @@ | |
2484 | if CROSS_COMPILING | |
ad6a5263 ER |
2485 | configparser.c configparser.h: |
2486 | mod_ssi_exprparser.c mod_ssi_exprparser.h: | |
54b68997 ER |
2487 | + |
2488 | +.PHONY: parsers | |
2489 | +parsers: | |
ad6a5263 ER |
2490 | else |
2491 | -$(srcdir)/configparser.y: lemon | |
2492 | -$(srcdir)/mod_ssi_exprparser.y: lemon | |
2493 | - | |
2494 | -configparser.c configparser.h: $(srcdir)/configparser.y | |
54b68997 ER |
2495 | +configparser.h: configparser.c |
2496 | +configparser.c: $(srcdir)/configparser.y $(srcdir)/lempar.c lemon$(EXEEXT) | |
ad6a5263 ER |
2497 | rm -f configparser.h |
2498 | $(LEMON) -q $(srcdir)/configparser.y $(srcdir)/lempar.c | |
2499 | ||
2500 | -mod_ssi_exprparser.c mod_ssi_exprparser.h: $(srcdir)/mod_ssi_exprparser.y | |
54b68997 ER |
2501 | +mod_ssi_exprparser.h: mod_ssi_exprparser.c |
2502 | +mod_ssi_exprparser.c: $(srcdir)/mod_ssi_exprparser.y $(srcdir)/lempar.c lemon$(EXEEXT) | |
ad6a5263 ER |
2503 | rm -f mod_ssi_exprparser.h |
2504 | $(LEMON) -q $(srcdir)/mod_ssi_exprparser.y $(srcdir)/lempar.c | |
54b68997 ER |
2505 | + |
2506 | +.PHONY: parsers | |
2507 | +parsers: configparser.c mod_ssi_exprparser.c | |
ad6a5263 ER |
2508 | endif |
2509 | ||
2510 | -$(srcdir)/configfile.c: configparser.h | |
2511 | -$(srcdir)/mod_ssi_expr.c: mod_ssi_exprparser.h | |
54b68997 ER |
2512 | +BUILT_SOURCES = parsers |
2513 | +MAINTAINERCLEANFILES = configparser.c configparser.h mod_ssi_exprparser.c mod_ssi_exprparser.h | |
ad6a5263 ER |
2514 | |
2515 | common_src=buffer.c log.c \ | |
2516 | keyvalue.c chunk.c \ | |
54b68997 ER |
2517 | Index: src/mod_expire.c |
2518 | =================================================================== | |
2519 | --- src/mod_expire.c (.../tags/lighttpd-1.4.19) (revision 2303) | |
2520 | +++ src/mod_expire.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
2521 | @@ -339,7 +339,7 @@ | |
2522 | response_header_overwrite(srv, con, CONST_STR_LEN("Expires"), CONST_BUF_LEN(p->expire_tstmp)); | |
2523 | ||
2524 | /* HTTP/1.1 */ | |
2525 | - buffer_copy_string(p->expire_tstmp, "max-age="); | |
2526 | + buffer_copy_string_len(p->expire_tstmp, CONST_STR_LEN("max-age=")); | |
2527 | buffer_append_long(p->expire_tstmp, ts); | |
2528 | ||
2529 | response_header_overwrite(srv, con, CONST_STR_LEN("Cache-Control"), CONST_BUF_LEN(p->expire_tstmp)); | |
a34aaa25 ER |
2530 | Index: src/network_openssl.c |
2531 | =================================================================== | |
54b68997 ER |
2532 | --- src/network_openssl.c (.../tags/lighttpd-1.4.19) (revision 2303) |
2533 | +++ src/network_openssl.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
49b4da39 ER |
2534 | @@ -85,6 +85,7 @@ |
2535 | * | |
2536 | */ | |
a34aaa25 | 2537 | |
49b4da39 ER |
2538 | + ERR_clear_error(); |
2539 | if ((r = SSL_write(ssl, offset, toSend)) <= 0) { | |
2540 | unsigned long err; | |
36650255 | 2541 | |
49b4da39 | 2542 | @@ -187,6 +188,7 @@ |
36650255 | 2543 | |
49b4da39 | 2544 | close(ifd); |
36650255 | 2545 | |
49b4da39 ER |
2546 | + ERR_clear_error(); |
2547 | if ((r = SSL_write(ssl, s, toSend)) <= 0) { | |
2548 | unsigned long err; | |
36650255 | 2549 | |
54b68997 ER |
2550 | Index: src/network_freebsd_sendfile.c |
2551 | =================================================================== | |
2552 | --- src/network_freebsd_sendfile.c (.../tags/lighttpd-1.4.19) (revision 2303) | |
2553 | +++ src/network_freebsd_sendfile.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
2554 | @@ -166,6 +166,7 @@ | |
2555 | if (-1 == sendfile(c->file.fd, fd, offset, toSend, NULL, &r, 0)) { | |
2556 | switch(errno) { | |
2557 | case EAGAIN: | |
2558 | + case EINTR: | |
2559 | break; | |
2560 | case ENOTCONN: | |
2561 | return -2; | |
2562 | @@ -175,7 +176,7 @@ | |
2563 | } | |
2564 | } | |
2565 | ||
2566 | - if (r == 0) { | |
2567 | + if (r == 0 && (errno != EAGAIN && errno != EINTR)) { | |
2568 | int oerrno = errno; | |
2569 | /* We got an event to write but we wrote nothing | |
2570 | * | |
ad6a5263 ER |
2571 | Index: src/mod_redirect.c |
2572 | =================================================================== | |
54b68997 ER |
2573 | --- src/mod_redirect.c (.../tags/lighttpd-1.4.19) (revision 2303) |
2574 | +++ src/mod_redirect.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
ad6a5263 ER |
2575 | @@ -215,8 +215,7 @@ |
2576 | ||
2577 | start = 0; end = pattern_len; | |
2578 | for (k = 0; k < pattern_len; k++) { | |
2579 | - if ((pattern[k] == '$' || pattern[k] == '%') && | |
2580 | - isdigit((unsigned char)pattern[k + 1])) { | |
2581 | + if (pattern[k] == '$' || pattern[k] == '%') { | |
2582 | /* got one */ | |
2583 | ||
2584 | size_t num = pattern[k + 1] - '0'; | |
2585 | @@ -225,7 +224,10 @@ | |
2586 | ||
2587 | buffer_append_string_len(p->location, pattern + start, end - start); | |
2588 | ||
2589 | - if (pattern[k] == '$') { | |
2590 | + if (!isdigit((unsigned char)pattern[k + 1])) { | |
2591 | + /* enable escape: "%%" => "%", "%a" => "%a", "$$" => "$" */ | |
2592 | + buffer_append_string_len(p->location, pattern+k, pattern[k] == pattern[k+1] ? 1 : 2); | |
2593 | + } else if (pattern[k] == '$') { | |
2594 | /* n is always > 0 */ | |
2595 | if (num < (size_t)n) { | |
2596 | buffer_append_string(p->location, list[num]); | |
54b68997 ER |
2597 | @@ -251,6 +253,7 @@ |
2598 | response_header_insert(srv, con, CONST_STR_LEN("Location"), CONST_BUF_LEN(p->location)); | |
2599 | ||
2600 | con->http_status = 301; | |
2601 | + con->mode = DIRECT; | |
2602 | con->file_finished = 1; | |
2603 | ||
2604 | return HANDLER_FINISHED; | |
2605 | Index: src/http_auth.c | |
2606 | =================================================================== | |
2607 | --- src/http_auth.c (.../tags/lighttpd-1.4.19) (revision 2303) | |
2608 | +++ src/http_auth.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
2609 | @@ -697,7 +697,7 @@ | |
2610 | } | |
2611 | } else if (p->conf.auth_backend == AUTH_BACKEND_LDAP) { | |
2612 | #ifdef USE_LDAP | |
2613 | - LDAP *ldap; | |
2614 | + LDAP *ldap = NULL; | |
2615 | LDAPMessage *lm, *first; | |
2616 | char *dn; | |
2617 | int ret; | |
2618 | @@ -742,39 +742,56 @@ | |
2619 | buffer_append_string_buffer(p->ldap_filter, username); | |
2620 | buffer_append_string_buffer(p->ldap_filter, p->conf.ldap_filter_post); | |
2621 | ||
2622 | - | |
2623 | /* 2. */ | |
2624 | if (p->conf.ldap == NULL || | |
2625 | LDAP_SUCCESS != (ret = ldap_search_s(p->conf.ldap, p->conf.auth_ldap_basedn->ptr, LDAP_SCOPE_SUBTREE, p->ldap_filter->ptr, attrs, 0, &lm))) { | |
2626 | - if (auth_ldap_init(srv, &p->conf) != HANDLER_GO_ON) | |
2627 | - return -1; | |
2628 | - if (LDAP_SUCCESS != (ret = ldap_search_s(p->conf.ldap, p->conf.auth_ldap_basedn->ptr, LDAP_SCOPE_SUBTREE, p->ldap_filter->ptr, attrs, 0, &lm))) { | |
2629 | + /* try again if ldap was only temporary down */ | |
2630 | + if (p->conf.ldap == NULL || ret != LDAP_SERVER_DOWN || LDAP_SUCCESS != (ret = ldap_search_s(p->conf.ldap, p->conf.auth_ldap_basedn->ptr, LDAP_SCOPE_SUBTREE, p->ldap_filter->ptr, attrs, 0, &lm))) { | |
2631 | + if (auth_ldap_init(srv, &p->conf) != HANDLER_GO_ON) | |
2632 | + return -1; | |
2633 | ||
2634 | - log_error_write(srv, __FILE__, __LINE__, "sssb", | |
2635 | - "ldap:", ldap_err2string(ret), "filter:", p->ldap_filter); | |
2636 | - | |
2637 | - return -1; | |
2638 | + ldap = p->conf.ldap; /* save temporary ldap connection (TODO: redo ldap) */ | |
2639 | + if (LDAP_SUCCESS != (ret = ldap_search_s(p->conf.ldap, p->conf.auth_ldap_basedn->ptr, LDAP_SCOPE_SUBTREE, p->ldap_filter->ptr, attrs, 0, &lm))) { | |
2640 | + log_error_write(srv, __FILE__, __LINE__, "sssb", | |
2641 | + "ldap:", ldap_err2string(ret), "filter:", p->ldap_filter); | |
2642 | + /* destroy temporary ldap connection (TODO: redo ldap) */ | |
2643 | + ldap_unbind_s(ldap); | |
2644 | + return -1; | |
2645 | + } | |
2646 | } | |
2647 | } | |
2648 | ||
2649 | if (NULL == (first = ldap_first_entry(p->conf.ldap, lm))) { | |
2650 | - log_error_write(srv, __FILE__, __LINE__, "s", "ldap ..."); | |
2651 | + /* No matching entry is not an error */ | |
2652 | + /* log_error_write(srv, __FILE__, __LINE__, "s", "ldap ..."); */ | |
2653 | ||
2654 | ldap_msgfree(lm); | |
2655 | ||
2656 | + /* destroy temporary ldap connection (TODO: redo ldap) */ | |
2657 | + if (NULL != ldap) { | |
2658 | + ldap_unbind_s(ldap); | |
2659 | + } | |
2660 | return -1; | |
2661 | } | |
2662 | ||
2663 | if (NULL == (dn = ldap_get_dn(p->conf.ldap, first))) { | |
2664 | - log_error_write(srv, __FILE__, __LINE__, "s", "ldap ..."); | |
2665 | + log_error_write(srv, __FILE__, __LINE__, "s", "ldap: ldap_get_dn failed"); | |
2666 | ||
2667 | ldap_msgfree(lm); | |
2668 | ||
2669 | + /* destroy temporary ldap connection (TODO: redo ldap) */ | |
2670 | + if (NULL != ldap) { | |
2671 | + ldap_unbind_s(ldap); | |
2672 | + } | |
2673 | return -1; | |
2674 | } | |
2675 | ||
2676 | ldap_msgfree(lm); | |
2677 | ||
2678 | + /* destroy temporary ldap connection (TODO: redo ldap) */ | |
2679 | + if (NULL != ldap) { | |
2680 | + ldap_unbind_s(ldap); | |
2681 | + } | |
2682 | ||
2683 | /* 3. */ | |
2684 | if (NULL == (ldap = ldap_init(p->conf.auth_ldap_hostname->ptr, LDAP_PORT))) { | |
2685 | Index: src/mod_usertrack.c | |
2686 | =================================================================== | |
2687 | --- src/mod_usertrack.c (.../tags/lighttpd-1.4.19) (revision 2303) | |
2688 | +++ src/mod_usertrack.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
2689 | @@ -103,7 +103,7 @@ | |
2690 | } | |
2691 | ||
2692 | if (buffer_is_empty(s->cookie_name)) { | |
2693 | - buffer_copy_string(s->cookie_name, "TRACKID"); | |
2694 | + buffer_copy_string_len(s->cookie_name, CONST_STR_LEN("TRACKID")); | |
2695 | } else { | |
2696 | size_t j; | |
2697 | for (j = 0; j < s->cookie_name->used - 1; j++) { | |
2698 | @@ -214,9 +214,9 @@ | |
2699 | if (NULL == (ds = (data_string *)array_get_unused_element(con->response.headers, TYPE_STRING))) { | |
2700 | ds = data_response_init(); | |
2701 | } | |
2702 | - buffer_copy_string(ds->key, "Set-Cookie"); | |
2703 | + buffer_copy_string_len(ds->key, CONST_STR_LEN("Set-Cookie")); | |
2704 | buffer_copy_string_buffer(ds->value, p->conf.cookie_name); | |
2705 | - buffer_append_string(ds->value, "="); | |
2706 | + buffer_append_string_len(ds->value, CONST_STR_LEN("=")); | |
2707 | ||
2708 | ||
2709 | /* taken from mod_auth.c */ | |
2710 | @@ -235,16 +235,16 @@ | |
2711 | MD5_Final(h, &Md5Ctx); | |
2712 | ||
2713 | buffer_append_string_encoded(ds->value, (char *)h, 16, ENCODING_HEX); | |
2714 | - buffer_append_string(ds->value, "; Path=/"); | |
2715 | - buffer_append_string(ds->value, "; Version=1"); | |
2716 | + buffer_append_string_len(ds->value, CONST_STR_LEN("; Path=/")); | |
2717 | + buffer_append_string_len(ds->value, CONST_STR_LEN("; Version=1")); | |
2718 | ||
2719 | if (!buffer_is_empty(p->conf.cookie_domain)) { | |
2720 | - buffer_append_string(ds->value, "; Domain="); | |
2721 | + buffer_append_string_len(ds->value, CONST_STR_LEN("; Domain=")); | |
2722 | buffer_append_string_encoded(ds->value, CONST_BUF_LEN(p->conf.cookie_domain), ENCODING_REL_URI); | |
2723 | } | |
2724 | ||
2725 | if (p->conf.cookie_max_age) { | |
2726 | - buffer_append_string(ds->value, "; max-age="); | |
2727 | + buffer_append_string_len(ds->value, CONST_STR_LEN("; max-age=")); | |
2728 | buffer_append_long(ds->value, p->conf.cookie_max_age); | |
2729 | } | |
2730 | ||
ad6a5263 ER |
2731 | Index: src/mod_webdav.c |
2732 | =================================================================== | |
54b68997 ER |
2733 | --- src/mod_webdav.c (.../tags/lighttpd-1.4.19) (revision 2303) |
2734 | +++ src/mod_webdav.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
2735 | @@ -485,23 +485,23 @@ | |
2736 | UNUSED(con); | |
2737 | ||
2738 | if (value) { | |
2739 | - buffer_append_string(b,"<"); | |
2740 | + buffer_append_string_len(b,CONST_STR_LEN("<")); | |
2741 | buffer_append_string(b, prop_name); | |
2742 | - buffer_append_string(b, " xmlns=\""); | |
2743 | + buffer_append_string_len(b, CONST_STR_LEN(" xmlns=\"")); | |
2744 | buffer_append_string(b, prop_ns); | |
2745 | - buffer_append_string(b, "\">"); | |
2746 | + buffer_append_string_len(b, CONST_STR_LEN("\">")); | |
2747 | ||
2748 | buffer_append_string(b, value); | |
2749 | ||
2750 | - buffer_append_string(b,"</"); | |
2751 | + buffer_append_string_len(b,CONST_STR_LEN("</")); | |
2752 | buffer_append_string(b, prop_name); | |
2753 | - buffer_append_string(b, ">"); | |
2754 | + buffer_append_string_len(b, CONST_STR_LEN(">")); | |
2755 | } else { | |
2756 | - buffer_append_string(b,"<"); | |
2757 | + buffer_append_string_len(b,CONST_STR_LEN("<")); | |
2758 | buffer_append_string(b, prop_name); | |
2759 | - buffer_append_string(b, " xmlns=\""); | |
2760 | + buffer_append_string_len(b, CONST_STR_LEN(" xmlns=\"")); | |
2761 | buffer_append_string(b, prop_ns); | |
2762 | - buffer_append_string(b, "\"/>"); | |
2763 | + buffer_append_string_len(b, CONST_STR_LEN("\"/>")); | |
2764 | } | |
2765 | ||
2766 | return 0; | |
2767 | @@ -511,24 +511,24 @@ | |
2768 | static int webdav_gen_response_status_tag(server *srv, connection *con, physical *dst, int status, buffer *b) { | |
2769 | UNUSED(srv); | |
2770 | ||
2771 | - buffer_append_string(b,"<D:response xmlns:ns0=\"urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/\">\n"); | |
2772 | + buffer_append_string_len(b,CONST_STR_LEN("<D:response xmlns:ns0=\"urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/\">\n")); | |
2773 | ||
2774 | - buffer_append_string(b,"<D:href>\n"); | |
2775 | + buffer_append_string_len(b,CONST_STR_LEN("<D:href>\n")); | |
2776 | buffer_append_string_buffer(b, dst->rel_path); | |
2777 | - buffer_append_string(b,"</D:href>\n"); | |
2778 | - buffer_append_string(b,"<D:status>\n"); | |
2779 | + buffer_append_string_len(b,CONST_STR_LEN("</D:href>\n")); | |
2780 | + buffer_append_string_len(b,CONST_STR_LEN("<D:status>\n")); | |
2781 | ||
2782 | if (con->request.http_version == HTTP_VERSION_1_1) { | |
2783 | - BUFFER_COPY_STRING_CONST(b, "HTTP/1.1 "); | |
2784 | + buffer_copy_string_len(b, CONST_STR_LEN("HTTP/1.1 ")); | |
2785 | } else { | |
2786 | - BUFFER_COPY_STRING_CONST(b, "HTTP/1.0 "); | |
2787 | + buffer_copy_string_len(b, CONST_STR_LEN("HTTP/1.0 ")); | |
2788 | } | |
2789 | buffer_append_long(b, status); | |
2790 | - BUFFER_APPEND_STRING_CONST(b, " "); | |
2791 | + buffer_append_string_len(b, CONST_STR_LEN(" ")); | |
2792 | buffer_append_string(b, get_http_status_name(status)); | |
2793 | ||
2794 | - buffer_append_string(b,"</D:status>\n"); | |
2795 | - buffer_append_string(b,"</D:response>\n"); | |
2796 | + buffer_append_string_len(b,CONST_STR_LEN("</D:status>\n")); | |
2797 | + buffer_append_string_len(b,CONST_STR_LEN("</D:response>\n")); | |
2798 | ||
2799 | return 0; | |
2800 | } | |
ad6a5263 ER |
2801 | @@ -570,6 +570,8 @@ |
2802 | /* */ | |
2803 | } | |
2804 | } | |
2805 | +#else | |
2806 | + UNUSED(p); | |
2807 | #endif | |
2808 | } | |
2809 | ||
2810 | @@ -730,6 +732,8 @@ | |
2811 | } | |
2812 | } | |
2813 | } | |
2814 | +#else | |
2815 | + UNUSED(p); | |
2816 | #endif | |
2817 | return status; | |
2818 | } | |
54b68997 ER |
2819 | @@ -840,12 +844,12 @@ |
2820 | ||
2821 | if (0 == strcmp(prop_name, "resourcetype")) { | |
2822 | if (S_ISDIR(sce->st.st_mode)) { | |
2823 | - buffer_append_string(b, "<D:resourcetype><D:collection/></D:resourcetype>"); | |
2824 | + buffer_append_string_len(b, CONST_STR_LEN("<D:resourcetype><D:collection/></D:resourcetype>")); | |
2825 | found = 1; | |
2826 | } | |
2827 | } else if (0 == strcmp(prop_name, "getcontenttype")) { | |
2828 | if (S_ISDIR(sce->st.st_mode)) { | |
2829 | - buffer_append_string(b, "<D:getcontenttype>httpd/unix-directory</D:getcontenttype>"); | |
2830 | + buffer_append_string_len(b, CONST_STR_LEN("<D:getcontenttype>httpd/unix-directory</D:getcontenttype>")); | |
2831 | found = 1; | |
2832 | } else if(S_ISREG(sce->st.st_mode)) { | |
2833 | for (k = 0; k < con->conf.mimetypes->used; k++) { | |
2834 | @@ -854,9 +858,9 @@ | |
2835 | if (ds->key->used == 0) continue; | |
2836 | ||
2837 | if (buffer_is_equal_right_len(dst->path, ds->key, ds->key->used - 1)) { | |
2838 | - buffer_append_string(b,"<D:getcontenttype>"); | |
2839 | + buffer_append_string_len(b,CONST_STR_LEN("<D:getcontenttype>")); | |
2840 | buffer_append_string_buffer(b, ds->value); | |
2841 | - buffer_append_string(b, "</D:getcontenttype>"); | |
2842 | + buffer_append_string_len(b, CONST_STR_LEN("</D:getcontenttype>")); | |
2843 | found = 1; | |
2844 | ||
2845 | break; | |
2846 | @@ -864,26 +868,26 @@ | |
2847 | } | |
2848 | } | |
2849 | } else if (0 == strcmp(prop_name, "creationdate")) { | |
2850 | - buffer_append_string(b, "<D:creationdate ns0:dt=\"dateTime.tz\">"); | |
2851 | + buffer_append_string_len(b, CONST_STR_LEN("<D:creationdate ns0:dt=\"dateTime.tz\">")); | |
2852 | strftime(ctime_buf, sizeof(ctime_buf), "%Y-%m-%dT%H:%M:%SZ", gmtime(&(sce->st.st_ctime))); | |
2853 | buffer_append_string(b, ctime_buf); | |
2854 | - buffer_append_string(b, "</D:creationdate>"); | |
2855 | + buffer_append_string_len(b, CONST_STR_LEN("</D:creationdate>")); | |
2856 | found = 1; | |
2857 | } else if (0 == strcmp(prop_name, "getlastmodified")) { | |
2858 | - buffer_append_string(b,"<D:getlastmodified ns0:dt=\"dateTime.rfc1123\">"); | |
2859 | + buffer_append_string_len(b,CONST_STR_LEN("<D:getlastmodified ns0:dt=\"dateTime.rfc1123\">")); | |
2860 | strftime(mtime_buf, sizeof(mtime_buf), "%a, %d %b %Y %H:%M:%S GMT", gmtime(&(sce->st.st_mtime))); | |
2861 | buffer_append_string(b, mtime_buf); | |
2862 | - buffer_append_string(b, "</D:getlastmodified>"); | |
2863 | + buffer_append_string_len(b, CONST_STR_LEN("</D:getlastmodified>")); | |
2864 | found = 1; | |
2865 | } else if (0 == strcmp(prop_name, "getcontentlength")) { | |
2866 | - buffer_append_string(b,"<D:getcontentlength>"); | |
2867 | + buffer_append_string_len(b,CONST_STR_LEN("<D:getcontentlength>")); | |
2868 | buffer_append_off_t(b, sce->st.st_size); | |
2869 | - buffer_append_string(b, "</D:getcontentlength>"); | |
2870 | + buffer_append_string_len(b, CONST_STR_LEN("</D:getcontentlength>")); | |
2871 | found = 1; | |
2872 | } else if (0 == strcmp(prop_name, "getcontentlanguage")) { | |
2873 | - buffer_append_string(b,"<D:getcontentlanguage>"); | |
2874 | - buffer_append_string(b, "en"); | |
2875 | - buffer_append_string(b, "</D:getcontentlanguage>"); | |
2876 | + buffer_append_string_len(b,CONST_STR_LEN("<D:getcontentlanguage>")); | |
2877 | + buffer_append_string_len(b, CONST_STR_LEN("en")); | |
2878 | + buffer_append_string_len(b, CONST_STR_LEN("</D:getcontentlanguage>")); | |
2879 | found = 1; | |
2880 | } | |
2881 | } | |
2882 | @@ -1103,44 +1107,44 @@ | |
2883 | ||
2884 | b = chunkqueue_get_append_buffer(con->write_queue); | |
2885 | ||
2886 | - buffer_copy_string(b, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"); | |
2887 | + buffer_copy_string_len(b, CONST_STR_LEN("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")); | |
2888 | ||
2889 | - buffer_append_string(b,"<D:prop xmlns:D=\"DAV:\" xmlns:ns0=\"urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/\">\n"); | |
2890 | - buffer_append_string(b,"<D:lockdiscovery>\n"); | |
2891 | - buffer_append_string(b,"<D:activelock>\n"); | |
2892 | + buffer_append_string_len(b,CONST_STR_LEN("<D:prop xmlns:D=\"DAV:\" xmlns:ns0=\"urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/\">\n")); | |
2893 | + buffer_append_string_len(b,CONST_STR_LEN("<D:lockdiscovery>\n")); | |
2894 | + buffer_append_string_len(b,CONST_STR_LEN("<D:activelock>\n")); | |
2895 | ||
2896 | - buffer_append_string(b,"<D:lockscope>"); | |
2897 | - buffer_append_string(b,"<D:"); | |
2898 | + buffer_append_string_len(b,CONST_STR_LEN("<D:lockscope>")); | |
2899 | + buffer_append_string_len(b,CONST_STR_LEN("<D:")); | |
2900 | buffer_append_string(b, lockscope); | |
2901 | - buffer_append_string(b, "/>"); | |
2902 | - buffer_append_string(b,"</D:lockscope>\n"); | |
2903 | + buffer_append_string_len(b, CONST_STR_LEN("/>")); | |
2904 | + buffer_append_string_len(b,CONST_STR_LEN("</D:lockscope>\n")); | |
2905 | ||
2906 | - buffer_append_string(b,"<D:locktype>"); | |
2907 | - buffer_append_string(b,"<D:"); | |
2908 | + buffer_append_string_len(b,CONST_STR_LEN("<D:locktype>")); | |
2909 | + buffer_append_string_len(b,CONST_STR_LEN("<D:")); | |
2910 | buffer_append_string(b, locktype); | |
2911 | - buffer_append_string(b, "/>"); | |
2912 | - buffer_append_string(b,"</D:locktype>\n"); | |
2913 | + buffer_append_string_len(b, CONST_STR_LEN("/>")); | |
2914 | + buffer_append_string_len(b,CONST_STR_LEN("</D:locktype>\n")); | |
2915 | ||
2916 | - buffer_append_string(b,"<D:depth>"); | |
2917 | + buffer_append_string_len(b,CONST_STR_LEN("<D:depth>")); | |
2918 | buffer_append_string(b, depth == 0 ? "0" : "infinity"); | |
2919 | - buffer_append_string(b,"</D:depth>\n"); | |
2920 | + buffer_append_string_len(b,CONST_STR_LEN("</D:depth>\n")); | |
2921 | ||
2922 | - buffer_append_string(b,"<D:timeout>"); | |
2923 | - buffer_append_string(b, "Second-600"); | |
2924 | - buffer_append_string(b,"</D:timeout>\n"); | |
2925 | + buffer_append_string_len(b,CONST_STR_LEN("<D:timeout>")); | |
2926 | + buffer_append_string_len(b, CONST_STR_LEN("Second-600")); | |
2927 | + buffer_append_string_len(b,CONST_STR_LEN("</D:timeout>\n")); | |
2928 | ||
2929 | - buffer_append_string(b,"<D:owner>"); | |
2930 | - buffer_append_string(b,"</D:owner>\n"); | |
2931 | + buffer_append_string_len(b,CONST_STR_LEN("<D:owner>")); | |
2932 | + buffer_append_string_len(b,CONST_STR_LEN("</D:owner>\n")); | |
2933 | ||
2934 | - buffer_append_string(b,"<D:locktoken>"); | |
2935 | - buffer_append_string(b, "<D:href>"); | |
2936 | + buffer_append_string_len(b,CONST_STR_LEN("<D:locktoken>")); | |
2937 | + buffer_append_string_len(b, CONST_STR_LEN("<D:href>")); | |
2938 | buffer_append_string_buffer(b, locktoken); | |
2939 | - buffer_append_string(b, "</D:href>"); | |
2940 | - buffer_append_string(b,"</D:locktoken>\n"); | |
2941 | + buffer_append_string_len(b, CONST_STR_LEN("</D:href>")); | |
2942 | + buffer_append_string_len(b,CONST_STR_LEN("</D:locktoken>\n")); | |
2943 | ||
2944 | - buffer_append_string(b,"</D:activelock>\n"); | |
2945 | - buffer_append_string(b,"</D:lockdiscovery>\n"); | |
2946 | - buffer_append_string(b,"</D:prop>\n"); | |
2947 | + buffer_append_string_len(b,CONST_STR_LEN("</D:activelock>\n")); | |
2948 | + buffer_append_string_len(b,CONST_STR_LEN("</D:lockdiscovery>\n")); | |
2949 | + buffer_append_string_len(b,CONST_STR_LEN("</D:prop>\n")); | |
2950 | ||
2951 | return 0; | |
2952 | } | |
ad6a5263 ER |
2953 | @@ -1154,6 +1158,7 @@ |
2954 | int has_lock = 1; | |
2955 | ||
2956 | #ifdef USE_LOCKS | |
2957 | + UNUSED(srv); | |
2958 | data_string *ds; | |
2959 | ||
2960 | /** | |
2961 | @@ -1192,6 +1197,11 @@ | |
2962 | has_lock = 0; | |
2963 | } | |
2964 | } | |
2965 | +#else | |
2966 | + UNUSED(srv); | |
2967 | + UNUSED(con); | |
2968 | + UNUSED(p); | |
2969 | + UNUSED(uri); | |
2970 | #endif | |
2971 | ||
2972 | return has_lock; | |
54b68997 ER |
2973 | @@ -1334,9 +1344,9 @@ |
2974 | ||
2975 | b = chunkqueue_get_append_buffer(con->write_queue); | |
2976 | ||
2977 | - buffer_copy_string(b, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"); | |
2978 | + buffer_copy_string_len(b, CONST_STR_LEN("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")); | |
2979 | ||
2980 | - buffer_append_string(b,"<D:multistatus xmlns:D=\"DAV:\" xmlns:ns0=\"urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/\">\n"); | |
2981 | + buffer_append_string_len(b,CONST_STR_LEN("<D:multistatus xmlns:D=\"DAV:\" xmlns:ns0=\"urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/\">\n")); | |
2982 | ||
2983 | /* allprop */ | |
2984 | ||
2985 | @@ -1348,40 +1358,40 @@ | |
2986 | /* Depth: 0 */ | |
2987 | webdav_get_props(srv, con, p, &(con->physical), req_props, prop_200, prop_404); | |
2988 | ||
2989 | - buffer_append_string(b,"<D:response>\n"); | |
2990 | - buffer_append_string(b,"<D:href>"); | |
2991 | + buffer_append_string_len(b,CONST_STR_LEN("<D:response>\n")); | |
2992 | + buffer_append_string_len(b,CONST_STR_LEN("<D:href>")); | |
2993 | buffer_append_string_buffer(b, con->uri.scheme); | |
2994 | - buffer_append_string(b,"://"); | |
2995 | + buffer_append_string_len(b,CONST_STR_LEN("://")); | |
2996 | buffer_append_string_buffer(b, con->uri.authority); | |
2997 | buffer_append_string_encoded(b, CONST_BUF_LEN(con->uri.path), ENCODING_REL_URI); | |
2998 | - buffer_append_string(b,"</D:href>\n"); | |
2999 | + buffer_append_string_len(b,CONST_STR_LEN("</D:href>\n")); | |
3000 | ||
3001 | if (!buffer_is_empty(prop_200)) { | |
3002 | - buffer_append_string(b,"<D:propstat>\n"); | |
3003 | - buffer_append_string(b,"<D:prop>\n"); | |
3004 | + buffer_append_string_len(b,CONST_STR_LEN("<D:propstat>\n")); | |
3005 | + buffer_append_string_len(b,CONST_STR_LEN("<D:prop>\n")); | |
3006 | ||
3007 | buffer_append_string_buffer(b, prop_200); | |
3008 | ||
3009 | - buffer_append_string(b,"</D:prop>\n"); | |
3010 | + buffer_append_string_len(b,CONST_STR_LEN("</D:prop>\n")); | |
3011 | ||
3012 | - buffer_append_string(b,"<D:status>HTTP/1.1 200 OK</D:status>\n"); | |
3013 | + buffer_append_string_len(b,CONST_STR_LEN("<D:status>HTTP/1.1 200 OK</D:status>\n")); | |
3014 | ||
3015 | - buffer_append_string(b,"</D:propstat>\n"); | |
3016 | + buffer_append_string_len(b,CONST_STR_LEN("</D:propstat>\n")); | |
3017 | } | |
3018 | if (!buffer_is_empty(prop_404)) { | |
3019 | - buffer_append_string(b,"<D:propstat>\n"); | |
3020 | - buffer_append_string(b,"<D:prop>\n"); | |
3021 | + buffer_append_string_len(b,CONST_STR_LEN("<D:propstat>\n")); | |
3022 | + buffer_append_string_len(b,CONST_STR_LEN("<D:prop>\n")); | |
3023 | ||
3024 | buffer_append_string_buffer(b, prop_404); | |
3025 | ||
3026 | - buffer_append_string(b,"</D:prop>\n"); | |
3027 | + buffer_append_string_len(b,CONST_STR_LEN("</D:prop>\n")); | |
3028 | ||
3029 | - buffer_append_string(b,"<D:status>HTTP/1.1 404 Not Found</D:status>\n"); | |
3030 | + buffer_append_string_len(b,CONST_STR_LEN("<D:status>HTTP/1.1 404 Not Found</D:status>\n")); | |
3031 | ||
3032 | - buffer_append_string(b,"</D:propstat>\n"); | |
3033 | + buffer_append_string_len(b,CONST_STR_LEN("</D:propstat>\n")); | |
3034 | } | |
3035 | ||
3036 | - buffer_append_string(b,"</D:response>\n"); | |
3037 | + buffer_append_string_len(b,CONST_STR_LEN("</D:response>\n")); | |
3038 | ||
3039 | break; | |
3040 | case 1: | |
3041 | @@ -1417,40 +1427,40 @@ | |
3042 | ||
3043 | webdav_get_props(srv, con, p, &d, req_props, prop_200, prop_404); | |
3044 | ||
3045 | - buffer_append_string(b,"<D:response>\n"); | |
3046 | - buffer_append_string(b,"<D:href>"); | |
3047 | + buffer_append_string_len(b,CONST_STR_LEN("<D:response>\n")); | |
3048 | + buffer_append_string_len(b,CONST_STR_LEN("<D:href>")); | |
3049 | buffer_append_string_buffer(b, con->uri.scheme); | |
3050 | - buffer_append_string(b,"://"); | |
3051 | + buffer_append_string_len(b,CONST_STR_LEN("://")); | |
3052 | buffer_append_string_buffer(b, con->uri.authority); | |
3053 | buffer_append_string_encoded(b, CONST_BUF_LEN(d.rel_path), ENCODING_REL_URI); | |
3054 | - buffer_append_string(b,"</D:href>\n"); | |
3055 | + buffer_append_string_len(b,CONST_STR_LEN("</D:href>\n")); | |
3056 | ||
3057 | if (!buffer_is_empty(prop_200)) { | |
3058 | - buffer_append_string(b,"<D:propstat>\n"); | |
3059 | - buffer_append_string(b,"<D:prop>\n"); | |
3060 | + buffer_append_string_len(b,CONST_STR_LEN("<D:propstat>\n")); | |
3061 | + buffer_append_string_len(b,CONST_STR_LEN("<D:prop>\n")); | |
3062 | ||
3063 | buffer_append_string_buffer(b, prop_200); | |
3064 | ||
3065 | - buffer_append_string(b,"</D:prop>\n"); | |
3066 | + buffer_append_string_len(b,CONST_STR_LEN("</D:prop>\n")); | |
3067 | ||
3068 | - buffer_append_string(b,"<D:status>HTTP/1.1 200 OK</D:status>\n"); | |
3069 | + buffer_append_string_len(b,CONST_STR_LEN("<D:status>HTTP/1.1 200 OK</D:status>\n")); | |
3070 | ||
3071 | - buffer_append_string(b,"</D:propstat>\n"); | |
3072 | + buffer_append_string_len(b,CONST_STR_LEN("</D:propstat>\n")); | |
3073 | } | |
3074 | if (!buffer_is_empty(prop_404)) { | |
3075 | - buffer_append_string(b,"<D:propstat>\n"); | |
3076 | - buffer_append_string(b,"<D:prop>\n"); | |
3077 | + buffer_append_string_len(b,CONST_STR_LEN("<D:propstat>\n")); | |
3078 | + buffer_append_string_len(b,CONST_STR_LEN("<D:prop>\n")); | |
3079 | ||
3080 | buffer_append_string_buffer(b, prop_404); | |
3081 | ||
3082 | - buffer_append_string(b,"</D:prop>\n"); | |
3083 | + buffer_append_string_len(b,CONST_STR_LEN("</D:prop>\n")); | |
3084 | ||
3085 | - buffer_append_string(b,"<D:status>HTTP/1.1 404 Not Found</D:status>\n"); | |
3086 | + buffer_append_string_len(b,CONST_STR_LEN("<D:status>HTTP/1.1 404 Not Found</D:status>\n")); | |
3087 | ||
3088 | - buffer_append_string(b,"</D:propstat>\n"); | |
3089 | + buffer_append_string_len(b,CONST_STR_LEN("</D:propstat>\n")); | |
3090 | } | |
3091 | ||
3092 | - buffer_append_string(b,"</D:response>\n"); | |
3093 | + buffer_append_string_len(b,CONST_STR_LEN("</D:response>\n")); | |
3094 | } | |
3095 | closedir(dir); | |
3096 | buffer_free(d.path); | |
3097 | @@ -1473,7 +1483,7 @@ | |
3098 | buffer_free(prop_200); | |
3099 | buffer_free(prop_404); | |
3100 | ||
3101 | - buffer_append_string(b,"</D:multistatus>\n"); | |
3102 | + buffer_append_string_len(b,CONST_STR_LEN("</D:multistatus>\n")); | |
3103 | ||
3104 | if (p->conf.log_xml) { | |
3105 | log_error_write(srv, __FILE__, __LINE__, "sb", "XML-response-body:", b); | |
3106 | @@ -1548,13 +1558,13 @@ | |
3107 | ||
3108 | b = chunkqueue_get_append_buffer(con->write_queue); | |
3109 | ||
3110 | - buffer_copy_string(b, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"); | |
3111 | + buffer_copy_string_len(b, CONST_STR_LEN("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")); | |
3112 | ||
3113 | - buffer_append_string(b,"<D:multistatus xmlns:D=\"DAV:\">\n"); | |
3114 | + buffer_append_string_len(b,CONST_STR_LEN("<D:multistatus xmlns:D=\"DAV:\">\n")); | |
3115 | ||
3116 | buffer_append_string_buffer(b, multi_status_resp); | |
3117 | ||
3118 | - buffer_append_string(b,"</D:multistatus>\n"); | |
3119 | + buffer_append_string_len(b,CONST_STR_LEN("</D:multistatus>\n")); | |
3120 | ||
3121 | if (p->conf.log_xml) { | |
3122 | log_error_write(srv, __FILE__, __LINE__, "sb", "XML-response-body:", b); | |
3123 | @@ -2286,7 +2296,7 @@ | |
3124 | uuid_generate(id); | |
3125 | uuid_unparse(id, uuid); | |
3126 | ||
3127 | - buffer_copy_string(p->tmp_buf, "opaquelocktoken:"); | |
3128 | + buffer_copy_string_len(p->tmp_buf, CONST_STR_LEN("opaquelocktoken:")); | |
3129 | buffer_append_string(p->tmp_buf, uuid); | |
3130 | ||
3131 | /* "CREATE TABLE locks (" | |
3132 | Index: src/configparser.y | |
3133 | =================================================================== | |
3134 | --- src/configparser.y (.../tags/lighttpd-1.4.19) (revision 2303) | |
3135 | +++ src/configparser.y (.../branches/lighttpd-1.4.x) (revision 2303) | |
3136 | @@ -21,6 +21,10 @@ | |
3137 | dc->parent = ctx->current; | |
3138 | array_insert_unique(dc->parent->childs, (data_unset *)dc); | |
3139 | } | |
3140 | + if (ctx->configs_stack->used > 0 && ctx->current->context_ndx == 0) { | |
3141 | + fprintf(stderr, "Cannot use conditionals inside a global { ... } block\n"); | |
3142 | + exit(-1); | |
3143 | + } | |
3144 | array_insert_unique(ctx->configs_stack, (data_unset *)ctx->current); | |
3145 | ctx->current = dc; | |
3146 | } | |
3147 | Index: src/mod_status.c | |
3148 | =================================================================== | |
3149 | --- src/mod_status.c (.../tags/lighttpd-1.4.19) (revision 2303) | |
3150 | +++ src/mod_status.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
3151 | @@ -143,24 +143,24 @@ | |
3152 | ||
3153 | ||
3154 | static int mod_status_row_append(buffer *b, const char *key, const char *value) { | |
3155 | - BUFFER_APPEND_STRING_CONST(b, " <tr>\n"); | |
3156 | - BUFFER_APPEND_STRING_CONST(b, " <td><b>"); | |
3157 | + buffer_append_string_len(b, CONST_STR_LEN(" <tr>\n")); | |
3158 | + buffer_append_string_len(b, CONST_STR_LEN(" <td><b>")); | |
3159 | buffer_append_string(b, key); | |
3160 | - BUFFER_APPEND_STRING_CONST(b, "</b></td>\n"); | |
3161 | - BUFFER_APPEND_STRING_CONST(b, " <td>"); | |
3162 | + buffer_append_string_len(b, CONST_STR_LEN("</b></td>\n")); | |
3163 | + buffer_append_string_len(b, CONST_STR_LEN(" <td>")); | |
3164 | buffer_append_string(b, value); | |
3165 | - BUFFER_APPEND_STRING_CONST(b, "</td>\n"); | |
3166 | - BUFFER_APPEND_STRING_CONST(b, " </tr>\n"); | |
3167 | + buffer_append_string_len(b, CONST_STR_LEN("</td>\n")); | |
3168 | + buffer_append_string_len(b, CONST_STR_LEN(" </tr>\n")); | |
3169 | ||
3170 | return 0; | |
3171 | } | |
3172 | ||
3173 | static int mod_status_header_append(buffer *b, const char *key) { | |
3174 | - BUFFER_APPEND_STRING_CONST(b, " <tr>\n"); | |
3175 | - BUFFER_APPEND_STRING_CONST(b, " <th colspan=\"2\">"); | |
3176 | + buffer_append_string_len(b, CONST_STR_LEN(" <tr>\n")); | |
3177 | + buffer_append_string_len(b, CONST_STR_LEN(" <th colspan=\"2\">")); | |
3178 | buffer_append_string(b, key); | |
3179 | - BUFFER_APPEND_STRING_CONST(b, "</th>\n"); | |
3180 | - BUFFER_APPEND_STRING_CONST(b, " </tr>\n"); | |
3181 | + buffer_append_string_len(b, CONST_STR_LEN("</th>\n")); | |
3182 | + buffer_append_string_len(b, CONST_STR_LEN(" </tr>\n")); | |
3183 | ||
3184 | return 0; | |
3185 | } | |
3186 | @@ -169,13 +169,13 @@ | |
3187 | plugin_data *p = p_d; | |
3188 | ||
3189 | if (p->conf.sort) { | |
3190 | - BUFFER_APPEND_STRING_CONST(b, "<th class=\"status\"><a href=\"#\" class=\"sortheader\" onclick=\"resort(this);return false;\">"); | |
3191 | + buffer_append_string_len(b, CONST_STR_LEN("<th class=\"status\"><a href=\"#\" class=\"sortheader\" onclick=\"resort(this);return false;\">")); | |
3192 | buffer_append_string(b, key); | |
3193 | - BUFFER_APPEND_STRING_CONST(b, "<span class=\"sortarrow\">:</span></a></th>\n"); | |
3194 | + buffer_append_string_len(b, CONST_STR_LEN("<span class=\"sortarrow\">:</span></a></th>\n")); | |
3195 | } else { | |
3196 | - BUFFER_APPEND_STRING_CONST(b, "<th class=\"status\">"); | |
3197 | + buffer_append_string_len(b, CONST_STR_LEN("<th class=\"status\">")); | |
3198 | buffer_append_string(b, key); | |
3199 | - BUFFER_APPEND_STRING_CONST(b, "</th>\n"); | |
3200 | + buffer_append_string_len(b, CONST_STR_LEN("</th>\n")); | |
3201 | } | |
3202 | ||
3203 | return 0; | |
3204 | @@ -209,15 +209,14 @@ | |
3205 | ||
3206 | b = chunkqueue_get_append_buffer(con->write_queue); | |
3207 | ||
3208 | - BUFFER_COPY_STRING_CONST(b, | |
3209 | + buffer_copy_string_len(b, CONST_STR_LEN( | |
3210 | "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n" | |
3211 | "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n" | |
3212 | " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n" | |
3213 | "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n" | |
3214 | " <head>\n" | |
3215 | - " <title>Status</title>\n"); | |
3216 | + " <title>Status</title>\n" | |
3217 | ||
3218 | - BUFFER_APPEND_STRING_CONST(b, | |
3219 | " <style type=\"text/css\">\n" | |
3220 | " table.status { border: black solid thin; }\n" | |
3221 | " td { white-space: nowrap; }\n" | |
3222 | @@ -226,16 +225,15 @@ | |
3223 | " th.status { background-color: black; color: white; font-weight: bold; }\n" | |
3224 | " a.sortheader { background-color: black; color: white; font-weight: bold; text-decoration: none; display: block; }\n" | |
3225 | " span.sortarrow { color: white; text-decoration: none; }\n" | |
3226 | - " </style>\n"); | |
3227 | + " </style>\n")); | |
3228 | ||
3229 | if (p->conf.sort) { | |
3230 | - BUFFER_APPEND_STRING_CONST(b, | |
3231 | + buffer_append_string_len(b, CONST_STR_LEN( | |
3232 | "<script type=\"text/javascript\">\n" | |
3233 | "// <!--\n" | |
3234 | "var sort_column;\n" | |
3235 | - "var prev_span = null;\n"); | |
3236 | + "var prev_span = null;\n" | |
3237 | ||
3238 | - BUFFER_APPEND_STRING_CONST(b, | |
3239 | "function get_inner_text(el) {\n" | |
3240 | " if((typeof el == 'string')||(typeof el == 'undefined'))\n" | |
3241 | " return el;\n" | |
3242 | @@ -251,9 +249,8 @@ | |
3243 | " }\n" | |
3244 | " }\n" | |
3245 | " return str;\n" | |
3246 | - "}\n"); | |
3247 | + "}\n" | |
3248 | ||
3249 | - BUFFER_APPEND_STRING_CONST(b, | |
3250 | "function sortfn(a,b) {\n" | |
3251 | " var at = get_inner_text(a.cells[sort_column]);\n" | |
3252 | " var bt = get_inner_text(b.cells[sort_column]);\n" | |
3253 | @@ -266,9 +263,8 @@ | |
3254 | " else if (aa<bb) return -1;\n" | |
3255 | " else return 1;\n" | |
3256 | " }\n" | |
3257 | - "}\n"); | |
3258 | + "}\n" | |
3259 | ||
3260 | - BUFFER_APPEND_STRING_CONST(b, | |
3261 | "function resort(lnk) {\n" | |
3262 | " var span = lnk.childNodes[1];\n" | |
3263 | " var table = lnk.parentNode.parentNode.parentNode.parentNode;\n" | |
3264 | @@ -276,9 +272,8 @@ | |
3265 | " for (j=1;j<table.rows.length;j++)\n" | |
3266 | " rows[j-1] = table.rows[j];\n" | |
3267 | " sort_column = lnk.parentNode.cellIndex;\n" | |
3268 | - " rows.sort(sortfn);\n"); | |
3269 | + " rows.sort(sortfn);\n" | |
3270 | ||
3271 | - BUFFER_APPEND_STRING_CONST(b, | |
3272 | " if (prev_span != null) prev_span.innerHTML = '';\n" | |
3273 | " if (span.getAttribute('sortdir')=='down') {\n" | |
3274 | " span.innerHTML = '↑';\n" | |
3275 | @@ -293,25 +288,25 @@ | |
3276 | " prev_span = span;\n" | |
3277 | "}\n" | |
3278 | "// -->\n" | |
3279 | - "</script>\n"); | |
3280 | + "</script>\n")); | |
3281 | } | |
3282 | ||
3283 | - BUFFER_APPEND_STRING_CONST(b, | |
3284 | + buffer_append_string_len(b, CONST_STR_LEN( | |
3285 | " </head>\n" | |
3286 | - " <body>\n"); | |
3287 | + " <body>\n")); | |
3288 | ||
3289 | ||
3290 | ||
3291 | /* connection listing */ | |
3292 | - BUFFER_APPEND_STRING_CONST(b, "<h1>Server-Status</h1>"); | |
3293 | + buffer_append_string_len(b, CONST_STR_LEN("<h1>Server-Status</h1>")); | |
3294 | ||
3295 | - BUFFER_APPEND_STRING_CONST(b, "<table summary=\"status\" class=\"status\">"); | |
3296 | - BUFFER_APPEND_STRING_CONST(b, "<tr><td>Hostname</td><td class=\"string\">"); | |
3297 | + buffer_append_string_len(b, CONST_STR_LEN("<table summary=\"status\" class=\"status\">")); | |
3298 | + buffer_append_string_len(b, CONST_STR_LEN("<tr><td>Hostname</td><td class=\"string\">")); | |
3299 | buffer_append_string_buffer(b, con->uri.authority); | |
3300 | - BUFFER_APPEND_STRING_CONST(b, " ("); | |
3301 | + buffer_append_string_len(b, CONST_STR_LEN(" (")); | |
3302 | buffer_append_string_buffer(b, con->server_name); | |
3303 | - BUFFER_APPEND_STRING_CONST(b, ")</td></tr>\n"); | |
3304 | - BUFFER_APPEND_STRING_CONST(b, "<tr><td>Uptime</td><td class=\"string\">"); | |
3305 | + buffer_append_string_len(b, CONST_STR_LEN(")</td></tr>\n")); | |
3306 | + buffer_append_string_len(b, CONST_STR_LEN("<tr><td>Uptime</td><td class=\"string\">")); | |
3307 | ||
3308 | ts = srv->cur_ts - srv->startup_ts; | |
3309 | ||
3310 | @@ -328,98 +323,98 @@ | |
3311 | ||
3312 | if (days) { | |
3313 | buffer_append_long(b, days); | |
3314 | - BUFFER_APPEND_STRING_CONST(b, " days "); | |
3315 | + buffer_append_string_len(b, CONST_STR_LEN(" days ")); | |
3316 | } | |
3317 | ||
3318 | if (hours) { | |
3319 | buffer_append_long(b, hours); | |
3320 | - BUFFER_APPEND_STRING_CONST(b, " hours "); | |
3321 | + buffer_append_string_len(b, CONST_STR_LEN(" hours ")); | |
3322 | } | |
3323 | ||
3324 | if (mins) { | |
3325 | buffer_append_long(b, mins); | |
3326 | - BUFFER_APPEND_STRING_CONST(b, " min "); | |
3327 | + buffer_append_string_len(b, CONST_STR_LEN(" min ")); | |
3328 | } | |
3329 | ||
3330 | buffer_append_long(b, seconds); | |
3331 | - BUFFER_APPEND_STRING_CONST(b, " s"); | |
3332 | + buffer_append_string_len(b, CONST_STR_LEN(" s")); | |
3333 | ||
3334 | - BUFFER_APPEND_STRING_CONST(b, "</td></tr>\n"); | |
3335 | - BUFFER_APPEND_STRING_CONST(b, "<tr><td>Started at</td><td class=\"string\">"); | |
3336 | + buffer_append_string_len(b, CONST_STR_LEN("</td></tr>\n")); | |
3337 | + buffer_append_string_len(b, CONST_STR_LEN("<tr><td>Started at</td><td class=\"string\">")); | |
3338 | ||
3339 | ts = srv->startup_ts; | |
3340 | ||
3341 | strftime(buf, sizeof(buf) - 1, "%Y-%m-%d %H:%M:%S", localtime(&ts)); | |
3342 | buffer_append_string(b, buf); | |
3343 | - BUFFER_APPEND_STRING_CONST(b, "</td></tr>\n"); | |
3344 | + buffer_append_string_len(b, CONST_STR_LEN("</td></tr>\n")); | |
3345 | ||
3346 | ||
3347 | - BUFFER_APPEND_STRING_CONST(b, "<tr><th colspan=\"2\">absolute (since start)</th></tr>\n"); | |
3348 | + buffer_append_string_len(b, CONST_STR_LEN("<tr><th colspan=\"2\">absolute (since start)</th></tr>\n")); | |
3349 | ||
3350 | - BUFFER_APPEND_STRING_CONST(b, "<tr><td>Requests</td><td class=\"string\">"); | |
3351 | + buffer_append_string_len(b, CONST_STR_LEN("<tr><td>Requests</td><td class=\"string\">")); | |
3352 | avg = p->abs_requests; | |
3353 | ||
3354 | mod_status_get_multiplier(&avg, &multiplier, 1000); | |
3355 | ||
3356 | buffer_append_long(b, avg); | |
3357 | - BUFFER_APPEND_STRING_CONST(b, " "); | |
3358 | + buffer_append_string_len(b, CONST_STR_LEN(" ")); | |
3359 | if (multiplier) buffer_append_string_len(b, &multiplier, 1); | |
3360 | - BUFFER_APPEND_STRING_CONST(b, "req</td></tr>\n"); | |
3361 | + buffer_append_string_len(b, CONST_STR_LEN("req</td></tr>\n")); | |
3362 | ||
3363 | - BUFFER_APPEND_STRING_CONST(b, "<tr><td>Traffic</td><td class=\"string\">"); | |
3364 | + buffer_append_string_len(b, CONST_STR_LEN("<tr><td>Traffic</td><td class=\"string\">")); | |
3365 | avg = p->abs_traffic_out; | |
3366 | ||
3367 | mod_status_get_multiplier(&avg, &multiplier, 1024); | |
3368 | ||
3369 | sprintf(buf, "%.2f", avg); | |
3370 | buffer_append_string(b, buf); | |
3371 | - BUFFER_APPEND_STRING_CONST(b, " "); | |
3372 | + buffer_append_string_len(b, CONST_STR_LEN(" ")); | |
3373 | if (multiplier) buffer_append_string_len(b, &multiplier, 1); | |
3374 | - BUFFER_APPEND_STRING_CONST(b, "byte</td></tr>\n"); | |
3375 | + buffer_append_string_len(b, CONST_STR_LEN("byte</td></tr>\n")); | |
3376 | ||
3377 | ||
3378 | ||
3379 | - BUFFER_APPEND_STRING_CONST(b, "<tr><th colspan=\"2\">average (since start)</th></tr>\n"); | |
3380 | + buffer_append_string_len(b, CONST_STR_LEN("<tr><th colspan=\"2\">average (since start)</th></tr>\n")); | |
3381 | ||
3382 | - BUFFER_APPEND_STRING_CONST(b, "<tr><td>Requests</td><td class=\"string\">"); | |
3383 | + buffer_append_string_len(b, CONST_STR_LEN("<tr><td>Requests</td><td class=\"string\">")); | |
3384 | avg = p->abs_requests / (srv->cur_ts - srv->startup_ts); | |
3385 | ||
3386 | mod_status_get_multiplier(&avg, &multiplier, 1000); | |
3387 | ||
3388 | buffer_append_long(b, avg); | |
3389 | - BUFFER_APPEND_STRING_CONST(b, " "); | |
3390 | + buffer_append_string_len(b, CONST_STR_LEN(" ")); | |
3391 | if (multiplier) buffer_append_string_len(b, &multiplier, 1); | |
3392 | - BUFFER_APPEND_STRING_CONST(b, "req/s</td></tr>\n"); | |
3393 | + buffer_append_string_len(b, CONST_STR_LEN("req/s</td></tr>\n")); | |
3394 | ||
3395 | - BUFFER_APPEND_STRING_CONST(b, "<tr><td>Traffic</td><td class=\"string\">"); | |
3396 | + buffer_append_string_len(b, CONST_STR_LEN("<tr><td>Traffic</td><td class=\"string\">")); | |
3397 | avg = p->abs_traffic_out / (srv->cur_ts - srv->startup_ts); | |
3398 | ||
3399 | mod_status_get_multiplier(&avg, &multiplier, 1024); | |
3400 | ||
3401 | sprintf(buf, "%.2f", avg); | |
3402 | buffer_append_string(b, buf); | |
3403 | - BUFFER_APPEND_STRING_CONST(b, " "); | |
3404 | + buffer_append_string_len(b, CONST_STR_LEN(" ")); | |
3405 | if (multiplier) buffer_append_string_len(b, &multiplier, 1); | |
3406 | - BUFFER_APPEND_STRING_CONST(b, "byte/s</td></tr>\n"); | |
3407 | + buffer_append_string_len(b, CONST_STR_LEN("byte/s</td></tr>\n")); | |
3408 | ||
3409 | ||
3410 | ||
3411 | - BUFFER_APPEND_STRING_CONST(b, "<tr><th colspan=\"2\">average (5s sliding average)</th></tr>\n"); | |
3412 | + buffer_append_string_len(b, CONST_STR_LEN("<tr><th colspan=\"2\">average (5s sliding average)</th></tr>\n")); | |
3413 | for (j = 0, avg = 0; j < 5; j++) { | |
3414 | avg += p->mod_5s_requests[j]; | |
3415 | } | |
3416 | ||
3417 | avg /= 5; | |
3418 | ||
3419 | - BUFFER_APPEND_STRING_CONST(b, "<tr><td>Requests</td><td class=\"string\">"); | |
3420 | + buffer_append_string_len(b, CONST_STR_LEN("<tr><td>Requests</td><td class=\"string\">")); | |
3421 | ||
3422 | mod_status_get_multiplier(&avg, &multiplier, 1000); | |
3423 | ||
3424 | buffer_append_long(b, avg); | |
3425 | - BUFFER_APPEND_STRING_CONST(b, " "); | |
3426 | + buffer_append_string_len(b, CONST_STR_LEN(" ")); | |
3427 | if (multiplier) buffer_append_string_len(b, &multiplier, 1); | |
3428 | ||
3429 | - BUFFER_APPEND_STRING_CONST(b, "req/s</td></tr>\n"); | |
3430 | + buffer_append_string_len(b, CONST_STR_LEN("req/s</td></tr>\n")); | |
3431 | ||
3432 | for (j = 0, avg = 0; j < 5; j++) { | |
3433 | avg += p->mod_5s_traffic_out[j]; | |
3434 | @@ -427,28 +422,29 @@ | |
3435 | ||
3436 | avg /= 5; | |
3437 | ||
3438 | - BUFFER_APPEND_STRING_CONST(b, "<tr><td>Traffic</td><td class=\"string\">"); | |
3439 | + buffer_append_string_len(b, CONST_STR_LEN("<tr><td>Traffic</td><td class=\"string\">")); | |
3440 | ||
3441 | mod_status_get_multiplier(&avg, &multiplier, 1024); | |
3442 | ||
3443 | sprintf(buf, "%.2f", avg); | |
3444 | buffer_append_string(b, buf); | |
3445 | - BUFFER_APPEND_STRING_CONST(b, " "); | |
3446 | + buffer_append_string_len(b, CONST_STR_LEN(" ")); | |
3447 | if (multiplier) buffer_append_string_len(b, &multiplier, 1); | |
3448 | - BUFFER_APPEND_STRING_CONST(b, "byte/s</td></tr>\n"); | |
3449 | + buffer_append_string_len(b, CONST_STR_LEN("byte/s</td></tr>\n")); | |
3450 | ||
3451 | - BUFFER_APPEND_STRING_CONST(b, "</table>\n"); | |
3452 | + buffer_append_string_len(b, CONST_STR_LEN("</table>\n")); | |
3453 | ||
3454 | ||
3455 | - BUFFER_APPEND_STRING_CONST(b, "<hr />\n<pre><b>legend</b>\n"); | |
3456 | - BUFFER_APPEND_STRING_CONST(b, ". = connect, C = close, E = hard error\n"); | |
3457 | - BUFFER_APPEND_STRING_CONST(b, "r = read, R = read-POST, W = write, h = handle-request\n"); | |
3458 | - BUFFER_APPEND_STRING_CONST(b, "q = request-start, Q = request-end\n"); | |
3459 | - BUFFER_APPEND_STRING_CONST(b, "s = response-start, S = response-end\n"); | |
3460 | + buffer_append_string_len(b, CONST_STR_LEN( | |
3461 | + "<hr />\n<pre><b>legend</b>\n" | |
3462 | + ". = connect, C = close, E = hard error\n" | |
3463 | + "r = read, R = read-POST, W = write, h = handle-request\n" | |
3464 | + "q = request-start, Q = request-end\n" | |
3465 | + "s = response-start, S = response-end\n")); | |
3466 | ||
3467 | - BUFFER_APPEND_STRING_CONST(b, "<b>"); | |
3468 | + buffer_append_string_len(b, CONST_STR_LEN("<b>")); | |
3469 | buffer_append_long(b, srv->conns->used); | |
3470 | - BUFFER_APPEND_STRING_CONST(b, " connections</b>\n"); | |
3471 | + buffer_append_string_len(b, CONST_STR_LEN(" connections</b>\n")); | |
3472 | ||
3473 | for (j = 0; j < srv->conns->used; j++) { | |
3474 | connection *c = srv->conns->ptr[j]; | |
3475 | @@ -457,14 +453,14 @@ | |
3476 | buffer_append_string_len(b, state, 1); | |
3477 | ||
3478 | if (((j + 1) % 50) == 0) { | |
3479 | - BUFFER_APPEND_STRING_CONST(b, "\n"); | |
3480 | + buffer_append_string_len(b, CONST_STR_LEN("\n")); | |
3481 | } | |
3482 | } | |
3483 | ||
3484 | - BUFFER_APPEND_STRING_CONST(b, "\n</pre><hr />\n<h2>Connections</h2>\n"); | |
3485 | + buffer_append_string_len(b, CONST_STR_LEN("\n</pre><hr />\n<h2>Connections</h2>\n")); | |
3486 | ||
3487 | - BUFFER_APPEND_STRING_CONST(b, "<table summary=\"status\" class=\"status\">\n"); | |
3488 | - BUFFER_APPEND_STRING_CONST(b, "<tr>"); | |
3489 | + buffer_append_string_len(b, CONST_STR_LEN("<table summary=\"status\" class=\"status\">\n")); | |
3490 | + buffer_append_string_len(b, CONST_STR_LEN("<tr>")); | |
3491 | mod_status_header_append_sort(b, p_d, "Client IP"); | |
3492 | mod_status_header_append_sort(b, p_d, "Read"); | |
3493 | mod_status_header_append_sort(b, p_d, "Written"); | |
3494 | @@ -473,40 +469,40 @@ | |
3495 | mod_status_header_append_sort(b, p_d, "Host"); | |
3496 | mod_status_header_append_sort(b, p_d, "URI"); | |
3497 | mod_status_header_append_sort(b, p_d, "File"); | |
3498 | - BUFFER_APPEND_STRING_CONST(b, "</tr>\n"); | |
3499 | + buffer_append_string_len(b, CONST_STR_LEN("</tr>\n")); | |
3500 | ||
3501 | for (j = 0; j < srv->conns->used; j++) { | |
3502 | connection *c = srv->conns->ptr[j]; | |
3503 | ||
3504 | - BUFFER_APPEND_STRING_CONST(b, "<tr><td class=\"string\">"); | |
3505 | + buffer_append_string_len(b, CONST_STR_LEN("<tr><td class=\"string\">")); | |
3506 | ||
3507 | buffer_append_string(b, inet_ntop_cache_get_ip(srv, &(c->dst_addr))); | |
3508 | ||
3509 | - BUFFER_APPEND_STRING_CONST(b, "</td><td class=\"int\">"); | |
3510 | + buffer_append_string_len(b, CONST_STR_LEN("</td><td class=\"int\">")); | |
3511 | ||
3512 | if (con->request.content_length) { | |
3513 | buffer_append_long(b, c->request_content_queue->bytes_in); | |
3514 | - BUFFER_APPEND_STRING_CONST(b, "/"); | |
3515 | + buffer_append_string_len(b, CONST_STR_LEN("/")); | |
3516 | buffer_append_long(b, c->request.content_length); | |
3517 | } else { | |
3518 | - BUFFER_APPEND_STRING_CONST(b, "0/0"); | |
3519 | + buffer_append_string_len(b, CONST_STR_LEN("0/0")); | |
3520 | } | |
3521 | ||
3522 | - BUFFER_APPEND_STRING_CONST(b, "</td><td class=\"int\">"); | |
3523 | + buffer_append_string_len(b, CONST_STR_LEN("</td><td class=\"int\">")); | |
3524 | ||
3525 | buffer_append_off_t(b, chunkqueue_written(c->write_queue)); | |
3526 | - BUFFER_APPEND_STRING_CONST(b, "/"); | |
3527 | + buffer_append_string_len(b, CONST_STR_LEN("/")); | |
3528 | buffer_append_off_t(b, chunkqueue_length(c->write_queue)); | |
3529 | ||
3530 | - BUFFER_APPEND_STRING_CONST(b, "</td><td class=\"string\">"); | |
3531 | + buffer_append_string_len(b, CONST_STR_LEN("</td><td class=\"string\">")); | |
3532 | ||
3533 | buffer_append_string(b, connection_get_state(c->state)); | |
3534 | ||
3535 | - BUFFER_APPEND_STRING_CONST(b, "</td><td class=\"int\">"); | |
3536 | + buffer_append_string_len(b, CONST_STR_LEN("</td><td class=\"int\">")); | |
3537 | ||
3538 | buffer_append_long(b, srv->cur_ts - c->request_start); | |
3539 | ||
3540 | - BUFFER_APPEND_STRING_CONST(b, "</td><td class=\"string\">"); | |
3541 | + buffer_append_string_len(b, CONST_STR_LEN("</td><td class=\"string\">")); | |
3542 | ||
3543 | if (buffer_is_empty(c->server_name)) { | |
3544 | buffer_append_string_buffer(b, c->uri.authority); | |
3545 | @@ -515,38 +511,38 @@ | |
3546 | buffer_append_string_buffer(b, c->server_name); | |
3547 | } | |
3548 | ||
3549 | - BUFFER_APPEND_STRING_CONST(b, "</td><td class=\"string\">"); | |
3550 | + buffer_append_string_len(b, CONST_STR_LEN("</td><td class=\"string\">")); | |
3551 | ||
3552 | if (!buffer_is_empty(c->uri.path)) { | |
3553 | buffer_append_string_encoded(b, CONST_BUF_LEN(c->uri.path), ENCODING_HTML); | |
3554 | } | |
3555 | ||
3556 | if (!buffer_is_empty(c->uri.query)) { | |
3557 | - BUFFER_APPEND_STRING_CONST(b, "?"); | |
3558 | + buffer_append_string_len(b, CONST_STR_LEN("?")); | |
3559 | buffer_append_string_encoded(b, CONST_BUF_LEN(c->uri.query), ENCODING_HTML); | |
3560 | } | |
3561 | ||
3562 | if (!buffer_is_empty(c->request.orig_uri)) { | |
3563 | - BUFFER_APPEND_STRING_CONST(b, " ("); | |
3564 | + buffer_append_string_len(b, CONST_STR_LEN(" (")); | |
3565 | buffer_append_string_encoded(b, CONST_BUF_LEN(c->request.orig_uri), ENCODING_HTML); | |
3566 | - BUFFER_APPEND_STRING_CONST(b, ")"); | |
3567 | + buffer_append_string_len(b, CONST_STR_LEN(")")); | |
3568 | } | |
3569 | - BUFFER_APPEND_STRING_CONST(b, "</td><td class=\"string\">"); | |
3570 | + buffer_append_string_len(b, CONST_STR_LEN("</td><td class=\"string\">")); | |
3571 | ||
3572 | buffer_append_string_buffer(b, c->physical.path); | |
3573 | ||
3574 | - BUFFER_APPEND_STRING_CONST(b, "</td></tr>\n"); | |
3575 | + buffer_append_string_len(b, CONST_STR_LEN("</td></tr>\n")); | |
3576 | } | |
3577 | ||
3578 | ||
3579 | - BUFFER_APPEND_STRING_CONST(b, | |
3580 | - "</table>\n"); | |
3581 | + buffer_append_string_len(b, CONST_STR_LEN( | |
3582 | + "</table>\n")); | |
3583 | ||
3584 | ||
3585 | - BUFFER_APPEND_STRING_CONST(b, | |
3586 | + buffer_append_string_len(b, CONST_STR_LEN( | |
3587 | " </body>\n" | |
3588 | "</html>\n" | |
3589 | - ); | |
3590 | + )); | |
3591 | ||
3592 | response_header_overwrite(srv, con, CONST_STR_LEN("Content-Type"), CONST_STR_LEN("text/html")); | |
3593 | ||
3594 | @@ -566,45 +562,45 @@ | |
3595 | b = chunkqueue_get_append_buffer(con->write_queue); | |
3596 | ||
3597 | /* output total number of requests */ | |
3598 | - BUFFER_APPEND_STRING_CONST(b, "Total Accesses: "); | |
3599 | + buffer_append_string_len(b, CONST_STR_LEN("Total Accesses: ")); | |
3600 | avg = p->abs_requests; | |
3601 | snprintf(buf, sizeof(buf) - 1, "%.0f", avg); | |
3602 | buffer_append_string(b, buf); | |
3603 | - BUFFER_APPEND_STRING_CONST(b, "\n"); | |
3604 | + buffer_append_string_len(b, CONST_STR_LEN("\n")); | |
3605 | ||
3606 | /* output total traffic out in kbytes */ | |
3607 | - BUFFER_APPEND_STRING_CONST(b, "Total kBytes: "); | |
3608 | + buffer_append_string_len(b, CONST_STR_LEN("Total kBytes: ")); | |
3609 | avg = p->abs_traffic_out / 1024; | |
3610 | snprintf(buf, sizeof(buf) - 1, "%.0f", avg); | |
3611 | buffer_append_string(b, buf); | |
3612 | - BUFFER_APPEND_STRING_CONST(b, "\n"); | |
3613 | + buffer_append_string_len(b, CONST_STR_LEN("\n")); | |
3614 | ||
3615 | /* output uptime */ | |
3616 | - BUFFER_APPEND_STRING_CONST(b, "Uptime: "); | |
3617 | + buffer_append_string_len(b, CONST_STR_LEN("Uptime: ")); | |
3618 | ts = srv->cur_ts - srv->startup_ts; | |
3619 | buffer_append_long(b, ts); | |
3620 | - BUFFER_APPEND_STRING_CONST(b, "\n"); | |
3621 | + buffer_append_string_len(b, CONST_STR_LEN("\n")); | |
3622 | ||
3623 | /* output busy servers */ | |
3624 | - BUFFER_APPEND_STRING_CONST(b, "BusyServers: "); | |
3625 | + buffer_append_string_len(b, CONST_STR_LEN("BusyServers: ")); | |
3626 | buffer_append_long(b, srv->conns->used); | |
3627 | - BUFFER_APPEND_STRING_CONST(b, "\n"); | |
3628 | + buffer_append_string_len(b, CONST_STR_LEN("\n")); | |
3629 | ||
3630 | - BUFFER_APPEND_STRING_CONST(b, "IdleServers: "); | |
3631 | + buffer_append_string_len(b, CONST_STR_LEN("IdleServers: ")); | |
3632 | buffer_append_long(b, srv->conns->size - srv->conns->used); | |
3633 | - BUFFER_APPEND_STRING_CONST(b, "\n"); | |
3634 | + buffer_append_string_len(b, CONST_STR_LEN("\n")); | |
3635 | ||
3636 | /* output scoreboard */ | |
3637 | - BUFFER_APPEND_STRING_CONST(b, "Scoreboard: "); | |
3638 | + buffer_append_string_len(b, CONST_STR_LEN("Scoreboard: ")); | |
3639 | for (k = 0; k < srv->conns->used; k++) { | |
3640 | connection *c = srv->conns->ptr[k]; | |
3641 | const char *state = connection_get_short_state(c->state); | |
3642 | buffer_append_string_len(b, state, 1); | |
3643 | } | |
3644 | for (l = 0; l < srv->conns->size - srv->conns->used; l++) { | |
3645 | - BUFFER_APPEND_STRING_CONST(b, "_"); | |
3646 | + buffer_append_string_len(b, CONST_STR_LEN("_")); | |
3647 | } | |
3648 | - BUFFER_APPEND_STRING_CONST(b, "\n"); | |
3649 | + buffer_append_string_len(b, CONST_STR_LEN("\n")); | |
3650 | ||
3651 | /* set text/plain output */ | |
3652 | ||
3653 | @@ -633,9 +629,9 @@ | |
3654 | size_t ndx = st->sorted[i]; | |
3655 | ||
3656 | buffer_append_string_buffer(b, st->data[ndx]->key); | |
3657 | - buffer_append_string(b, ": "); | |
3658 | + buffer_append_string_len(b, CONST_STR_LEN(": ")); | |
3659 | buffer_append_long(b, ((data_integer *)(st->data[ndx]))->value); | |
3660 | - buffer_append_string(b, "\n"); | |
3661 | + buffer_append_string_len(b, CONST_STR_LEN("\n")); | |
3662 | } | |
3663 | ||
3664 | response_header_overwrite(srv, con, CONST_STR_LEN("Content-Type"), CONST_STR_LEN("text/plain")); | |
3665 | @@ -696,7 +692,7 @@ | |
3666 | ||
3667 | b = chunkqueue_get_append_buffer(con->write_queue); | |
3668 | ||
3669 | - BUFFER_COPY_STRING_CONST(b, | |
3670 | + buffer_copy_string_len(b, CONST_STR_LEN( | |
3671 | "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n" | |
3672 | "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n" | |
3673 | " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n" | |
3674 | @@ -706,7 +702,7 @@ | |
3675 | " </head>\n" | |
3676 | " <body>\n" | |
3677 | " <h1>" PACKAGE_NAME " " PACKAGE_VERSION "</h1>\n" | |
3678 | - " <table summary=\"status\" border=\"1\">\n"); | |
3679 | + " <table summary=\"status\" border=\"1\">\n")); | |
3680 | ||
3681 | mod_status_header_append(b, "Server-Features"); | |
3682 | #ifdef HAVE_PCRE_H | |
3683 | @@ -733,19 +729,19 @@ | |
3684 | if (i == 0) { | |
3685 | buffer_copy_string_buffer(m, pl->name); | |
3686 | } else { | |
3687 | - BUFFER_APPEND_STRING_CONST(m, "<br />"); | |
3688 | + buffer_append_string_len(m, CONST_STR_LEN("<br />")); | |
3689 | buffer_append_string_buffer(m, pl->name); | |
3690 | } | |
3691 | } | |
3692 | ||
3693 | mod_status_row_append(b, "Loaded Modules", m->ptr); | |
3694 | ||
3695 | - BUFFER_APPEND_STRING_CONST(b, " </table>\n"); | |
3696 | + buffer_append_string_len(b, CONST_STR_LEN(" </table>\n")); | |
3697 | ||
3698 | - BUFFER_APPEND_STRING_CONST(b, | |
3699 | + buffer_append_string_len(b, CONST_STR_LEN( | |
3700 | " </body>\n" | |
3701 | "</html>\n" | |
3702 | - ); | |
3703 | + )); | |
3704 | ||
3705 | response_header_overwrite(srv, con, CONST_STR_LEN("Content-Type"), CONST_STR_LEN("text/html")); | |
3706 | ||
3707 | @@ -796,6 +792,8 @@ | |
3708 | static handler_t mod_status_handler(server *srv, connection *con, void *p_d) { | |
3709 | plugin_data *p = p_d; | |
3710 | ||
3711 | + if (con->mode != DIRECT) return HANDLER_GO_ON; | |
3712 | + | |
3713 | mod_status_patch_connection(srv, con, p); | |
3714 | ||
3715 | if (!buffer_is_empty(p->conf.status_url) && | |
ad6a5263 ER |
3716 | Index: src/md5.c |
3717 | =================================================================== | |
54b68997 ER |
3718 | --- src/md5.c (.../tags/lighttpd-1.4.19) (revision 2303) |
3719 | +++ src/md5.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
ad6a5263 ER |
3720 | @@ -52,9 +52,9 @@ |
3721 | #define S43 15 | |
3722 | #define S44 21 | |
3723 | ||
3724 | -static void MD5Transform (UINT4 [4], unsigned char [64]); | |
3725 | +static void MD5Transform (UINT4 [4], const unsigned char [64]); | |
3726 | static void Encode (unsigned char *, UINT4 *, unsigned int); | |
3727 | -static void Decode (UINT4 *, unsigned char *, unsigned int); | |
3728 | +static void Decode (UINT4 *, const unsigned char *, unsigned int); | |
3729 | ||
3730 | #ifdef HAVE_MEMCPY | |
3731 | #define MD5_memcpy(output, input, len) memcpy((output), (input), (len)) | |
3732 | @@ -126,12 +126,13 @@ | |
3733 | operation, processing another message block, and updating the | |
3734 | context. | |
3735 | */ | |
3736 | -void MD5_Update (context, input, inputLen) | |
3737 | +void MD5_Update (context, _input, inputLen) | |
3738 | MD5_CTX *context; /* context */ | |
3739 | -unsigned char *input; /* input block */ | |
3740 | +const void *_input; /* input block */ | |
3741 | unsigned int inputLen; /* length of input block */ | |
3742 | { | |
3743 | unsigned int i, ndx, partLen; | |
3744 | + const unsigned char *input = (const unsigned char*) _input; | |
3745 | ||
3746 | /* Compute number of bytes mod 64 */ | |
3747 | ndx = (unsigned int)((context->count[0] >> 3) & 0x3F); | |
3748 | @@ -200,7 +201,7 @@ | |
3749 | */ | |
3750 | static void MD5Transform (state, block) | |
3751 | UINT4 state[4]; | |
3752 | -unsigned char block[64]; | |
3753 | +const unsigned char block[64]; | |
3754 | { | |
3755 | UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16]; | |
3756 | ||
3757 | @@ -313,7 +314,7 @@ | |
3758 | */ | |
3759 | static void Decode (output, input, len) | |
3760 | UINT4 *output; | |
3761 | -unsigned char *input; | |
3762 | +const unsigned char *input; | |
3763 | unsigned int len; | |
3764 | { | |
3765 | unsigned int i, j; | |
a34aaa25 ER |
3766 | Index: src/mod_compress.c |
3767 | =================================================================== | |
54b68997 ER |
3768 | --- src/mod_compress.c (.../tags/lighttpd-1.4.19) (revision 2303) |
3769 | +++ src/mod_compress.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
ad6a5263 ER |
3770 | @@ -102,7 +102,7 @@ |
3771 | return HANDLER_GO_ON; | |
3772 | } | |
3773 | ||
3774 | -// 0 on success, -1 for error | |
3775 | +/* 0 on success, -1 for error */ | |
3776 | int mkdir_recursive(char *dir) { | |
3777 | char *p = dir; | |
3778 | ||
3779 | @@ -118,13 +118,13 @@ | |
3780 | } | |
3781 | ||
3782 | *p++ = '/'; | |
3783 | - if (!*p) return 0; // Ignore trailing slash | |
3784 | + if (!*p) return 0; /* Ignore trailing slash */ | |
3785 | } | |
3786 | ||
3787 | return (mkdir(dir, 0700) != 0) && (errno != EEXIST) ? -1 : 0; | |
3788 | } | |
3789 | ||
3790 | -// 0 on success, -1 for error | |
3791 | +/* 0 on success, -1 for error */ | |
3792 | int mkdir_for_file(char *filename) { | |
3793 | char *p = filename; | |
3794 | ||
3795 | @@ -140,7 +140,7 @@ | |
3796 | } | |
3797 | ||
3798 | *p++ = '/'; | |
3799 | - if (!*p) return -1; // Unexpected trailing slash in filename | |
3800 | + if (!*p) return -1; /* Unexpected trailing slash in filename */ | |
3801 | } | |
3802 | ||
3803 | return 0; | |
49b4da39 | 3804 | @@ -178,9 +178,9 @@ |
a34aaa25 ER |
3805 | } |
3806 | ||
3807 | if (!buffer_is_empty(s->compress_cache_dir)) { | |
49b4da39 ER |
3808 | + struct stat st; |
3809 | mkdir_recursive(s->compress_cache_dir->ptr); | |
3810 | ||
3811 | - struct stat st; | |
a34aaa25 ER |
3812 | if (0 != stat(s->compress_cache_dir->ptr, &st)) { |
3813 | log_error_write(srv, __FILE__, __LINE__, "sbs", "can't stat compress.cache-dir", | |
49b4da39 | 3814 | s->compress_cache_dir, strerror(errno)); |
54b68997 ER |
3815 | @@ -396,13 +396,13 @@ |
3816 | ||
3817 | switch(type) { | |
3818 | case HTTP_ACCEPT_ENCODING_GZIP: | |
3819 | - buffer_append_string(p->ofn, "-gzip-"); | |
3820 | + buffer_append_string_len(p->ofn, CONST_STR_LEN("-gzip-")); | |
3821 | break; | |
3822 | case HTTP_ACCEPT_ENCODING_DEFLATE: | |
3823 | - buffer_append_string(p->ofn, "-deflate-"); | |
3824 | + buffer_append_string_len(p->ofn, CONST_STR_LEN("-deflate-")); | |
3825 | break; | |
3826 | case HTTP_ACCEPT_ENCODING_BZIP2: | |
3827 | - buffer_append_string(p->ofn, "-bzip2-"); | |
3828 | + buffer_append_string_len(p->ofn, CONST_STR_LEN("-bzip2-")); | |
3829 | break; | |
3830 | default: | |
3831 | log_error_write(srv, __FILE__, __LINE__, "sd", "unknown compression type", type); | |
ad6a5263 ER |
3832 | Index: src/md5.h |
3833 | =================================================================== | |
54b68997 ER |
3834 | --- src/md5.h (.../tags/lighttpd-1.4.19) (revision 2303) |
3835 | +++ src/md5.h (.../branches/lighttpd-1.4.x) (revision 2303) | |
ad6a5263 ER |
3836 | @@ -42,6 +42,6 @@ |
3837 | } MD5_CTX; | |
3838 | ||
3839 | void MD5_Init (MD5_CTX *); | |
3840 | -void MD5_Update (MD5_CTX *, unsigned char *, unsigned int); | |
3841 | +void MD5_Update (MD5_CTX *, const void *, unsigned int); | |
3842 | void MD5_Final (unsigned char [16], MD5_CTX *); | |
3843 | ||
54b68997 ER |
3844 | Index: src/mod_ssi.c |
3845 | =================================================================== | |
3846 | --- src/mod_ssi.c (.../tags/lighttpd-1.4.19) (revision 2303) | |
3847 | +++ src/mod_ssi.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
3848 | @@ -177,7 +177,7 @@ | |
3849 | } | |
3850 | ||
3851 | if (0 != strcasecmp(ds->key->ptr, "CONTENT-TYPE")) { | |
3852 | - buffer_copy_string(srv->tmp_buf, "HTTP_"); | |
3853 | + buffer_copy_string_len(srv->tmp_buf, CONST_STR_LEN("HTTP_")); | |
3854 | srv->tmp_buf->used--; | |
3855 | } | |
3856 | ||
3857 | @@ -419,7 +419,7 @@ | |
3858 | ||
3859 | b = chunkqueue_get_append_buffer(con->write_queue); | |
3860 | if (0 == strftime(buf, sizeof(buf), p->timefmt->ptr, localtime(&t))) { | |
3861 | - buffer_copy_string(b, "(none)"); | |
3862 | + buffer_copy_string_len(b, CONST_STR_LEN("(none)")); | |
3863 | } else { | |
3864 | buffer_copy_string(b, buf); | |
3865 | } | |
3866 | @@ -430,7 +430,7 @@ | |
3867 | ||
3868 | b = chunkqueue_get_append_buffer(con->write_queue); | |
3869 | if (0 == strftime(buf, sizeof(buf), p->timefmt->ptr, localtime(&t))) { | |
3870 | - buffer_copy_string(b, "(none)"); | |
3871 | + buffer_copy_string_len(b, CONST_STR_LEN("(none)")); | |
3872 | } else { | |
3873 | buffer_copy_string(b, buf); | |
3874 | } | |
3875 | @@ -441,7 +441,7 @@ | |
3876 | ||
3877 | b = chunkqueue_get_append_buffer(con->write_queue); | |
3878 | if (0 == strftime(buf, sizeof(buf), p->timefmt->ptr, gmtime(&t))) { | |
3879 | - buffer_copy_string(b, "(none)"); | |
3880 | + buffer_copy_string_len(b, CONST_STR_LEN("(none)")); | |
3881 | } else { | |
3882 | buffer_copy_string(b, buf); | |
3883 | } | |
3884 | @@ -472,7 +472,7 @@ | |
3885 | if (NULL != (ds = (data_string *)array_get_element(p->ssi_cgi_env, var_val))) { | |
3886 | buffer_copy_string_buffer(b, ds->value); | |
3887 | } else { | |
3888 | - buffer_copy_string(b, "(none)"); | |
3889 | + buffer_copy_string_len(b, CONST_STR_LEN("(none)")); | |
3890 | } | |
3891 | ||
3892 | break; | |
3893 | @@ -519,7 +519,7 @@ | |
3894 | if (file_path) { | |
3895 | /* current doc-root */ | |
3896 | if (NULL == (sl = strrchr(con->physical.path->ptr, '/'))) { | |
3897 | - buffer_copy_string(p->stat_fn, "/"); | |
3898 | + buffer_copy_string_len(p->stat_fn, CONST_STR_LEN("/")); | |
3899 | } else { | |
3900 | buffer_copy_string_len(p->stat_fn, con->physical.path->ptr, sl - con->physical.path->ptr + 1); | |
3901 | } | |
3902 | @@ -573,7 +573,7 @@ | |
3903 | case SSI_FLASTMOD: | |
3904 | b = chunkqueue_get_append_buffer(con->write_queue); | |
3905 | if (0 == strftime(buf, sizeof(buf), p->timefmt->ptr, localtime(&t))) { | |
3906 | - buffer_copy_string(b, "(none)"); | |
3907 | + buffer_copy_string_len(b, CONST_STR_LEN("(none)")); | |
3908 | } else { | |
3909 | buffer_copy_string(b, buf); | |
3910 | } | |
3911 | @@ -656,17 +656,17 @@ | |
3912 | if (p->if_is_false) break; | |
3913 | ||
3914 | b = chunkqueue_get_append_buffer(con->write_queue); | |
3915 | - buffer_copy_string(b, "<pre>"); | |
3916 | + buffer_copy_string_len(b, CONST_STR_LEN("<pre>")); | |
3917 | for (i = 0; i < p->ssi_vars->used; i++) { | |
3918 | data_string *ds = (data_string *)p->ssi_vars->data[p->ssi_vars->sorted[i]]; | |
3919 | ||
3920 | buffer_append_string_buffer(b, ds->key); | |
3921 | - buffer_append_string(b, ": "); | |
3922 | + buffer_append_string_len(b, CONST_STR_LEN(": ")); | |
3923 | buffer_append_string_buffer(b, ds->value); | |
3924 | - buffer_append_string(b, "<br />"); | |
3925 | + buffer_append_string_len(b, CONST_STR_LEN("<br />")); | |
3926 | ||
3927 | } | |
3928 | - buffer_append_string(b, "</pre>"); | |
3929 | + buffer_append_string_len(b, CONST_STR_LEN("</pre>")); | |
3930 | ||
3931 | break; | |
3932 | case SSI_EXEC: { | |
3933 | @@ -924,7 +924,7 @@ | |
3934 | ||
3935 | array_reset(p->ssi_vars); | |
3936 | array_reset(p->ssi_cgi_env); | |
3937 | - buffer_copy_string(p->timefmt, "%a, %d %b %Y %H:%M:%S %Z"); | |
3938 | + buffer_copy_string_len(p->timefmt, CONST_STR_LEN("%a, %d %b %Y %H:%M:%S %Z")); | |
3939 | p->sizefmt = 0; | |
3940 | build_ssi_cgi_vars(srv, con, p); | |
3941 | p->if_is_false = 0; | |
3942 | @@ -1027,6 +1027,7 @@ | |
3943 | ||
3944 | con->file_started = 1; | |
3945 | con->file_finished = 1; | |
3946 | + con->mode = p->id; | |
3947 | ||
3948 | response_header_overwrite(srv, con, CONST_STR_LEN("Content-Type"), CONST_STR_LEN("text/html")); | |
3949 | ||
3950 | @@ -1094,6 +1095,8 @@ | |
3951 | plugin_data *p = p_d; | |
3952 | size_t k; | |
3953 | ||
3954 | + if (con->mode != DIRECT) return HANDLER_GO_ON; | |
3955 | + | |
3956 | if (con->physical.path->used == 0) return HANDLER_GO_ON; | |
3957 | ||
3958 | mod_ssi_patch_connection(srv, con, p); | |
3959 | @@ -1109,6 +1112,7 @@ | |
3960 | if (mod_ssi_handle_request(srv, con, p)) { | |
3961 | /* on error */ | |
3962 | con->http_status = 500; | |
3963 | + con->mode = DIRECT; | |
3964 | } | |
3965 | ||
3966 | return HANDLER_FINISHED; | |
3c3043fd ER |
3967 | Index: src/spawn-fcgi.c |
3968 | =================================================================== | |
54b68997 ER |
3969 | --- src/spawn-fcgi.c (.../tags/lighttpd-1.4.19) (revision 2303) |
3970 | +++ src/spawn-fcgi.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
3c3043fd ER |
3971 | @@ -37,9 +37,9 @@ |
3972 | #endif | |
3973 | ||
3974 | #ifdef HAVE_SYS_UN_H | |
3975 | -int fcgi_spawn_connection(char *appPath, char **appArgv, char *addr, unsigned short port, const char *unixsocket, int child_count, int pid_fd, int nofork) { | |
3976 | +int fcgi_spawn_connection(char *appPath, char **appArgv, char *addr, unsigned short port, const char *unixsocket, int fork_count, int child_count, int pid_fd, int nofork) { | |
3977 | int fcgi_fd; | |
3978 | - int socket_type, status; | |
3979 | + int socket_type, status, rc = 0; | |
3980 | struct timeval tv = { 0, 100 * 1000 }; | |
3981 | ||
3982 | struct sockaddr_un fcgi_addr_un; | |
3983 | @@ -48,9 +48,6 @@ | |
3984 | ||
3985 | socklen_t servlen; | |
3986 | ||
3987 | - pid_t child; | |
3988 | - int val; | |
3989 | - | |
3990 | if (child_count < 2) { | |
3991 | child_count = 5; | |
3992 | } | |
3993 | @@ -74,25 +71,6 @@ | |
3994 | #endif | |
3995 | socket_type = AF_UNIX; | |
3996 | fcgi_addr = (struct sockaddr *) &fcgi_addr_un; | |
3997 | - | |
3998 | - /* check if some backend is listening on the socket | |
3999 | - * as if we delete the socket-file and rebind there will be no "socket already in use" error | |
4000 | - */ | |
4001 | - if (-1 == (fcgi_fd = socket(socket_type, SOCK_STREAM, 0))) { | |
4002 | - fprintf(stderr, "%s.%d\n", | |
4003 | - __FILE__, __LINE__); | |
4004 | - return -1; | |
4005 | - } | |
4006 | - | |
4007 | - if (-1 != connect(fcgi_fd, fcgi_addr, servlen)) { | |
4008 | - fprintf(stderr, "%s.%d: socket is already used, can't spawn\n", | |
4009 | - __FILE__, __LINE__); | |
4010 | - return -1; | |
4011 | - } | |
4012 | - | |
4013 | - /* cleanup previous socket if it exists */ | |
4014 | - unlink(unixsocket); | |
4015 | - close(fcgi_fd); | |
4016 | } else { | |
4017 | fcgi_addr_in.sin_family = AF_INET; | |
4018 | if (addr != NULL) { | |
4019 | @@ -107,133 +85,176 @@ | |
4020 | fcgi_addr = (struct sockaddr *) &fcgi_addr_in; | |
4021 | } | |
4022 | ||
4023 | - /* open socket */ | |
4024 | if (-1 == (fcgi_fd = socket(socket_type, SOCK_STREAM, 0))) { | |
4025 | fprintf(stderr, "%s.%d\n", | |
4026 | __FILE__, __LINE__); | |
4027 | return -1; | |
4028 | } | |
4029 | ||
4030 | - val = 1; | |
4031 | - if (setsockopt(fcgi_fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val)) < 0) { | |
4032 | - fprintf(stderr, "%s.%d\n", | |
4033 | - __FILE__, __LINE__); | |
4034 | - return -1; | |
4035 | - } | |
4036 | + if (-1 == connect(fcgi_fd, fcgi_addr, servlen)) { | |
4037 | + /* server is not up, spawn in */ | |
4038 | + pid_t child; | |
4039 | + int val; | |
4040 | ||
4041 | - /* create socket */ | |
4042 | - if (-1 == bind(fcgi_fd, fcgi_addr, servlen)) { | |
4043 | - fprintf(stderr, "%s.%d: bind failed: %s\n", | |
4044 | - __FILE__, __LINE__, | |
4045 | - strerror(errno)); | |
4046 | - return -1; | |
4047 | - } | |
4048 | + if (unixsocket) unlink(unixsocket); | |
4049 | ||
4050 | - if (-1 == listen(fcgi_fd, 1024)) { | |
4051 | - fprintf(stderr, "%s.%d: fd = -1\n", | |
4052 | - __FILE__, __LINE__); | |
4053 | - return -1; | |
4054 | - } | |
4055 | + close(fcgi_fd); | |
4056 | ||
4057 | - if (!nofork) { | |
4058 | - child = fork(); | |
4059 | - } else { | |
4060 | - child = 0; | |
4061 | - } | |
4062 | + /* reopen socket */ | |
4063 | + if (-1 == (fcgi_fd = socket(socket_type, SOCK_STREAM, 0))) { | |
4064 | + fprintf(stderr, "%s.%d\n", | |
4065 | + __FILE__, __LINE__); | |
4066 | + return -1; | |
4067 | + } | |
4068 | ||
4069 | - switch (child) { | |
4070 | - case 0: { | |
4071 | - char cgi_childs[64]; | |
4072 | + val = 1; | |
4073 | + if (setsockopt(fcgi_fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val)) < 0) { | |
4074 | + fprintf(stderr, "%s.%d\n", | |
4075 | + __FILE__, __LINE__); | |
4076 | + return -1; | |
4077 | + } | |
4078 | ||
4079 | - int i = 0; | |
4080 | - | |
4081 | - /* is safe as we limit to 256 childs */ | |
4082 | - sprintf(cgi_childs, "PHP_FCGI_CHILDREN=%d", child_count); | |
4083 | - | |
4084 | - if(fcgi_fd != FCGI_LISTENSOCK_FILENO) { | |
4085 | - close(FCGI_LISTENSOCK_FILENO); | |
4086 | - dup2(fcgi_fd, FCGI_LISTENSOCK_FILENO); | |
4087 | - close(fcgi_fd); | |
4088 | + /* create socket */ | |
4089 | + if (-1 == bind(fcgi_fd, fcgi_addr, servlen)) { | |
4090 | + fprintf(stderr, "%s.%d: bind failed: %s\n", | |
4091 | + __FILE__, __LINE__, | |
4092 | + strerror(errno)); | |
4093 | + return -1; | |
4094 | } | |
4095 | ||
4096 | - /* we don't need the client socket */ | |
4097 | - for (i = 3; i < 256; i++) { | |
4098 | - close(i); | |
4099 | + if (-1 == listen(fcgi_fd, 1024)) { | |
4100 | + fprintf(stderr, "%s.%d: fd = -1\n", | |
4101 | + __FILE__, __LINE__); | |
4102 | + return -1; | |
4103 | } | |
4104 | ||
4105 | - /* create environment */ | |
4106 | + while (fork_count-- > 0) { | |
4107 | ||
4108 | - putenv(cgi_childs); | |
4109 | + if (!nofork) { | |
4110 | + child = fork(); | |
4111 | + } else { | |
4112 | + child = 0; | |
4113 | + } | |
4114 | ||
4115 | - /* fork and replace shell */ | |
4116 | - if (appArgv) { | |
4117 | - execv(appArgv[0], appArgv); | |
4118 | + switch (child) { | |
4119 | + case 0: { | |
4120 | + char cgi_childs[64]; | |
4121 | + int max_fd = 0; | |
4122 | ||
4123 | - } else { | |
4124 | - char *b = malloc(strlen("exec ") + strlen(appPath) + 1); | |
4125 | - strcpy(b, "exec "); | |
4126 | - strcat(b, appPath); | |
4127 | + int i = 0; | |
4128 | ||
4129 | - /* exec the cgi */ | |
4130 | - execl("/bin/sh", "sh", "-c", b, (char *)NULL); | |
4131 | - } | |
4132 | + /* loose control terminal */ | |
4133 | + setsid(); | |
4134 | ||
4135 | - exit(errno); | |
4136 | + /* is safe as we limit to 256 childs */ | |
4137 | + sprintf(cgi_childs, "PHP_FCGI_CHILDREN=%d", child_count); | |
4138 | ||
4139 | - break; | |
4140 | - } | |
4141 | - case -1: | |
4142 | - /* error */ | |
4143 | - break; | |
4144 | - default: | |
4145 | - /* father */ | |
4146 | + if(fcgi_fd != FCGI_LISTENSOCK_FILENO) { | |
4147 | + close(FCGI_LISTENSOCK_FILENO); | |
4148 | + dup2(fcgi_fd, FCGI_LISTENSOCK_FILENO); | |
4149 | + close(fcgi_fd); | |
4150 | + } | |
4151 | ||
4152 | - /* wait */ | |
4153 | - select(0, NULL, NULL, NULL, &tv); | |
4154 | + max_fd = open("/dev/null", O_RDWR); | |
4155 | + close(STDERR_FILENO); | |
4156 | + dup2(max_fd, STDERR_FILENO); | |
4157 | + close(max_fd); | |
4158 | ||
4159 | - switch (waitpid(child, &status, WNOHANG)) { | |
4160 | - case 0: | |
4161 | - fprintf(stderr, "%s.%d: child spawned successfully: PID: %d\n", | |
4162 | - __FILE__, __LINE__, | |
4163 | - child); | |
4164 | + max_fd = open("/dev/null", O_RDWR); | |
4165 | + close(STDOUT_FILENO); | |
4166 | + dup2(max_fd, STDOUT_FILENO); | |
4167 | + close(max_fd); | |
4168 | ||
4169 | - /* write pid file */ | |
4170 | - if (pid_fd != -1) { | |
4171 | - /* assume a 32bit pid_t */ | |
4172 | - char pidbuf[12]; | |
4173 | + /* we don't need the client socket */ | |
4174 | + for (i = 3; i < max_fd; i++) { | |
4175 | + if (i != FCGI_LISTENSOCK_FILENO) close(i); | |
4176 | + } | |
4177 | ||
4178 | - snprintf(pidbuf, sizeof(pidbuf) - 1, "%d", child); | |
4179 | + /* create environment */ | |
4180 | ||
4181 | - write(pid_fd, pidbuf, strlen(pidbuf)); | |
4182 | - close(pid_fd); | |
4183 | - pid_fd = -1; | |
4184 | + putenv(cgi_childs); | |
4185 | + | |
4186 | + /* fork and replace shell */ | |
4187 | + if (appArgv) { | |
4188 | + execv(appArgv[0], appArgv); | |
4189 | + | |
4190 | + } else { | |
4191 | + char *b = malloc(strlen("exec ") + strlen(appPath) + 1); | |
4192 | + strcpy(b, "exec "); | |
4193 | + strcat(b, appPath); | |
4194 | + | |
4195 | + /* exec the cgi */ | |
4196 | + execl("/bin/sh", "sh", "-c", b, (char *)NULL); | |
4197 | + } | |
4198 | + | |
4199 | + exit(errno); | |
4200 | + | |
4201 | + break; | |
4202 | } | |
4203 | + case -1: | |
4204 | + /* error */ | |
4205 | + break; | |
4206 | + default: | |
4207 | + /* father */ | |
4208 | ||
4209 | - break; | |
4210 | - case -1: | |
4211 | - break; | |
4212 | - default: | |
4213 | - if (WIFEXITED(status)) { | |
4214 | - fprintf(stderr, "%s.%d: child exited with: %d, %s\n", | |
4215 | - __FILE__, __LINE__, | |
4216 | - WEXITSTATUS(status), strerror(WEXITSTATUS(status))); | |
4217 | - } else if (WIFSIGNALED(status)) { | |
4218 | - fprintf(stderr, "%s.%d: child signaled: %d\n", | |
4219 | - __FILE__, __LINE__, | |
4220 | - WTERMSIG(status)); | |
4221 | - } else { | |
4222 | - fprintf(stderr, "%s.%d: child died somehow: %d\n", | |
4223 | - __FILE__, __LINE__, | |
4224 | - status); | |
4225 | + /* wait */ | |
4226 | + select(0, NULL, NULL, NULL, &tv); | |
4227 | + | |
4228 | + switch (waitpid(child, &status, WNOHANG)) { | |
4229 | + case 0: | |
4230 | + fprintf(stdout, "%s.%d: child spawned successfully: PID: %d\n", | |
4231 | + __FILE__, __LINE__, | |
4232 | + child); | |
4233 | + | |
4234 | + /* write pid file */ | |
4235 | + if (pid_fd != -1) { | |
4236 | + /* assume a 32bit pid_t */ | |
4237 | + char pidbuf[12]; | |
4238 | + | |
4239 | + snprintf(pidbuf, sizeof(pidbuf) - 1, "%d", child); | |
4240 | + | |
4241 | + write(pid_fd, pidbuf, strlen(pidbuf)); | |
4242 | + /* avoid eol for the last one */ | |
4243 | + if (fork_count != 0) { | |
4244 | + write(pid_fd, "\n", 1); | |
4245 | + } | |
4246 | + } | |
4247 | + | |
4248 | + break; | |
4249 | + case -1: | |
4250 | + break; | |
4251 | + default: | |
4252 | + if (WIFEXITED(status)) { | |
4253 | + fprintf(stderr, "%s.%d: child exited with: %d\n", | |
4254 | + __FILE__, __LINE__, WEXITSTATUS(status)); | |
4255 | + rc = WEXITSTATUS(status); | |
4256 | + } else if (WIFSIGNALED(status)) { | |
4257 | + fprintf(stderr, "%s.%d: child signaled: %d\n", | |
4258 | + __FILE__, __LINE__, | |
4259 | + WTERMSIG(status)); | |
4260 | + rc = 1; | |
4261 | + } else { | |
4262 | + fprintf(stderr, "%s.%d: child died somehow: %d\n", | |
4263 | + __FILE__, __LINE__, | |
4264 | + status); | |
4265 | + rc = status; | |
4266 | + } | |
4267 | + } | |
4268 | + | |
4269 | + break; | |
4270 | } | |
4271 | } | |
4272 | - | |
4273 | - break; | |
4274 | + close(pid_fd); | |
4275 | + pid_fd = -1; | |
4276 | + } else { | |
4277 | + fprintf(stderr, "%s.%d: socket is already used, can't spawn\n", | |
4278 | + __FILE__, __LINE__); | |
4279 | + return -1; | |
4280 | } | |
4281 | ||
4282 | close(fcgi_fd); | |
4283 | ||
4284 | - return 0; | |
4285 | + return rc; | |
4286 | } | |
4287 | ||
4288 | ||
4289 | @@ -256,6 +277,7 @@ | |
4290 | " -p <port> bind to tcp-port\n" \ | |
4291 | " -s <path> bind to unix-domain socket\n" \ | |
4292 | " -C <childs> (PHP only) numbers of childs to spawn (default 5)\n" \ | |
4293 | +" -F <childs> numbers of childs to fork (default 1)\n" \ | |
4294 | " -P <path> name of PID-file for spawed process\n" \ | |
4295 | " -n no fork (for daemontools)\n" \ | |
4296 | " -v show version\n" \ | |
4297 | @@ -276,20 +298,21 @@ | |
4298 | char **fcgi_app_argv = { NULL }; | |
4299 | unsigned short port = 0; | |
4300 | int child_count = 5; | |
4301 | + int fork_count = 1; | |
4302 | int i_am_root, o; | |
4303 | int pid_fd = -1; | |
4304 | int nofork = 0; | |
4305 | struct sockaddr_un un; | |
4306 | - const size_t sun_path_len = sizeof(un.sun_path); | |
4307 | ||
4308 | i_am_root = (getuid() == 0); | |
4309 | ||
4310 | - while(-1 != (o = getopt(argc, argv, "c:f:g:hna:p:u:vC:s:P:"))) { | |
4311 | + while (-1 != (o = getopt(argc, argv, "c:f:g:hna:p:u:vC:F:s:P:"))) { | |
4312 | switch(o) { | |
4313 | case 'f': fcgi_app = optarg; break; | |
4314 | case 'a': addr = optarg;/* ip addr */ break; | |
4315 | case 'p': port = strtol(optarg, NULL, 10);/* port */ break; | |
4316 | case 'C': child_count = strtol(optarg, NULL, 10);/* */ break; | |
4317 | + case 'F': fork_count = strtol(optarg, NULL, 10);/* */ break; | |
4318 | case 's': unixsocket = optarg; /* unix-domain socket */ break; | |
4319 | case 'c': if (i_am_root) { changeroot = optarg; }/* chroot() */ break; | |
4320 | case 'u': if (i_am_root) { username = optarg; } /* set user */ break; | |
4321 | @@ -321,7 +344,7 @@ | |
4322 | return -1; | |
4323 | } | |
4324 | ||
4325 | - if (unixsocket && strlen(unixsocket) > sun_path_len - 1) { | |
4326 | + if (unixsocket && strlen(unixsocket) > sizeof(un.sun_path) - 1) { | |
4327 | fprintf(stderr, "%s.%d: %s\n", | |
4328 | __FILE__, __LINE__, | |
4329 | "path of the unix socket is too long\n"); | |
4330 | @@ -416,18 +439,15 @@ | |
4331 | "I will not set gid to 0\n"); | |
4332 | return -1; | |
4333 | } | |
4334 | - } | |
4335 | ||
4336 | - /* | |
4337 | - * Change group before chroot, when we have access | |
4338 | - * to /etc/group | |
4339 | - */ | |
4340 | - if (groupname) { | |
4341 | + /* do the change before we do the chroot() */ | |
4342 | setgid(grp->gr_gid); | |
4343 | - setgroups(0, NULL); | |
4344 | + setgroups(0, NULL); | |
4345 | + | |
4346 | if (username) { | |
4347 | initgroups(username, grp->gr_gid); | |
4348 | } | |
4349 | + | |
54b68997 ER |
4350 | } |
4351 | ||
4352 | if (changeroot) { | |
4353 | @@ -451,7 +471,7 @@ | |
4354 | } | |
4355 | } | |
4356 | ||
4357 | - return fcgi_spawn_connection(fcgi_app, fcgi_app_argv, addr, port, unixsocket, child_count, pid_fd, nofork); | |
4358 | + return fcgi_spawn_connection(fcgi_app, fcgi_app_argv, addr, port, unixsocket, fork_count, child_count, pid_fd, nofork); | |
4359 | } | |
4360 | #else | |
4361 | int main() { | |
4362 | Index: src/mod_auth.c | |
4363 | =================================================================== | |
4364 | --- src/mod_auth.c (.../tags/lighttpd-1.4.19) (revision 2303) | |
4365 | +++ src/mod_auth.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
4366 | @@ -150,13 +150,15 @@ | |
4367 | PATCH(auth_ldap_hostname); | |
4368 | #ifdef USE_LDAP | |
4369 | PATCH(ldap); | |
4370 | - PATCH(ldap_filter_pre); | |
4371 | - PATCH(ldap_filter_post); | |
4372 | #endif | |
4373 | } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("auth.backend.ldap.base-dn"))) { | |
4374 | PATCH(auth_ldap_basedn); | |
4375 | } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("auth.backend.ldap.filter"))) { | |
4376 | PATCH(auth_ldap_filter); | |
4377 | +#ifdef USE_LDAP | |
4378 | + PATCH(ldap_filter_pre); | |
4379 | + PATCH(ldap_filter_post); | |
4380 | +#endif | |
4381 | } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("auth.backend.ldap.ca-file"))) { | |
4382 | PATCH(auth_ldap_cafile); | |
4383 | } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("auth.backend.ldap.starttls"))) { | |
4384 | @@ -248,6 +250,7 @@ | |
4385 | if (0 == strcmp(method->value->ptr, "digest")) { | |
4386 | if (-1 == (auth_satisfied = http_auth_digest_check(srv, con, p, req, con->uri.path, auth_realm+1))) { | |
4387 | con->http_status = 400; | |
4388 | + con->mode = DIRECT; | |
4389 | ||
4390 | /* a field was missing */ | |
4391 | ||
4392 | @@ -268,22 +271,23 @@ | |
4393 | realm = (data_string *)array_get_element(req, "realm"); | |
4394 | ||
4395 | con->http_status = 401; | |
4396 | + con->mode = DIRECT; | |
4397 | ||
4398 | if (0 == strcmp(method->value->ptr, "basic")) { | |
4399 | - buffer_copy_string(p->tmp_buf, "Basic realm=\""); | |
4400 | + buffer_copy_string_len(p->tmp_buf, CONST_STR_LEN("Basic realm=\"")); | |
4401 | buffer_append_string_buffer(p->tmp_buf, realm->value); | |
4402 | - buffer_append_string(p->tmp_buf, "\""); | |
4403 | + buffer_append_string_len(p->tmp_buf, CONST_STR_LEN("\"")); | |
4404 | ||
4405 | response_header_insert(srv, con, CONST_STR_LEN("WWW-Authenticate"), CONST_BUF_LEN(p->tmp_buf)); | |
4406 | } else if (0 == strcmp(method->value->ptr, "digest")) { | |
4407 | char hh[33]; | |
4408 | http_auth_digest_generate_nonce(srv, p, srv->tmp_buf, hh); | |
4409 | ||
4410 | - buffer_copy_string(p->tmp_buf, "Digest realm=\""); | |
4411 | + buffer_copy_string_len(p->tmp_buf, CONST_STR_LEN("Digest realm=\"")); | |
4412 | buffer_append_string_buffer(p->tmp_buf, realm->value); | |
4413 | - buffer_append_string(p->tmp_buf, "\", nonce=\""); | |
4414 | + buffer_append_string_len(p->tmp_buf, CONST_STR_LEN("\", nonce=\"")); | |
4415 | buffer_append_string(p->tmp_buf, hh); | |
4416 | - buffer_append_string(p->tmp_buf, "\", qop=\"auth\""); | |
4417 | + buffer_append_string_len(p->tmp_buf, CONST_STR_LEN("\", qop=\"auth\"")); | |
4418 | ||
4419 | response_header_insert(srv, con, CONST_STR_LEN("WWW-Authenticate"), CONST_BUF_LEN(p->tmp_buf)); | |
4420 | } else { | |
4421 | @@ -393,6 +397,23 @@ | |
4422 | } | |
4423 | } | |
4424 | ||
4425 | +#ifdef USE_LDAP | |
4426 | + if (s->auth_ldap_filter->used) { | |
4427 | + char *dollar; | |
4428 | + | |
4429 | + /* parse filter */ | |
4430 | + | |
4431 | + if (NULL == (dollar = strchr(s->auth_ldap_filter->ptr, '$'))) { | |
4432 | + log_error_write(srv, __FILE__, __LINE__, "s", "ldap: auth.backend.ldap.filter is missing a replace-operator '$'"); | |
4433 | + | |
4434 | + return HANDLER_ERROR; | |
4435 | + } | |
4436 | + | |
4437 | + buffer_copy_string_len(s->ldap_filter_pre, s->auth_ldap_filter->ptr, dollar - s->auth_ldap_filter->ptr); | |
4438 | + buffer_copy_string(s->ldap_filter_post, dollar+1); | |
4439 | + } | |
4440 | +#endif | |
4441 | + | |
4442 | /* no auth.require for this section */ | |
4443 | if (NULL == (da = (data_array *)array_get_element(ca, "auth.require"))) continue; | |
3c3043fd | 4444 | |
54b68997 ER |
4445 | @@ -479,21 +500,21 @@ |
4446 | ||
4447 | ds = data_string_init(); | |
4448 | ||
4449 | - buffer_copy_string(ds->key, "method"); | |
4450 | + buffer_copy_string_len(ds->key, CONST_STR_LEN("method")); | |
4451 | buffer_copy_string(ds->value, method); | |
4452 | ||
4453 | array_insert_unique(a->value, (data_unset *)ds); | |
4454 | ||
4455 | ds = data_string_init(); | |
4456 | ||
4457 | - buffer_copy_string(ds->key, "realm"); | |
4458 | + buffer_copy_string_len(ds->key, CONST_STR_LEN("realm")); | |
4459 | buffer_copy_string(ds->value, realm); | |
4460 | ||
4461 | array_insert_unique(a->value, (data_unset *)ds); | |
4462 | ||
4463 | ds = data_string_init(); | |
4464 | ||
4465 | - buffer_copy_string(ds->key, "require"); | |
4466 | + buffer_copy_string_len(ds->key, CONST_STR_LEN("require")); | |
4467 | buffer_copy_string(ds->value, require); | |
4468 | ||
4469 | array_insert_unique(a->value, (data_unset *)ds); | |
4470 | @@ -507,97 +528,83 @@ | |
4471 | handler_t ret = auth_ldap_init(srv, s); | |
4472 | if (ret == HANDLER_ERROR) | |
4473 | return (ret); | |
4474 | - break; | |
4475 | + break; | |
3c3043fd | 4476 | } |
54b68997 ER |
4477 | - default: |
4478 | - break; | |
4479 | - } | |
4480 | - } | |
4481 | + default: | |
4482 | + break; | |
4483 | + } | |
4484 | + } | |
3c3043fd | 4485 | |
54b68997 ER |
4486 | - return HANDLER_GO_ON; |
4487 | + return HANDLER_GO_ON; | |
3c3043fd | 4488 | } |
ad6a5263 ER |
4489 | |
4490 | handler_t auth_ldap_init(server *srv, mod_auth_plugin_config *s) { | |
4491 | #ifdef USE_LDAP | |
4492 | - int ret; | |
4493 | + int ret; | |
4494 | #if 0 | |
4495 | - if (s->auth_ldap_basedn->used == 0) { | |
4496 | - log_error_write(srv, __FILE__, __LINE__, "s", "ldap: auth.backend.ldap.base-dn has to be set"); | |
4497 | + if (s->auth_ldap_basedn->used == 0) { | |
4498 | + log_error_write(srv, __FILE__, __LINE__, "s", "ldap: auth.backend.ldap.base-dn has to be set"); | |
4499 | ||
4500 | - return HANDLER_ERROR; | |
4501 | - } | |
4502 | + return HANDLER_ERROR; | |
4503 | + } | |
4504 | #endif | |
4505 | ||
4506 | - if (s->auth_ldap_filter->used) { | |
4507 | - char *dollar; | |
54b68997 ER |
4508 | + if (s->auth_ldap_hostname->used) { |
4509 | + if (NULL == (s->ldap = ldap_init(s->auth_ldap_hostname->ptr, LDAP_PORT))) { | |
4510 | + log_error_write(srv, __FILE__, __LINE__, "ss", "ldap ...", strerror(errno)); | |
ad6a5263 ER |
4511 | |
4512 | - /* parse filter */ | |
54b68997 ER |
4513 | + return HANDLER_ERROR; |
4514 | + } | |
ad6a5263 ER |
4515 | |
4516 | - if (NULL == (dollar = strchr(s->auth_ldap_filter->ptr, '$'))) { | |
4517 | - log_error_write(srv, __FILE__, __LINE__, "s", "ldap: auth.backend.ldap.filter is missing a replace-operator '$'"); | |
54b68997 ER |
4518 | + ret = LDAP_VERSION3; |
4519 | + if (LDAP_OPT_SUCCESS != (ret = ldap_set_option(s->ldap, LDAP_OPT_PROTOCOL_VERSION, &ret))) { | |
4520 | + log_error_write(srv, __FILE__, __LINE__, "ss", "ldap:", ldap_err2string(ret)); | |
ad6a5263 ER |
4521 | |
4522 | - return HANDLER_ERROR; | |
4523 | - } | |
4524 | + return HANDLER_ERROR; | |
4525 | + } | |
4526 | ||
4527 | - buffer_copy_string_len(s->ldap_filter_pre, s->auth_ldap_filter->ptr, dollar - s->auth_ldap_filter->ptr); | |
4528 | - buffer_copy_string(s->ldap_filter_post, dollar+1); | |
4529 | - } | |
ad6a5263 ER |
4530 | + if (s->auth_ldap_starttls) { |
4531 | + /* if no CA file is given, it is ok, as we will use encryption | |
4532 | + * if the server requires a CAfile it will tell us */ | |
4533 | + if (!buffer_is_empty(s->auth_ldap_cafile)) { | |
4534 | + if (LDAP_OPT_SUCCESS != (ret = ldap_set_option(NULL, LDAP_OPT_X_TLS_CACERTFILE, | |
4535 | + s->auth_ldap_cafile->ptr))) { | |
4536 | + log_error_write(srv, __FILE__, __LINE__, "ss", | |
4537 | + "Loading CA certificate failed:", ldap_err2string(ret)); | |
54b68997 ER |
4538 | |
4539 | - if (s->auth_ldap_hostname->used) { | |
4540 | - if (NULL == (s->ldap = ldap_init(s->auth_ldap_hostname->ptr, LDAP_PORT))) { | |
4541 | - log_error_write(srv, __FILE__, __LINE__, "ss", "ldap ...", strerror(errno)); | |
4542 | - | |
ad6a5263 ER |
4543 | return HANDLER_ERROR; |
4544 | } | |
4545 | + } | |
4546 | ||
54b68997 ER |
4547 | - ret = LDAP_VERSION3; |
4548 | - if (LDAP_OPT_SUCCESS != (ret = ldap_set_option(s->ldap, LDAP_OPT_PROTOCOL_VERSION, &ret))) { | |
4549 | - log_error_write(srv, __FILE__, __LINE__, "ss", "ldap:", ldap_err2string(ret)); | |
4550 | + if (LDAP_OPT_SUCCESS != (ret = ldap_start_tls_s(s->ldap, NULL, NULL))) { | |
4551 | + log_error_write(srv, __FILE__, __LINE__, "ss", "ldap startTLS failed:", ldap_err2string(ret)); | |
4552 | ||
4553 | - return HANDLER_ERROR; | |
4554 | - } | |
4555 | + return HANDLER_ERROR; | |
4556 | + } | |
4557 | + } | |
4558 | ||
ad6a5263 ER |
4559 | - if (s->auth_ldap_starttls) { |
4560 | - /* if no CA file is given, it is ok, as we will use encryption | |
4561 | - * if the server requires a CAfile it will tell us */ | |
4562 | - if (!buffer_is_empty(s->auth_ldap_cafile)) { | |
4563 | - if (LDAP_OPT_SUCCESS != (ret = ldap_set_option(NULL, LDAP_OPT_X_TLS_CACERTFILE, | |
4564 | - s->auth_ldap_cafile->ptr))) { | |
4565 | - log_error_write(srv, __FILE__, __LINE__, "ss", | |
4566 | - "Loading CA certificate failed:", ldap_err2string(ret)); | |
ad6a5263 ER |
4567 | |
4568 | - return HANDLER_ERROR; | |
4569 | - } | |
4570 | - } | |
ad6a5263 ER |
4571 | + /* 1. */ |
4572 | + if (s->auth_ldap_binddn->used) { | |
4573 | + if (LDAP_SUCCESS != (ret = ldap_simple_bind_s(s->ldap, s->auth_ldap_binddn->ptr, s->auth_ldap_bindpw->ptr))) { | |
4574 | + log_error_write(srv, __FILE__, __LINE__, "ss", "ldap:", ldap_err2string(ret)); | |
4575 | ||
54b68997 ER |
4576 | - if (LDAP_OPT_SUCCESS != (ret = ldap_start_tls_s(s->ldap, NULL, NULL))) { |
4577 | - log_error_write(srv, __FILE__, __LINE__, "ss", "ldap startTLS failed:", ldap_err2string(ret)); | |
ad6a5263 ER |
4578 | + return HANDLER_ERROR; |
4579 | + } | |
4580 | + } else { | |
4581 | + if (LDAP_SUCCESS != (ret = ldap_simple_bind_s(s->ldap, NULL, NULL))) { | |
4582 | + log_error_write(srv, __FILE__, __LINE__, "ss", "ldap:", ldap_err2string(ret)); | |
4583 | ||
54b68997 ER |
4584 | - return HANDLER_ERROR; |
4585 | - } | |
4586 | - } | |
4587 | - | |
4588 | - | |
ad6a5263 ER |
4589 | - /* 1. */ |
4590 | - if (s->auth_ldap_binddn->used) { | |
4591 | - if (LDAP_SUCCESS != (ret = ldap_simple_bind_s(s->ldap, s->auth_ldap_binddn->ptr, s->auth_ldap_bindpw->ptr))) { | |
4592 | - log_error_write(srv, __FILE__, __LINE__, "ss", "ldap:", ldap_err2string(ret)); | |
4593 | - | |
4594 | - return HANDLER_ERROR; | |
4595 | - } | |
4596 | - } else { | |
4597 | - if (LDAP_SUCCESS != (ret = ldap_simple_bind_s(s->ldap, NULL, NULL))) { | |
4598 | - log_error_write(srv, __FILE__, __LINE__, "ss", "ldap:", ldap_err2string(ret)); | |
4599 | - | |
4600 | - return HANDLER_ERROR; | |
4601 | - } | |
4602 | - } | |
4603 | + return HANDLER_ERROR; | |
4604 | } | |
4605 | + } | |
4606 | + } | |
4607 | + return HANDLER_GO_ON; | |
4608 | #else | |
4609 | - log_error_write(srv, __FILE__, __LINE__, "s", "no ldap support available"); | |
4610 | - return HANDLER_ERROR; | |
4611 | + UNUSED(s); | |
4612 | + log_error_write(srv, __FILE__, __LINE__, "s", "no ldap support available"); | |
4613 | + return HANDLER_ERROR; | |
4614 | #endif | |
4615 | - return HANDLER_GO_ON; | |
4616 | } | |
4617 | ||
4618 | int mod_auth_plugin_init(plugin *p) { | |
54b68997 ER |
4619 | Index: src/data_string.c |
4620 | =================================================================== | |
4621 | --- src/data_string.c (.../tags/lighttpd-1.4.19) (revision 2303) | |
4622 | +++ src/data_string.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
4623 | @@ -37,7 +37,7 @@ | |
4624 | data_string *ds_src = (data_string *)src; | |
4625 | ||
4626 | if (ds_dst->value->used) { | |
4627 | - buffer_append_string(ds_dst->value, ", "); | |
4628 | + buffer_append_string_len(ds_dst->value, CONST_STR_LEN(", ")); | |
4629 | buffer_append_string_buffer(ds_dst->value, ds_src->value); | |
4630 | } else { | |
4631 | buffer_copy_string_buffer(ds_dst->value, ds_src->value); | |
4632 | @@ -53,9 +53,9 @@ | |
4633 | data_string *ds_src = (data_string *)src; | |
4634 | ||
4635 | if (ds_dst->value->used) { | |
4636 | - buffer_append_string(ds_dst->value, "\r\n"); | |
4637 | + buffer_append_string_len(ds_dst->value, CONST_STR_LEN("\r\n")); | |
4638 | buffer_append_string_buffer(ds_dst->value, ds_dst->key); | |
4639 | - buffer_append_string(ds_dst->value, ": "); | |
4640 | + buffer_append_string_len(ds_dst->value, CONST_STR_LEN(": ")); | |
4641 | buffer_append_string_buffer(ds_dst->value, ds_src->value); | |
4642 | } else { | |
4643 | buffer_copy_string_buffer(ds_dst->value, ds_src->value); | |
4644 | Index: src/http-header-glue.c | |
4645 | =================================================================== | |
4646 | --- src/http-header-glue.c (.../tags/lighttpd-1.4.19) (revision 2303) | |
4647 | +++ src/http-header-glue.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
4648 | @@ -109,9 +109,9 @@ | |
4649 | o = buffer_init(); | |
4650 | ||
4651 | if (con->conf.is_ssl) { | |
4652 | - buffer_copy_string(o, "https://"); | |
4653 | + buffer_copy_string_len(o, CONST_STR_LEN("https://")); | |
4654 | } else { | |
4655 | - buffer_copy_string(o, "http://"); | |
4656 | + buffer_copy_string_len(o, CONST_STR_LEN("http://")); | |
4657 | } | |
4658 | if (con->uri.authority->used) { | |
4659 | buffer_append_string_buffer(o, con->uri.authority); | |
4660 | @@ -180,14 +180,14 @@ | |
4661 | ||
4662 | if (!((con->conf.is_ssl == 0 && srv->srvconf.port == 80) || | |
4663 | (con->conf.is_ssl == 1 && srv->srvconf.port == 443))) { | |
4664 | - buffer_append_string(o, ":"); | |
4665 | + buffer_append_string_len(o, CONST_STR_LEN(":")); | |
4666 | buffer_append_long(o, srv->srvconf.port); | |
4667 | } | |
4668 | } | |
4669 | buffer_append_string_buffer(o, con->uri.path); | |
4670 | - buffer_append_string(o, "/"); | |
4671 | + buffer_append_string_len(o, CONST_STR_LEN("/")); | |
4672 | if (!buffer_is_empty(con->uri.query)) { | |
4673 | - buffer_append_string(o, "?"); | |
4674 | + buffer_append_string_len(o, CONST_STR_LEN("?")); | |
4675 | buffer_append_string_buffer(o, con->uri.query); | |
4676 | } | |
4677 | ||
4678 | @@ -272,6 +272,7 @@ | |
4679 | con->request.http_if_modified_since, used_len, sizeof(buf) - 1); | |
4680 | ||
4681 | con->http_status = 412; | |
4682 | + con->mode = DIRECT; | |
4683 | return HANDLER_FINISHED; | |
4684 | } | |
4685 | ||
4686 | @@ -281,6 +282,7 @@ | |
4687 | ||
4688 | if (NULL == strptime(buf, "%a, %d %b %Y %H:%M:%S GMT", &tm)) { | |
4689 | con->http_status = 412; | |
4690 | + con->mode = DIRECT; | |
4691 | return HANDLER_FINISHED; | |
4692 | } | |
4693 | t_header = mktime(&tm); | |
4694 | @@ -299,6 +301,7 @@ | |
4695 | } | |
4696 | } else { | |
4697 | con->http_status = 412; | |
4698 | + con->mode = DIRECT; | |
4699 | return HANDLER_FINISHED; | |
4700 | } | |
4701 | } | |
4702 | Index: src/mod_evasive.c | |
4703 | =================================================================== | |
4704 | --- src/mod_evasive.c (.../tags/lighttpd-1.4.19) (revision 2303) | |
4705 | +++ src/mod_evasive.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
4706 | @@ -138,24 +138,47 @@ | |
4707 | /* no limit set, nothing to block */ | |
4708 | if (p->conf.max_conns == 0) return HANDLER_GO_ON; | |
4709 | ||
4710 | + switch (con->dst_addr.plain.sa_family) { | |
4711 | + case AF_INET: | |
4712 | +#ifdef HAVE_IPV6 | |
4713 | + case AF_INET6: | |
4714 | +#endif | |
4715 | + break; | |
4716 | + default: // Address family not supported | |
4717 | + return HANDLER_GO_ON; | |
4718 | + }; | |
4719 | + | |
4720 | for (j = 0; j < srv->conns->used; j++) { | |
4721 | connection *c = srv->conns->ptr[j]; | |
4722 | ||
4723 | /* check if other connections are already actively serving data for the same IP | |
4724 | * we can only ban connections which are already behind the 'read request' state | |
4725 | * */ | |
4726 | - if (c->dst_addr.ipv4.sin_addr.s_addr == con->dst_addr.ipv4.sin_addr.s_addr && | |
4727 | - c->state > CON_STATE_REQUEST_END) { | |
4728 | - conns_by_ip++; | |
4729 | + if (c->dst_addr.plain.sa_family != con->dst_addr.plain.sa_family) continue; | |
4730 | + if (c->state <= CON_STATE_REQUEST_END) continue; | |
4731 | ||
4732 | - if (conns_by_ip > p->conf.max_conns) { | |
4733 | - log_error_write(srv, __FILE__, __LINE__, "ss", | |
4734 | - inet_ntop_cache_get_ip(srv, &(con->dst_addr)), | |
4735 | - "turned away. Too many connections."); | |
4736 | + switch (con->dst_addr.plain.sa_family) { | |
4737 | + case AF_INET: | |
4738 | + if (c->dst_addr.ipv4.sin_addr.s_addr != con->dst_addr.ipv4.sin_addr.s_addr) continue; | |
4739 | + break; | |
4740 | +#ifdef HAVE_IPV6 | |
4741 | + case AF_INET6: | |
4742 | + if (0 != memcmp(c->dst_addr.ipv6.sin6_addr.s6_addr, con->dst_addr.ipv6.sin6_addr.s6_addr, 16)) continue; | |
4743 | + break; | |
4744 | +#endif | |
4745 | + default: /* Address family not supported, should never be reached */ | |
4746 | + continue; | |
4747 | + }; | |
4748 | + conns_by_ip++; | |
4749 | ||
4750 | - con->http_status = 403; | |
4751 | - return HANDLER_FINISHED; | |
4752 | - } | |
4753 | + if (conns_by_ip > p->conf.max_conns) { | |
4754 | + log_error_write(srv, __FILE__, __LINE__, "ss", | |
4755 | + inet_ntop_cache_get_ip(srv, &(con->dst_addr)), | |
4756 | + "turned away. Too many connections."); | |
4757 | + | |
4758 | + con->http_status = 403; | |
4759 | + con->mode = DIRECT; | |
4760 | + return HANDLER_FINISHED; | |
4761 | } | |
4762 | } | |
4763 | ||
4764 | Index: src/mod_indexfile.c | |
4765 | =================================================================== | |
4766 | --- src/mod_indexfile.c (.../tags/lighttpd-1.4.19) (revision 2303) | |
4767 | +++ src/mod_indexfile.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
4768 | @@ -140,6 +140,8 @@ | |
4769 | size_t k; | |
4770 | stat_cache_entry *sce = NULL; | |
4771 | ||
4772 | + if (con->mode != DIRECT) return HANDLER_GO_ON; | |
4773 | + | |
4774 | if (con->uri.path->used == 0) return HANDLER_GO_ON; | |
4775 | if (con->uri.path->ptr[con->uri.path->used - 2] != '/') return HANDLER_GO_ON; | |
4776 | ||
4777 | Index: src/mod_uploadprogress.c | |
4778 | =================================================================== | |
4779 | --- src/mod_uploadprogress.c (.../tags/lighttpd-1.4.19) (revision 2303) | |
4780 | +++ src/mod_uploadprogress.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
4781 | @@ -355,6 +355,7 @@ | |
4782 | con->file_finished = 1; | |
4783 | ||
4784 | con->http_status = 200; | |
4785 | + con->mode = DIRECT; | |
4786 | ||
4787 | /* get the connection */ | |
4788 | if (NULL == (post_con = connection_map_get_connection(p->con_map, b))) { | |
4789 | @@ -363,7 +364,7 @@ | |
4790 | ||
4791 | b = chunkqueue_get_append_buffer(con->write_queue); | |
4792 | ||
4793 | - BUFFER_APPEND_STRING_CONST(b, "starting"); | |
4794 | + buffer_append_string_len(b, CONST_STR_LEN("starting")); | |
4795 | ||
4796 | return HANDLER_FINISHED; | |
4797 | } | |
4798 | @@ -378,15 +379,18 @@ | |
4799 | b = chunkqueue_get_append_buffer(con->write_queue); | |
4800 | ||
4801 | /* prepare XML */ | |
4802 | - BUFFER_COPY_STRING_CONST(b, "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>"); | |
4803 | - BUFFER_APPEND_STRING_CONST(b, "<upload>"); | |
4804 | - BUFFER_APPEND_STRING_CONST(b, "<size>"); | |
4805 | + buffer_copy_string_len(b, CONST_STR_LEN( | |
4806 | + "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>" | |
4807 | + "<upload>" | |
4808 | + "<size>")); | |
4809 | buffer_append_off_t(b, post_con->request.content_length); | |
4810 | - BUFFER_APPEND_STRING_CONST(b, "</size>"); | |
4811 | - BUFFER_APPEND_STRING_CONST(b, "<received>"); | |
4812 | + buffer_append_string_len(b, CONST_STR_LEN( | |
4813 | + "</size>" | |
4814 | + "<received>")); | |
4815 | buffer_append_off_t(b, post_con->request_content_queue->bytes_in); | |
4816 | - BUFFER_APPEND_STRING_CONST(b, "</received>"); | |
4817 | - BUFFER_APPEND_STRING_CONST(b, "</upload>"); | |
4818 | + buffer_append_string_len(b, CONST_STR_LEN( | |
4819 | + "</received>" | |
4820 | + "</upload>")); | |
4821 | ||
4822 | log_error_write(srv, __FILE__, __LINE__, "sb", "...", b); | |
4823 | ||
1e1cc0d1 ER |
4824 | Index: src/mod_fastcgi.c |
4825 | =================================================================== | |
54b68997 ER |
4826 | --- src/mod_fastcgi.c (.../tags/lighttpd-1.4.19) (revision 2303) |
4827 | +++ src/mod_fastcgi.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
ad6a5263 ER |
4828 | @@ -236,6 +236,16 @@ |
4829 | unsigned short break_scriptfilename_for_php; | |
4830 | ||
4831 | /* | |
4832 | + * workaround for program when prefix="/" | |
4833 | + * | |
4834 | + * rule to build PATH_INFO is hardcoded for when check_local is disabled | |
4835 | + * enable this option to use the workaround | |
4836 | + * | |
4837 | + */ | |
4838 | + | |
4839 | + unsigned short fix_root_path_name; | |
4840 | + | |
4841 | + /* | |
4842 | * If the backend includes X-LIGHTTPD-send-file in the response | |
4843 | * we use the value as filename and ignore the content. | |
4844 | * | |
54b68997 ER |
4845 | @@ -380,10 +390,10 @@ |
4846 | static handler_t fcgi_handle_fdevent(void *s, void *ctx, int revents); | |
4847 | ||
4848 | int fastcgi_status_copy_procname(buffer *b, fcgi_extension_host *host, fcgi_proc *proc) { | |
4849 | - buffer_copy_string(b, "fastcgi.backend."); | |
4850 | + buffer_copy_string_len(b, CONST_STR_LEN("fastcgi.backend.")); | |
4851 | buffer_append_string_buffer(b, host->id); | |
4852 | if (proc) { | |
4853 | - buffer_append_string(b, "."); | |
4854 | + buffer_append_string_len(b, CONST_STR_LEN(".")); | |
4855 | buffer_append_long(b, proc->id); | |
4856 | } | |
4857 | ||
4858 | @@ -393,7 +403,7 @@ | |
4859 | int fastcgi_status_init(server *srv, buffer *b, fcgi_extension_host *host, fcgi_proc *proc) { | |
4860 | #define CLEAN(x) \ | |
4861 | fastcgi_status_copy_procname(b, host, proc); \ | |
4862 | - buffer_append_string(b, x); \ | |
4863 | + buffer_append_string_len(b, CONST_STR_LEN(x)); \ | |
4864 | status_counter_set(srv, CONST_BUF_LEN(b), 0); | |
4865 | ||
4866 | CLEAN(".disabled"); | |
4867 | @@ -406,7 +416,7 @@ | |
4868 | ||
4869 | #define CLEAN(x) \ | |
4870 | fastcgi_status_copy_procname(b, host, NULL); \ | |
4871 | - buffer_append_string(b, x); \ | |
4872 | + buffer_append_string_len(b, CONST_STR_LEN(x)); \ | |
4873 | status_counter_set(srv, CONST_BUF_LEN(b), 0); | |
4874 | ||
4875 | CLEAN(".load"); | |
4876 | @@ -693,6 +703,7 @@ | |
4877 | ||
4878 | static int env_add(char_array *env, const char *key, size_t key_len, const char *val, size_t val_len) { | |
4879 | char *dst; | |
4880 | + size_t i; | |
4881 | ||
4882 | if (!key || !val) return -1; | |
4883 | ||
4884 | @@ -702,6 +713,15 @@ | |
4885 | /* add the \0 from the value */ | |
4886 | memcpy(dst + key_len + 1, val, val_len + 1); | |
4887 | ||
4888 | + for (i = 0; i < env->used; i++) { | |
4889 | + if (0 == strncmp(dst, env->ptr[i], key_len + 1)) { | |
4890 | + /* don't care about free as we are in a forked child which is going to exec(...) */ | |
4891 | + /* free(env->ptr[i]); */ | |
4892 | + env->ptr[i] = dst; | |
4893 | + return 0; | |
4894 | + } | |
4895 | + } | |
4896 | + | |
4897 | if (env->size == 0) { | |
4898 | env->size = 16; | |
4899 | env->ptr = malloc(env->size * sizeof(*env->ptr)); | |
4900 | @@ -811,7 +831,7 @@ | |
4901 | socket_type = AF_UNIX; | |
4902 | fcgi_addr = (struct sockaddr *) &fcgi_addr_un; | |
4903 | ||
4904 | - buffer_copy_string(proc->connection_name, "unix:"); | |
4905 | + buffer_copy_string_len(proc->connection_name, CONST_STR_LEN("unix:")); | |
4906 | buffer_append_string_buffer(proc->connection_name, proc->unixsocket); | |
4907 | ||
4908 | #else | |
4909 | @@ -857,13 +877,13 @@ | |
4910 | socket_type = AF_INET; | |
4911 | fcgi_addr = (struct sockaddr *) &fcgi_addr_in; | |
4912 | ||
4913 | - buffer_copy_string(proc->connection_name, "tcp:"); | |
4914 | + buffer_copy_string_len(proc->connection_name, CONST_STR_LEN("tcp:")); | |
4915 | if (!buffer_is_empty(host->host)) { | |
4916 | buffer_append_string_buffer(proc->connection_name, host->host); | |
4917 | } else { | |
4918 | - buffer_append_string(proc->connection_name, "localhost"); | |
4919 | + buffer_append_string_len(proc->connection_name, CONST_STR_LEN("localhost")); | |
4920 | } | |
4921 | - buffer_append_string(proc->connection_name, ":"); | |
4922 | + buffer_append_string_len(proc->connection_name, CONST_STR_LEN(":")); | |
4923 | buffer_append_long(proc->connection_name, proc->port); | |
4924 | } | |
4925 | ||
4926 | @@ -937,6 +957,8 @@ | |
ad6a5263 ER |
4927 | close(fcgi_fd); |
4928 | } | |
4929 | ||
4930 | + openDevNull(STDERR_FILENO); | |
4931 | + | |
4932 | /* we don't need the client socket */ | |
4933 | for (i = 3; i < 256; i++) { | |
4934 | close(i); | |
54b68997 | 4935 | @@ -1000,8 +1022,8 @@ |
ad6a5263 ER |
4936 | /* exec the cgi */ |
4937 | execve(arg.ptr[0], arg.ptr, env.ptr); | |
4938 | ||
4939 | - log_error_write(srv, __FILE__, __LINE__, "sbs", | |
4940 | - "execve failed for:", host->bin_path, strerror(errno)); | |
4941 | + /* log_error_write(srv, __FILE__, __LINE__, "sbs", | |
4942 | + "execve failed for:", host->bin_path, strerror(errno)); */ | |
4943 | ||
4944 | exit(errno); | |
4945 | ||
54b68997 | 4946 | @@ -1193,6 +1215,7 @@ |
ad6a5263 ER |
4947 | { "allow-x-send-file", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 15 */ |
4948 | { "strip-request-uri", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 16 */ | |
4949 | { "kill-signal", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION }, /* 17 */ | |
4950 | + { "fix-root-scriptname", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 18 */ | |
4951 | ||
4952 | { NULL, NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET } | |
4953 | }; | |
54b68997 | 4954 | @@ -1220,6 +1243,7 @@ |
ad6a5263 ER |
4955 | host->break_scriptfilename_for_php = 0; |
4956 | host->allow_xsendfile = 0; /* handle X-LIGHTTPD-send-file */ | |
4957 | host->kill_signal = SIGTERM; | |
4958 | + host->fix_root_path_name = 0; | |
4959 | ||
4960 | fcv[0].destination = host->host; | |
4961 | fcv[1].destination = host->docroot; | |
54b68997 | 4962 | @@ -1241,6 +1265,7 @@ |
ad6a5263 ER |
4963 | fcv[15].destination = &(host->allow_xsendfile); |
4964 | fcv[16].destination = host->strip_request_uri; | |
4965 | fcv[17].destination = &(host->kill_signal); | |
4966 | + fcv[18].destination = &(host->fix_root_path_name); | |
4967 | ||
4968 | if (0 != config_insert_values_internal(srv, da_host->value, fcv)) { | |
4969 | return HANDLER_ERROR; | |
54b68997 ER |
4970 | @@ -1324,7 +1349,7 @@ |
4971 | proc->port = host->port + pno; | |
4972 | } else { | |
4973 | buffer_copy_string_buffer(proc->unixsocket, host->unixsocket); | |
4974 | - buffer_append_string(proc->unixsocket, "-"); | |
4975 | + buffer_append_string_len(proc->unixsocket, CONST_STR_LEN("-")); | |
4976 | buffer_append_long(proc->unixsocket, pno); | |
4977 | } | |
4978 | ||
4979 | @@ -1482,7 +1507,7 @@ | |
4980 | status_counter_dec(srv, CONST_STR_LEN("fastcgi.active-requests")); | |
4981 | ||
4982 | fastcgi_status_copy_procname(p->statuskey, hctx->host, hctx->proc); | |
4983 | - buffer_append_string(p->statuskey, ".load"); | |
4984 | + buffer_append_string_len(p->statuskey, CONST_STR_LEN(".load")); | |
4985 | ||
4986 | status_counter_set(srv, CONST_BUF_LEN(p->statuskey), hctx->proc->load); | |
4987 | ||
4988 | @@ -1683,7 +1708,7 @@ | |
4989 | ||
4990 | if (buffer_is_empty(proc->connection_name)) { | |
4991 | /* on remote spawing we have to set the connection-name now */ | |
4992 | - buffer_copy_string(proc->connection_name, "unix:"); | |
4993 | + buffer_copy_string_len(proc->connection_name, CONST_STR_LEN("unix:")); | |
4994 | buffer_append_string_buffer(proc->connection_name, proc->unixsocket); | |
4995 | } | |
4996 | #else | |
4997 | @@ -1709,13 +1734,13 @@ | |
4998 | ||
4999 | if (buffer_is_empty(proc->connection_name)) { | |
5000 | /* on remote spawing we have to set the connection-name now */ | |
5001 | - buffer_copy_string(proc->connection_name, "tcp:"); | |
5002 | + buffer_copy_string_len(proc->connection_name, CONST_STR_LEN("tcp:")); | |
5003 | if (!buffer_is_empty(host->host)) { | |
5004 | buffer_append_string_buffer(proc->connection_name, host->host); | |
5005 | } else { | |
5006 | - buffer_append_string(proc->connection_name, "localhost"); | |
5007 | + buffer_append_string_len(proc->connection_name, CONST_STR_LEN("localhost")); | |
5008 | } | |
5009 | - buffer_append_string(proc->connection_name, ":"); | |
5010 | + buffer_append_string_len(proc->connection_name, CONST_STR_LEN(":")); | |
5011 | buffer_append_long(proc->connection_name, proc->port); | |
5012 | } | |
5013 | } | |
5014 | @@ -1771,7 +1796,7 @@ | |
5015 | buffer_reset(srv->tmp_buf); | |
5016 | ||
5017 | if (0 != strcasecmp(ds->key->ptr, "CONTENT-TYPE")) { | |
5018 | - BUFFER_COPY_STRING_CONST(srv->tmp_buf, "HTTP_"); | |
5019 | + buffer_copy_string_len(srv->tmp_buf, CONST_STR_LEN("HTTP_")); | |
5020 | srv->tmp_buf->used--; | |
5021 | } | |
5022 | ||
5023 | @@ -2026,7 +2051,7 @@ | |
5024 | */ | |
5025 | if ('/' != host->strip_request_uri->ptr[host->strip_request_uri->used - 2]) { | |
5026 | /* fix the user-input to have / as last char */ | |
5027 | - buffer_append_string(host->strip_request_uri, "/"); | |
5028 | + buffer_append_string_len(host->strip_request_uri, CONST_STR_LEN("/")); | |
5029 | } | |
5030 | ||
5031 | if (con->request.orig_uri->used >= host->strip_request_uri->used && | |
5032 | @@ -2094,12 +2119,12 @@ | |
5033 | hctx->wb->bytes_in += sizeof(header); | |
5034 | ||
5035 | if (p->conf.debug > 10) { | |
5036 | - fprintf(stderr, "%s.%d: tosend: %lld / %lld\n", __FILE__, __LINE__, offset, req_cq->bytes_in); | |
5037 | + log_error_write(srv, __FILE__, __LINE__, "soso", "tosend:", offset, "/", req_cq->bytes_in); | |
5038 | } | |
5039 | ||
5040 | for (written = 0; written != weWant; ) { | |
5041 | if (p->conf.debug > 10) { | |
5042 | - fprintf(stderr, "%s.%d: chunk: %lld / %lld\n", __FILE__, __LINE__, written, weWant); | |
5043 | + log_error_write(srv, __FILE__, __LINE__, "soso", "chunk:", written, "/", weWant); | |
5044 | } | |
5045 | ||
5046 | switch (req_c->type) { | |
5047 | @@ -2109,12 +2134,10 @@ | |
5048 | if (weHave > weWant - written) weHave = weWant - written; | |
5049 | ||
5050 | if (p->conf.debug > 10) { | |
5051 | - fprintf(stderr, "%s.%d: sending %lld bytes from (%lld / %lld) %s\n", | |
5052 | - __FILE__, __LINE__, | |
5053 | - weHave, | |
5054 | - req_c->offset, | |
5055 | - req_c->file.length, | |
5056 | - req_c->file.name->ptr); | |
5057 | + log_error_write(srv, __FILE__, __LINE__, "soSosOsb", | |
5058 | + "sending", weHave, "bytes from (", | |
5059 | + req_c->offset, "/", req_c->file.length, ")", | |
5060 | + req_c->file.name); | |
5061 | } | |
5062 | ||
5063 | assert(weHave != 0); | |
5064 | @@ -2143,7 +2166,7 @@ | |
5065 | chunk *c; | |
5066 | ||
5067 | if (p->conf.debug > 10) { | |
5068 | - fprintf(stderr, "%s.%d: next chunk\n", __FILE__, __LINE__); | |
5069 | + log_error_write(srv, __FILE__, __LINE__, "s", "next chunk"); | |
5070 | } | |
5071 | c = hctx->wb->last; | |
5072 | ||
5073 | @@ -2173,7 +2196,7 @@ | |
5074 | ||
5075 | hctx->wb->bytes_in += weHave; | |
5076 | ||
5077 | - if (req_c->offset == req_c->mem->used - 1) { | |
5078 | + if (req_c->offset == (off_t) req_c->mem->used - 1) { | |
5079 | chunkqueue_remove_finished_chunks(req_cq); | |
5080 | ||
5081 | req_c = req_cq->first; | |
5082 | @@ -2368,7 +2391,7 @@ | |
5083 | offset = sizeof(*header); | |
5084 | ||
5085 | /* ->b should only be the content */ | |
5086 | - buffer_copy_string(packet->b, ""); /* used == 1 */ | |
5087 | + buffer_copy_string_len(packet->b, CONST_STR_LEN("")); /* used == 1 */ | |
5088 | ||
5089 | if (packet->len) { | |
5090 | /* copy the content */ | |
5091 | @@ -2544,7 +2567,10 @@ | |
1e1cc0d1 ER |
5092 | stat_cache_entry *sce; |
5093 | ||
5094 | if (HANDLER_ERROR != stat_cache_get_entry(srv, con, ds->value, &sce)) { | |
49b4da39 ER |
5095 | - data_string *dcls = data_string_init(); |
5096 | + data_string *dcls; | |
5097 | + if (NULL == (dcls = (data_string *)array_get_unused_element(con->response.headers, TYPE_STRING))) { | |
5098 | + dcls = data_response_init(); | |
5099 | + } | |
1e1cc0d1 | 5100 | /* found */ |
1e1cc0d1 ER |
5101 | http_chunk_append_file(srv, con, ds->value, 0, sce->st.st_size); |
5102 | hctx->send_content_body = 0; /* ignore the content */ | |
54b68997 ER |
5103 | @@ -2663,30 +2689,48 @@ |
5104 | ||
5105 | /* the child should not terminate at all */ | |
5106 | ||
5107 | - switch(waitpid(proc->pid, &status, WNOHANG)) { | |
5108 | - case 0: | |
5109 | - /* child is still alive */ | |
5110 | - break; | |
5111 | - case -1: | |
5112 | - break; | |
5113 | - default: | |
5114 | - if (WIFEXITED(status)) { | |
5115 | + for ( ;; ) { | |
5116 | + switch(waitpid(proc->pid, &status, WNOHANG)) { | |
5117 | + case 0: | |
5118 | + /* child is still alive */ | |
5119 | + if (srv->cur_ts <= proc->disabled_until) break; | |
5120 | + | |
5121 | + proc->state = PROC_STATE_RUNNING; | |
5122 | + host->active_procs++; | |
5123 | + | |
5124 | + log_error_write(srv, __FILE__, __LINE__, "sbdb", | |
5125 | + "fcgi-server re-enabled:", | |
5126 | + host->host, host->port, | |
5127 | + host->unixsocket); | |
5128 | + break; | |
5129 | + case -1: | |
5130 | + if (errno == EINTR) continue; | |
5131 | + | |
5132 | + log_error_write(srv, __FILE__, __LINE__, "sd", | |
5133 | + "child died somehow, waitpid failed:", | |
5134 | + errno); | |
5135 | + proc->state = PROC_STATE_DIED; | |
5136 | + break; | |
5137 | + default: | |
5138 | + if (WIFEXITED(status)) { | |
5139 | #if 0 | |
5140 | - log_error_write(srv, __FILE__, __LINE__, "sdsd", | |
5141 | - "child exited, pid:", proc->pid, | |
5142 | - "status:", WEXITSTATUS(status)); | |
5143 | + log_error_write(srv, __FILE__, __LINE__, "sdsd", | |
5144 | + "child exited, pid:", proc->pid, | |
5145 | + "status:", WEXITSTATUS(status)); | |
5146 | #endif | |
5147 | - } else if (WIFSIGNALED(status)) { | |
5148 | - log_error_write(srv, __FILE__, __LINE__, "sd", | |
5149 | - "child signaled:", | |
5150 | - WTERMSIG(status)); | |
5151 | - } else { | |
5152 | - log_error_write(srv, __FILE__, __LINE__, "sd", | |
5153 | - "child died somehow:", | |
5154 | - status); | |
5155 | + } else if (WIFSIGNALED(status)) { | |
5156 | + log_error_write(srv, __FILE__, __LINE__, "sd", | |
5157 | + "child signaled:", | |
5158 | + WTERMSIG(status)); | |
5159 | + } else { | |
5160 | + log_error_write(srv, __FILE__, __LINE__, "sd", | |
5161 | + "child died somehow:", | |
5162 | + status); | |
5163 | + } | |
5164 | + | |
5165 | + proc->state = PROC_STATE_DIED; | |
5166 | + break; | |
5167 | } | |
5168 | - | |
5169 | - proc->state = PROC_STATE_DIED; | |
5170 | break; | |
5171 | } | |
5172 | ||
5173 | @@ -2797,7 +2841,7 @@ | |
5174 | hctx->proc->state = PROC_STATE_DIED; | |
5175 | ||
5176 | fastcgi_status_copy_procname(p->statuskey, hctx->host, hctx->proc); | |
5177 | - buffer_append_string(p->statuskey, ".died"); | |
5178 | + buffer_append_string_len(p->statuskey, CONST_STR_LEN(".died")); | |
5179 | ||
5180 | status_counter_inc(srv, CONST_BUF_LEN(p->statuskey)); | |
5181 | ||
5182 | @@ -2889,7 +2933,7 @@ | |
5183 | hctx->proc->state = PROC_STATE_OVERLOADED; | |
5184 | ||
5185 | fastcgi_status_copy_procname(p->statuskey, hctx->host, hctx->proc); | |
5186 | - buffer_append_string(p->statuskey, ".overloaded"); | |
5187 | + buffer_append_string_len(p->statuskey, CONST_STR_LEN(".overloaded")); | |
5188 | ||
5189 | status_counter_inc(srv, CONST_BUF_LEN(p->statuskey)); | |
5190 | ||
5191 | @@ -2915,7 +2959,7 @@ | |
5192 | "load:", host->load); | |
5193 | ||
5194 | fastcgi_status_copy_procname(p->statuskey, hctx->host, hctx->proc); | |
5195 | - buffer_append_string(p->statuskey, ".died"); | |
5196 | + buffer_append_string_len(p->statuskey, CONST_STR_LEN(".died")); | |
5197 | ||
5198 | status_counter_inc(srv, CONST_BUF_LEN(p->statuskey)); | |
5199 | ||
5200 | @@ -2941,19 +2985,19 @@ | |
5201 | status_counter_inc(srv, CONST_STR_LEN("fastcgi.active-requests")); | |
5202 | ||
5203 | fastcgi_status_copy_procname(p->statuskey, hctx->host, hctx->proc); | |
5204 | - buffer_append_string(p->statuskey, ".connected"); | |
5205 | + buffer_append_string_len(p->statuskey, CONST_STR_LEN(".connected")); | |
5206 | ||
5207 | status_counter_inc(srv, CONST_BUF_LEN(p->statuskey)); | |
5208 | ||
5209 | /* the proc-load */ | |
5210 | fastcgi_status_copy_procname(p->statuskey, hctx->host, hctx->proc); | |
5211 | - buffer_append_string(p->statuskey, ".load"); | |
5212 | + buffer_append_string_len(p->statuskey, CONST_STR_LEN(".load")); | |
5213 | ||
5214 | status_counter_set(srv, CONST_BUF_LEN(p->statuskey), hctx->proc->load); | |
5215 | ||
5216 | /* the host-load */ | |
5217 | fastcgi_status_copy_procname(p->statuskey, hctx->host, NULL); | |
5218 | - buffer_append_string(p->statuskey, ".load"); | |
5219 | + buffer_append_string_len(p->statuskey, CONST_STR_LEN(".load")); | |
5220 | ||
5221 | status_counter_set(srv, CONST_BUF_LEN(p->statuskey), hctx->host->load); | |
5222 | ||
5223 | @@ -3074,7 +3118,7 @@ | |
ad6a5263 ER |
5224 | |
5225 | /* check if the next server has no load. */ | |
5226 | ndx = hctx->ext->last_used_ndx + 1; | |
5227 | - if(ndx >= hctx->ext->used || ndx < 0) ndx = 0; | |
5228 | + if(ndx >= (int) hctx->ext->used || ndx < 0) ndx = 0; | |
5229 | host = hctx->ext->hosts[ndx]; | |
5230 | if (host->load > 0) { | |
5231 | /* get backend with the least load. */ | |
54b68997 ER |
5232 | @@ -3418,6 +3462,8 @@ |
5233 | fcgi_extension *extension = NULL; | |
5234 | fcgi_extension_host *host = NULL; | |
5235 | ||
5236 | + if (con->mode != DIRECT) return HANDLER_GO_ON; | |
5237 | + | |
5238 | /* Possibly, we processed already this request */ | |
5239 | if (con->file_started == 1) return HANDLER_GO_ON; | |
5240 | ||
5241 | @@ -3480,13 +3526,12 @@ | |
ad6a5263 ER |
5242 | |
5243 | ct_len = extension->key->used - 1; | |
5244 | ||
5245 | - if (s_len < ct_len) continue; | |
5246 | - | |
5247 | - /* check extension in the form "/fcgi_pattern" */ | |
5248 | - if (*(extension->key->ptr) == '/') { | |
5249 | - if (strncmp(fn->ptr, extension->key->ptr, ct_len) == 0) | |
5250 | + /* check _url_ in the form "/fcgi_pattern" */ | |
5251 | + if (extension->key->ptr[0] == '/') { | |
5252 | + if ((ct_len <= con->uri.path->used -1) && | |
5253 | + (strncmp(con->uri.path->ptr, extension->key->ptr, ct_len) == 0)) | |
5254 | break; | |
5255 | - } else if (0 == strncmp(fn->ptr + s_len - ct_len, extension->key->ptr, ct_len)) { | |
5256 | + } else if ((ct_len <= s_len) && (0 == strncmp(fn->ptr + s_len - ct_len, extension->key->ptr, ct_len))) { | |
5257 | /* check extension in the form ".fcg" */ | |
5258 | break; | |
5259 | } | |
54b68997 | 5260 | @@ -3499,16 +3544,15 @@ |
ad6a5263 ER |
5261 | |
5262 | /* check if we have at least one server for this extension up and running */ | |
5263 | for (k = 0; k < extension->used; k++) { | |
5264 | - host = extension->hosts[k]; | |
5265 | + fcgi_extension_host *h = extension->hosts[k]; | |
5266 | ||
5267 | /* we should have at least one proc that can do something */ | |
5268 | - if (host->active_procs == 0) { | |
5269 | - host = NULL; | |
5270 | - | |
5271 | + if (h->active_procs == 0) { | |
5272 | continue; | |
5273 | } | |
5274 | ||
5275 | /* we found one host that is alive */ | |
5276 | + host = h; | |
5277 | break; | |
5278 | } | |
5279 | ||
54b68997 | 5280 | @@ -3582,6 +3626,13 @@ |
ad6a5263 ER |
5281 | * SCRIPT_NAME = /fcgi-bin/foo |
5282 | * PATH_INFO = /bar | |
5283 | * | |
5284 | + * if prefix = /, and fix-root-path-name is enable | |
5285 | + * | |
5286 | + * /fcgi-bin/foo/bar | |
5287 | + * | |
5288 | + * SCRIPT_NAME = /fcgi-bin/foo | |
5289 | + * PATH_INFO = /bar | |
5290 | + * | |
5291 | */ | |
5292 | ||
5293 | /* the rewrite is only done for /prefix/? matches */ | |
54b68997 | 5294 | @@ -3594,6 +3645,10 @@ |
ad6a5263 ER |
5295 | |
5296 | con->uri.path->used -= con->request.pathinfo->used - 1; | |
5297 | con->uri.path->ptr[con->uri.path->used - 1] = '\0'; | |
5298 | + } else if (host->fix_root_path_name && extension->key->ptr[0] == '/' && extension->key->ptr[1] == '\0') { | |
5299 | + buffer_copy_string(con->request.pathinfo, con->uri.path->ptr); | |
5300 | + con->uri.path->used = 1; | |
5301 | + con->uri.path->ptr[con->uri.path->used - 1] = '\0'; | |
5302 | } | |
5303 | } | |
5304 | } else { | |
54b68997 ER |
5305 | @@ -3738,7 +3793,7 @@ |
5306 | proc->port = host->port + proc->id; | |
5307 | } else { | |
5308 | buffer_copy_string_buffer(proc->unixsocket, host->unixsocket); | |
5309 | - buffer_append_string(proc->unixsocket, "-"); | |
5310 | + buffer_append_string_len(proc->unixsocket, CONST_STR_LEN("-")); | |
5311 | buffer_append_long(proc->unixsocket, proc->id); | |
5312 | } | |
5313 | ||
5314 | Index: src/mod_ssi_exprparser.y | |
5315 | =================================================================== | |
5316 | --- src/mod_ssi_exprparser.y (.../tags/lighttpd-1.4.19) (revision 2303) | |
5317 | +++ src/mod_ssi_exprparser.y (.../branches/lighttpd-1.4.x) (revision 2303) | |
5318 | @@ -105,12 +105,13 @@ | |
5319 | } | |
5320 | ||
5321 | value(A) ::= VALUE(B). { | |
5322 | - A = buffer_init_string(B->ptr); | |
5323 | + A = B; | |
5324 | } | |
5325 | ||
5326 | value(A) ::= value(B) VALUE(C). { | |
5327 | A = B; | |
5328 | buffer_append_string_buffer(A, C); | |
5329 | + buffer_free(C); | |
5330 | } | |
5331 | ||
5332 | cond(A) ::= EQ. { A = SSI_COND_EQ; } | |
5333 | Index: src/mod_access.c | |
5334 | =================================================================== | |
5335 | --- src/mod_access.c (.../tags/lighttpd-1.4.19) (revision 2303) | |
5336 | +++ src/mod_access.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
5337 | @@ -159,6 +159,7 @@ | |
5338 | ||
5339 | if (denied) { | |
5340 | con->http_status = 403; | |
5341 | + con->mode = DIRECT; | |
5342 | ||
5343 | if (con->conf.log_request_handling) { | |
5344 | log_error_write(srv, __FILE__, __LINE__, "sb", | |
ad6a5263 ER |
5345 | Index: src/mod_accesslog.c |
5346 | =================================================================== | |
54b68997 ER |
5347 | --- src/mod_accesslog.c (.../tags/lighttpd-1.4.19) (revision 2303) |
5348 | +++ src/mod_accesslog.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
5349 | @@ -356,7 +356,7 @@ | |
5350 | if (s->use_syslog) { | |
5351 | # ifdef HAVE_SYSLOG_H | |
5352 | if (s->access_logbuffer->used > 2) { | |
5353 | - syslog(LOG_INFO, "%*s", s->access_logbuffer->used - 2, s->access_logbuffer->ptr); | |
5354 | + syslog(LOG_INFO, "%*s", (int) s->access_logbuffer->used - 2, s->access_logbuffer->ptr); | |
5355 | } | |
5356 | # endif | |
5357 | } else if (s->log_access_fd != -1) { | |
5358 | @@ -433,7 +433,7 @@ | |
5359 | if (i == 0 && buffer_is_empty(s->format)) { | |
5360 | /* set a default logfile string */ | |
5361 | ||
5362 | - buffer_copy_string(s->format, "%h %V %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""); | |
5363 | + buffer_copy_string_len(s->format, CONST_STR_LEN("%h %V %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"")); | |
5364 | } | |
5365 | ||
5366 | /* parse */ | |
ad6a5263 ER |
5367 | @@ -473,7 +473,7 @@ |
5368 | continue; | |
5369 | } | |
5370 | ||
5371 | - if (buffer_is_empty(s->access_logfile)) continue; | |
5372 | + if (s->access_logfile->used < 2) continue; | |
5373 | ||
5374 | if (s->access_logfile->ptr[0] == '|') { | |
5375 | #ifdef HAVE_FORK | |
5376 | @@ -498,6 +498,8 @@ | |
5377 | /* not needed */ | |
5378 | close(to_log_fds[1]); | |
5379 | ||
5380 | + openDevNull(STDERR_FILENO); | |
5381 | + | |
5382 | /* we don't need the client socket */ | |
5383 | for (i = 3; i < 256; i++) { | |
5384 | close(i); | |
54b68997 ER |
5385 | @@ -559,7 +561,7 @@ |
5386 | #ifdef HAVE_SYSLOG_H | |
5387 | if (s->access_logbuffer->used > 2) { | |
5388 | /* syslog appends a \n on its own */ | |
5389 | - syslog(LOG_INFO, "%*s", s->access_logbuffer->used - 2, s->access_logbuffer->ptr); | |
5390 | + syslog(LOG_INFO, "%*s", (int) s->access_logbuffer->used - 2, s->access_logbuffer->ptr); | |
5391 | } | |
5392 | #endif | |
5393 | } else if (s->log_access_fd != -1) { | |
ad6a5263 ER |
5394 | @@ -570,7 +572,7 @@ |
5395 | } | |
5396 | ||
5397 | if (s->use_syslog == 0 && | |
5398 | - !buffer_is_empty(s->access_logfile) && | |
5399 | + s->access_logfile->used > 1 && | |
5400 | s->access_logfile->ptr[0] != '|') { | |
5401 | ||
5402 | close(s->log_access_fd); | |
54b68997 | 5403 | @@ -647,9 +649,12 @@ |
ad6a5263 ER |
5404 | |
5405 | mod_accesslog_patch_connection(srv, con, p); | |
5406 | ||
5407 | + /* No output device, nothing to do */ | |
5408 | + if (!p->conf.use_syslog && p->conf.log_access_fd == -1) return HANDLER_GO_ON; | |
5409 | + | |
5410 | b = p->conf.access_logbuffer; | |
5411 | if (b->used == 0) { | |
54b68997 ER |
5412 | - buffer_copy_string(b, ""); |
5413 | + buffer_copy_string_len(b, CONST_STR_LEN("")); | |
5414 | } | |
5415 | ||
5416 | for (j = 0; j < p->conf.parsed_format->used; j++) { | |
5417 | @@ -674,23 +679,23 @@ | |
5418 | localtime_r(&(srv->cur_ts), &tm); | |
5419 | strftime(p->conf.ts_accesslog_str->ptr, p->conf.ts_accesslog_str->size - 1, "[%d/%b/%Y:%H:%M:%S ", &tm); | |
5420 | # else | |
5421 | - strftime(p->conf.ts_accesslog_str->ptr, p->conf.ts_accesslog_str->size - 1, "[%d/%b/%Y:%H:%M:%S ", localtime_r(&(srv->cur_ts))); | |
5422 | + strftime(p->conf.ts_accesslog_str->ptr, p->conf.ts_accesslog_str->size - 1, "[%d/%b/%Y:%H:%M:%S ", localtime(&(srv->cur_ts))); | |
5423 | # endif | |
5424 | p->conf.ts_accesslog_str->used = strlen(p->conf.ts_accesslog_str->ptr) + 1; | |
5425 | ||
5426 | - buffer_append_string(p->conf.ts_accesslog_str, tm.tm_gmtoff >= 0 ? "+" : "-"); | |
5427 | + buffer_append_string_len(p->conf.ts_accesslog_str, tm.tm_gmtoff >= 0 ? "+" : "-", 1); | |
5428 | ||
5429 | scd = abs(tm.tm_gmtoff); | |
5430 | hrs = scd / 3600; | |
5431 | min = (scd % 3600) / 60; | |
5432 | ||
5433 | /* hours */ | |
5434 | - if (hrs < 10) buffer_append_string(p->conf.ts_accesslog_str, "0"); | |
5435 | + if (hrs < 10) buffer_append_string_len(p->conf.ts_accesslog_str, CONST_STR_LEN("0")); | |
5436 | buffer_append_long(p->conf.ts_accesslog_str, hrs); | |
5437 | ||
5438 | - if (min < 10) buffer_append_string(p->conf.ts_accesslog_str, "0"); | |
5439 | + if (min < 10) buffer_append_string_len(p->conf.ts_accesslog_str, CONST_STR_LEN("0")); | |
5440 | buffer_append_long(p->conf.ts_accesslog_str, min); | |
5441 | - BUFFER_APPEND_STRING_CONST(p->conf.ts_accesslog_str, "]"); | |
5442 | + buffer_append_string_len(p->conf.ts_accesslog_str, CONST_STR_LEN("]")); | |
5443 | #else | |
5444 | #ifdef HAVE_GMTIME_R | |
5445 | gmtime_r(&(srv->cur_ts), &tm); | |
5446 | @@ -717,13 +722,13 @@ | |
5447 | break; | |
5448 | case FORMAT_REMOTE_IDENT: | |
5449 | /* ident */ | |
5450 | - BUFFER_APPEND_STRING_CONST(b, "-"); | |
5451 | + buffer_append_string_len(b, CONST_STR_LEN("-")); | |
5452 | break; | |
5453 | case FORMAT_REMOTE_USER: | |
5454 | if (con->authed_user->used > 1) { | |
5455 | buffer_append_string_buffer(b, con->authed_user); | |
5456 | } else { | |
5457 | - BUFFER_APPEND_STRING_CONST(b, "-"); | |
5458 | + buffer_append_string_len(b, CONST_STR_LEN("-")); | |
5459 | } | |
5460 | break; | |
5461 | case FORMAT_REQUEST_LINE: | |
5462 | @@ -740,42 +745,42 @@ | |
5463 | buffer_append_off_t(b, | |
5464 | con->bytes_written - con->bytes_header <= 0 ? 0 : con->bytes_written - con->bytes_header); | |
5465 | } else { | |
5466 | - BUFFER_APPEND_STRING_CONST(b, "-"); | |
5467 | + buffer_append_string_len(b, CONST_STR_LEN("-")); | |
5468 | } | |
5469 | break; | |
5470 | case FORMAT_HEADER: | |
5471 | if (NULL != (ds = (data_string *)array_get_element(con->request.headers, p->conf.parsed_format->ptr[j]->string->ptr))) { | |
5472 | buffer_append_string_buffer(b, ds->value); | |
5473 | } else { | |
5474 | - BUFFER_APPEND_STRING_CONST(b, "-"); | |
5475 | + buffer_append_string_len(b, CONST_STR_LEN("-")); | |
5476 | } | |
5477 | break; | |
5478 | case FORMAT_RESPONSE_HEADER: | |
5479 | if (NULL != (ds = (data_string *)array_get_element(con->response.headers, p->conf.parsed_format->ptr[j]->string->ptr))) { | |
5480 | buffer_append_string_buffer(b, ds->value); | |
5481 | } else { | |
5482 | - BUFFER_APPEND_STRING_CONST(b, "-"); | |
5483 | + buffer_append_string_len(b, CONST_STR_LEN("-")); | |
5484 | } | |
5485 | break; | |
5486 | case FORMAT_FILENAME: | |
5487 | if (con->physical.path->used > 1) { | |
5488 | buffer_append_string_buffer(b, con->physical.path); | |
5489 | } else { | |
5490 | - BUFFER_APPEND_STRING_CONST(b, "-"); | |
5491 | + buffer_append_string_len(b, CONST_STR_LEN("-")); | |
5492 | } | |
5493 | break; | |
5494 | case FORMAT_BYTES_OUT: | |
5495 | if (con->bytes_written > 0) { | |
5496 | buffer_append_off_t(b, con->bytes_written); | |
5497 | } else { | |
5498 | - BUFFER_APPEND_STRING_CONST(b, "-"); | |
5499 | + buffer_append_string_len(b, CONST_STR_LEN("-")); | |
5500 | } | |
5501 | break; | |
5502 | case FORMAT_BYTES_IN: | |
5503 | if (con->bytes_read > 0) { | |
5504 | buffer_append_off_t(b, con->bytes_read); | |
5505 | } else { | |
5506 | - BUFFER_APPEND_STRING_CONST(b, "-"); | |
5507 | + buffer_append_string_len(b, CONST_STR_LEN("-")); | |
5508 | } | |
5509 | break; | |
5510 | case FORMAT_TIME_USED: | |
5511 | @@ -785,28 +790,35 @@ | |
5512 | if (con->server_name->used > 1) { | |
5513 | buffer_append_string_buffer(b, con->server_name); | |
5514 | } else { | |
5515 | - BUFFER_APPEND_STRING_CONST(b, "-"); | |
5516 | + buffer_append_string_len(b, CONST_STR_LEN("-")); | |
5517 | } | |
5518 | break; | |
5519 | case FORMAT_HTTP_HOST: | |
5520 | if (con->uri.authority->used > 1) { | |
5521 | buffer_append_string_buffer(b, con->uri.authority); | |
5522 | } else { | |
5523 | - BUFFER_APPEND_STRING_CONST(b, "-"); | |
5524 | + buffer_append_string_len(b, CONST_STR_LEN("-")); | |
5525 | } | |
5526 | break; | |
5527 | case FORMAT_REQUEST_PROTOCOL: | |
5528 | - buffer_append_string(b, | |
5529 | - con->request.http_version == HTTP_VERSION_1_1 ? "HTTP/1.1" : "HTTP/1.0"); | |
5530 | + buffer_append_string_len(b, | |
5531 | + con->request.http_version == HTTP_VERSION_1_1 ? "HTTP/1.1" : "HTTP/1.0", 8); | |
5532 | break; | |
5533 | case FORMAT_REQUEST_METHOD: | |
5534 | buffer_append_string(b, get_http_method_name(con->request.http_method)); | |
5535 | break; | |
5536 | case FORMAT_PERCENT: | |
5537 | - buffer_append_string(b, "%"); | |
5538 | + buffer_append_string_len(b, CONST_STR_LEN("%")); | |
ad6a5263 ER |
5539 | break; |
5540 | case FORMAT_SERVER_PORT: | |
5541 | - buffer_append_long(b, srv->srvconf.port); | |
5542 | + { | |
5543 | + char *colon = strchr(((server_socket*)(con->srv_socket))->srv_token->ptr, ':'); | |
5544 | + if (colon) { | |
5545 | + buffer_append_string(b, colon+1); | |
5546 | + } else { | |
5547 | + buffer_append_long(b, srv->srvconf.port); | |
5548 | + } | |
5549 | + } | |
5550 | break; | |
5551 | case FORMAT_QUERY_STRING: | |
5552 | buffer_append_string_buffer(b, con->uri.query); | |
54b68997 ER |
5553 | @@ -816,8 +828,8 @@ |
5554 | break; | |
5555 | case FORMAT_CONNECTION_STATUS: | |
5556 | switch(con->keep_alive) { | |
5557 | - case 0: buffer_append_string(b, "-"); break; | |
5558 | - default: buffer_append_string(b, "+"); break; | |
5559 | + case 0: buffer_append_string_len(b, CONST_STR_LEN("-")); break; | |
5560 | + default: buffer_append_string_len(b, CONST_STR_LEN("+")); break; | |
5561 | } | |
5562 | break; | |
5563 | default: | |
5564 | @@ -837,7 +849,7 @@ | |
5565 | } | |
5566 | } | |
5567 | ||
5568 | - BUFFER_APPEND_STRING_CONST(b, "\n"); | |
5569 | + buffer_append_string_len(b, CONST_STR_LEN("\n")); | |
5570 | ||
5571 | if (p->conf.use_syslog || /* syslog doesn't cache */ | |
5572 | (p->conf.access_logfile->used && p->conf.access_logfile->ptr[0] == '|') || /* pipes don't cache */ | |
5573 | @@ -847,7 +859,7 @@ | |
5574 | #ifdef HAVE_SYSLOG_H | |
5575 | if (b->used > 2) { | |
5576 | /* syslog appends a \n on its own */ | |
5577 | - syslog(LOG_INFO, "%*s", b->used - 2, b->ptr); | |
5578 | + syslog(LOG_INFO, "%*s", (int) b->used - 2, b->ptr); | |
5579 | } | |
5580 | #endif | |
5581 | } else if (p->conf.log_access_fd != -1) { | |
ad6a5263 ER |
5582 | Index: src/server.c |
5583 | =================================================================== | |
54b68997 ER |
5584 | --- src/server.c (.../tags/lighttpd-1.4.19) (revision 2303) |
5585 | +++ src/server.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
5586 | @@ -80,7 +80,7 @@ | |
5587 | switch (sig) { | |
5588 | case SIGTERM: | |
5589 | srv_shutdown = 1; | |
5590 | - memcpy(&last_sigterm_info, si, sizeof(*si)); | |
5591 | + last_sigterm_info = *si; | |
5592 | break; | |
5593 | case SIGINT: | |
5594 | if (graceful_shutdown) { | |
5595 | @@ -88,7 +88,7 @@ | |
5596 | } else { | |
5597 | graceful_shutdown = 1; | |
5598 | } | |
5599 | - memcpy(&last_sigterm_info, si, sizeof(*si)); | |
5600 | + last_sigterm_info = *si; | |
5601 | ||
5602 | break; | |
5603 | case SIGALRM: | |
5604 | @@ -104,7 +104,7 @@ | |
5605 | */ | |
5606 | if (!forwarded_sig_hup) { | |
5607 | handle_sig_hup = 1; | |
5608 | - memcpy(&last_sighup_info, si, sizeof(*si)); | |
5609 | + last_sighup_info = *si; | |
5610 | } else { | |
5611 | forwarded_sig_hup = 0; | |
5612 | } | |
ad6a5263 ER |
5613 | @@ -573,20 +573,9 @@ |
5614 | } | |
5615 | ||
5616 | /* close stdin and stdout, as they are not needed */ | |
5617 | - /* move stdin to /dev/null */ | |
5618 | - if (-1 != (fd = open("/dev/null", O_RDONLY))) { | |
5619 | - close(STDIN_FILENO); | |
5620 | - dup2(fd, STDIN_FILENO); | |
5621 | - close(fd); | |
5622 | - } | |
5623 | + openDevNull(STDIN_FILENO); | |
5624 | + openDevNull(STDOUT_FILENO); | |
5625 | ||
5626 | - /* move stdout to /dev/null */ | |
5627 | - if (-1 != (fd = open("/dev/null", O_WRONLY))) { | |
5628 | - close(STDOUT_FILENO); | |
5629 | - dup2(fd, STDOUT_FILENO); | |
5630 | - close(fd); | |
5631 | - } | |
5632 | - | |
5633 | if (0 != config_set_defaults(srv)) { | |
5634 | log_error_write(srv, __FILE__, __LINE__, "s", | |
5635 | "setting default values failed"); | |
54b68997 ER |
5636 | @@ -887,14 +876,14 @@ |
5637 | /* write pid file */ | |
5638 | if (pid_fd != -1) { | |
5639 | buffer_copy_long(srv->tmp_buf, getpid()); | |
5640 | - buffer_append_string(srv->tmp_buf, "\n"); | |
5641 | + buffer_append_string_len(srv->tmp_buf, CONST_STR_LEN("\n")); | |
5642 | write(pid_fd, srv->tmp_buf->ptr, srv->tmp_buf->used - 1); | |
5643 | close(pid_fd); | |
ad6a5263 ER |
5644 | pid_fd = -1; |
5645 | } | |
5646 | ||
5647 | - // Close stderr ASAP in the child process to make sure that nothing | |
5648 | - // is being written to that fd which may not be valid anymore. | |
5649 | + /* Close stderr ASAP in the child process to make sure that nothing | |
5650 | + * is being written to that fd which may not be valid anymore. */ | |
5651 | if (-1 == log_error_open(srv)) { | |
5652 | log_error_write(srv, __FILE__, __LINE__, "s", "Opening errorlog failed. Going down."); | |
5653 | ||
5654 | Index: src/mod_dirlisting.c | |
5655 | =================================================================== | |
54b68997 ER |
5656 | --- src/mod_dirlisting.c (.../tags/lighttpd-1.4.19) (revision 2303) |
5657 | +++ src/mod_dirlisting.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
5658 | @@ -454,21 +454,21 @@ | |
5659 | static void http_list_directory_header(server *srv, connection *con, plugin_data *p, buffer *out) { | |
5660 | UNUSED(srv); | |
5661 | ||
5662 | - BUFFER_APPEND_STRING_CONST(out, | |
5663 | + buffer_append_string_len(out, CONST_STR_LEN( | |
5664 | "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n" | |
5665 | "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">\n" | |
5666 | "<head>\n" | |
5667 | "<title>Index of " | |
5668 | - ); | |
5669 | + )); | |
5670 | buffer_append_string_encoded(out, CONST_BUF_LEN(con->uri.path), ENCODING_MINIMAL_XML); | |
5671 | - BUFFER_APPEND_STRING_CONST(out, "</title>\n"); | |
5672 | + buffer_append_string_len(out, CONST_STR_LEN("</title>\n")); | |
5673 | ||
5674 | if (p->conf.external_css->used > 1) { | |
5675 | - BUFFER_APPEND_STRING_CONST(out, "<link rel=\"stylesheet\" type=\"text/css\" href=\""); | |
5676 | + buffer_append_string_len(out, CONST_STR_LEN("<link rel=\"stylesheet\" type=\"text/css\" href=\"")); | |
5677 | buffer_append_string_buffer(out, p->conf.external_css); | |
5678 | - BUFFER_APPEND_STRING_CONST(out, "\" />\n"); | |
5679 | + buffer_append_string_len(out, CONST_STR_LEN("\" />\n")); | |
5680 | } else { | |
5681 | - BUFFER_APPEND_STRING_CONST(out, | |
5682 | + buffer_append_string_len(out, CONST_STR_LEN( | |
5683 | "<style type=\"text/css\">\n" | |
5684 | "a, a:active {text-decoration: none; color: blue;}\n" | |
5685 | "a:visited {color: #48468F;}\n" | |
5686 | @@ -485,8 +485,6 @@ | |
5687 | " padding-right: 14px;" | |
5688 | " padding-bottom: 3px;" | |
5689 | "}\n" | |
5690 | - ); | |
5691 | - BUFFER_APPEND_STRING_CONST(out, | |
5692 | "td {padding-right: 14px;}\n" | |
5693 | "td.s, th.s {text-align: right;}\n" | |
5694 | "div.list {" | |
5695 | @@ -502,10 +500,10 @@ | |
5696 | " padding-top: 4px;" | |
5697 | "}\n" | |
5698 | "</style>\n" | |
5699 | - ); | |
5700 | + )); | |
5701 | } | |
5702 | ||
5703 | - BUFFER_APPEND_STRING_CONST(out, "</head>\n<body>\n"); | |
5704 | + buffer_append_string_len(out, CONST_STR_LEN("</head>\n<body>\n")); | |
5705 | ||
5706 | /* HEADER.txt */ | |
5707 | if (p->conf.show_header) { | |
5708 | @@ -514,19 +512,19 @@ | |
5709 | ||
5710 | buffer_copy_string_buffer(p->tmp_buf, con->physical.path); | |
5711 | BUFFER_APPEND_SLASH(p->tmp_buf); | |
5712 | - BUFFER_APPEND_STRING_CONST(p->tmp_buf, "HEADER.txt"); | |
5713 | + buffer_append_string_len(p->tmp_buf, CONST_STR_LEN("HEADER.txt")); | |
5714 | ||
5715 | if (-1 != stream_open(&s, p->tmp_buf)) { | |
5716 | - BUFFER_APPEND_STRING_CONST(out, "<pre class=\"header\">"); | |
5717 | + buffer_append_string_len(out, CONST_STR_LEN("<pre class=\"header\">")); | |
5718 | buffer_append_string_encoded(out, s.start, s.size, ENCODING_MINIMAL_XML); | |
5719 | - BUFFER_APPEND_STRING_CONST(out, "</pre>"); | |
5720 | + buffer_append_string_len(out, CONST_STR_LEN("</pre>")); | |
5721 | } | |
5722 | stream_close(&s); | |
5723 | } | |
5724 | ||
5725 | - BUFFER_APPEND_STRING_CONST(out, "<h2>Index of "); | |
5726 | + buffer_append_string_len(out, CONST_STR_LEN("<h2>Index of ")); | |
5727 | buffer_append_string_encoded(out, CONST_BUF_LEN(con->uri.path), ENCODING_MINIMAL_XML); | |
5728 | - BUFFER_APPEND_STRING_CONST(out, | |
5729 | + buffer_append_string_len(out, CONST_STR_LEN( | |
5730 | "</h2>\n" | |
5731 | "<div class=\"list\">\n" | |
5732 | "<table summary=\"Directory Listing\" cellpadding=\"0\" cellspacing=\"0\">\n" | |
5733 | @@ -545,17 +543,17 @@ | |
5734 | "<td class=\"s\">- </td>" | |
5735 | "<td class=\"t\">Directory</td>" | |
5736 | "</tr>\n" | |
5737 | - ); | |
5738 | + )); | |
5739 | } | |
5740 | ||
5741 | static void http_list_directory_footer(server *srv, connection *con, plugin_data *p, buffer *out) { | |
5742 | UNUSED(srv); | |
5743 | ||
5744 | - BUFFER_APPEND_STRING_CONST(out, | |
5745 | + buffer_append_string_len(out, CONST_STR_LEN( | |
5746 | "</tbody>\n" | |
5747 | "</table>\n" | |
5748 | "</div>\n" | |
5749 | - ); | |
5750 | + )); | |
5751 | ||
5752 | if (p->conf.show_readme) { | |
5753 | stream s; | |
5754 | @@ -563,33 +561,33 @@ | |
5755 | ||
5756 | buffer_copy_string_buffer(p->tmp_buf, con->physical.path); | |
5757 | BUFFER_APPEND_SLASH(p->tmp_buf); | |
5758 | - BUFFER_APPEND_STRING_CONST(p->tmp_buf, "README.txt"); | |
5759 | + buffer_append_string_len(p->tmp_buf, CONST_STR_LEN("README.txt")); | |
5760 | ||
5761 | if (-1 != stream_open(&s, p->tmp_buf)) { | |
5762 | - BUFFER_APPEND_STRING_CONST(out, "<pre class=\"readme\">"); | |
5763 | + buffer_append_string_len(out, CONST_STR_LEN("<pre class=\"readme\">")); | |
5764 | buffer_append_string_encoded(out, s.start, s.size, ENCODING_MINIMAL_XML); | |
5765 | - BUFFER_APPEND_STRING_CONST(out, "</pre>"); | |
5766 | + buffer_append_string_len(out, CONST_STR_LEN("</pre>")); | |
5767 | } | |
5768 | stream_close(&s); | |
5769 | } | |
5770 | ||
5771 | - BUFFER_APPEND_STRING_CONST(out, | |
5772 | + buffer_append_string_len(out, CONST_STR_LEN( | |
5773 | "<div class=\"foot\">" | |
5774 | - ); | |
5775 | + )); | |
5776 | ||
5777 | if (p->conf.set_footer->used > 1) { | |
5778 | buffer_append_string_buffer(out, p->conf.set_footer); | |
5779 | } else if (buffer_is_empty(con->conf.server_tag)) { | |
5780 | - BUFFER_APPEND_STRING_CONST(out, PACKAGE_NAME "/" PACKAGE_VERSION); | |
5781 | + buffer_append_string_len(out, CONST_STR_LEN(PACKAGE_NAME "/" PACKAGE_VERSION)); | |
5782 | } else { | |
5783 | buffer_append_string_buffer(out, con->conf.server_tag); | |
5784 | } | |
5785 | ||
5786 | - BUFFER_APPEND_STRING_CONST(out, | |
5787 | + buffer_append_string_len(out, CONST_STR_LEN( | |
5788 | "</div>\n" | |
5789 | "</body>\n" | |
5790 | "</html>\n" | |
5791 | - ); | |
5792 | + )); | |
5793 | } | |
5794 | ||
5795 | static int http_list_directory(server *srv, connection *con, plugin_data *p, buffer *dir) { | |
5796 | @@ -742,13 +740,13 @@ | |
5797 | if (files.used) http_dirls_sort(files.ent, files.used); | |
5798 | ||
5799 | out = chunkqueue_get_append_buffer(con->write_queue); | |
5800 | - BUFFER_COPY_STRING_CONST(out, "<?xml version=\"1.0\" encoding=\""); | |
5801 | + buffer_copy_string_len(out, CONST_STR_LEN("<?xml version=\"1.0\" encoding=\"")); | |
5802 | if (buffer_is_empty(p->conf.encoding)) { | |
5803 | - BUFFER_APPEND_STRING_CONST(out, "iso-8859-1"); | |
5804 | + buffer_append_string_len(out, CONST_STR_LEN("iso-8859-1")); | |
5805 | } else { | |
5806 | buffer_append_string_buffer(out, p->conf.encoding); | |
5807 | } | |
5808 | - BUFFER_APPEND_STRING_CONST(out, "\"?>\n"); | |
5809 | + buffer_append_string_len(out, CONST_STR_LEN("\"?>\n")); | |
5810 | http_list_directory_header(srv, con, p, out); | |
5811 | ||
5812 | /* directories */ | |
5813 | @@ -762,13 +760,13 @@ | |
5814 | strftime(datebuf, sizeof(datebuf), "%Y-%b-%d %H:%M:%S", localtime(&(tmp->mtime))); | |
5815 | #endif | |
5816 | ||
5817 | - BUFFER_APPEND_STRING_CONST(out, "<tr><td class=\"n\"><a href=\""); | |
5818 | + buffer_append_string_len(out, CONST_STR_LEN("<tr><td class=\"n\"><a href=\"")); | |
5819 | buffer_append_string_encoded(out, DIRLIST_ENT_NAME(tmp), tmp->namelen, ENCODING_REL_URI_PART); | |
5820 | - BUFFER_APPEND_STRING_CONST(out, "/\">"); | |
5821 | + buffer_append_string_len(out, CONST_STR_LEN("/\">")); | |
5822 | buffer_append_string_encoded(out, DIRLIST_ENT_NAME(tmp), tmp->namelen, ENCODING_MINIMAL_XML); | |
5823 | - BUFFER_APPEND_STRING_CONST(out, "</a>/</td><td class=\"m\">"); | |
5824 | + buffer_append_string_len(out, CONST_STR_LEN("</a>/</td><td class=\"m\">")); | |
5825 | buffer_append_string_len(out, datebuf, sizeof(datebuf) - 1); | |
5826 | - BUFFER_APPEND_STRING_CONST(out, "</td><td class=\"s\">- </td><td class=\"t\">Directory</td></tr>\n"); | |
5827 | + buffer_append_string_len(out, CONST_STR_LEN("</td><td class=\"s\">- </td><td class=\"t\">Directory</td></tr>\n")); | |
5828 | ||
5829 | free(tmp); | |
5830 | } | |
5831 | @@ -818,17 +816,17 @@ | |
5832 | #endif | |
5833 | http_list_directory_sizefmt(sizebuf, tmp->size); | |
5834 | ||
5835 | - BUFFER_APPEND_STRING_CONST(out, "<tr><td class=\"n\"><a href=\""); | |
5836 | + buffer_append_string_len(out, CONST_STR_LEN("<tr><td class=\"n\"><a href=\"")); | |
5837 | buffer_append_string_encoded(out, DIRLIST_ENT_NAME(tmp), tmp->namelen, ENCODING_REL_URI_PART); | |
5838 | - BUFFER_APPEND_STRING_CONST(out, "\">"); | |
5839 | + buffer_append_string_len(out, CONST_STR_LEN("\">")); | |
5840 | buffer_append_string_encoded(out, DIRLIST_ENT_NAME(tmp), tmp->namelen, ENCODING_MINIMAL_XML); | |
5841 | - BUFFER_APPEND_STRING_CONST(out, "</a></td><td class=\"m\">"); | |
5842 | + buffer_append_string_len(out, CONST_STR_LEN("</a></td><td class=\"m\">")); | |
5843 | buffer_append_string_len(out, datebuf, sizeof(datebuf) - 1); | |
5844 | - BUFFER_APPEND_STRING_CONST(out, "</td><td class=\"s\">"); | |
5845 | + buffer_append_string_len(out, CONST_STR_LEN("</td><td class=\"s\">")); | |
5846 | buffer_append_string(out, sizebuf); | |
5847 | - BUFFER_APPEND_STRING_CONST(out, "</td><td class=\"t\">"); | |
5848 | + buffer_append_string_len(out, CONST_STR_LEN("</td><td class=\"t\">")); | |
5849 | buffer_append_string(out, content_type); | |
5850 | - BUFFER_APPEND_STRING_CONST(out, "</td></tr>\n"); | |
5851 | + buffer_append_string_len(out, CONST_STR_LEN("</td></tr>\n")); | |
5852 | ||
5853 | free(tmp); | |
5854 | } | |
5855 | @@ -841,11 +839,11 @@ | |
ad6a5263 ER |
5856 | |
5857 | /* Insert possible charset to Content-Type */ | |
5858 | if (buffer_is_empty(p->conf.encoding)) { | |
5859 | - response_header_insert(srv, con, CONST_STR_LEN("Content-Type"), CONST_STR_LEN("text/html")); | |
5860 | + response_header_overwrite(srv, con, CONST_STR_LEN("Content-Type"), CONST_STR_LEN("text/html")); | |
5861 | } else { | |
54b68997 ER |
5862 | - buffer_copy_string(p->content_charset, "text/html; charset="); |
5863 | + buffer_copy_string_len(p->content_charset, CONST_STR_LEN("text/html; charset=")); | |
ad6a5263 ER |
5864 | buffer_append_string_buffer(p->content_charset, p->conf.encoding); |
5865 | - response_header_insert(srv, con, CONST_STR_LEN("Content-Type"), CONST_BUF_LEN(p->content_charset)); | |
5866 | + response_header_overwrite(srv, con, CONST_STR_LEN("Content-Type"), CONST_BUF_LEN(p->content_charset)); | |
5867 | } | |
5868 | ||
5869 | con->file_finished = 1; | |
54b68997 ER |
5870 | @@ -861,6 +859,18 @@ |
5871 | ||
5872 | UNUSED(srv); | |
5873 | ||
5874 | + /* we only handle GET, POST and HEAD */ | |
5875 | + switch(con->request.http_method) { | |
5876 | + case HTTP_METHOD_GET: | |
5877 | + case HTTP_METHOD_POST: | |
5878 | + case HTTP_METHOD_HEAD: | |
5879 | + break; | |
5880 | + default: | |
5881 | + return HANDLER_GO_ON; | |
5882 | + } | |
5883 | + | |
5884 | + if (con->mode != DIRECT) return HANDLER_GO_ON; | |
5885 | + | |
5886 | if (con->physical.path->used == 0) return HANDLER_GO_ON; | |
5887 | if (con->uri.path->used == 0) return HANDLER_GO_ON; | |
5888 | if (con->uri.path->ptr[con->uri.path->used - 2] != '/') return HANDLER_GO_ON; | |
5889 | Index: src/http_chunk.c | |
5890 | =================================================================== | |
5891 | --- src/http_chunk.c (.../tags/lighttpd-1.4.19) (revision 2303) | |
5892 | +++ src/http_chunk.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
5893 | @@ -27,7 +27,7 @@ | |
5894 | b = srv->tmp_chunk_len; | |
5895 | ||
5896 | if (len == 0) { | |
5897 | - buffer_copy_string(b, "0"); | |
5898 | + buffer_copy_string_len(b, CONST_STR_LEN("0")); | |
5899 | } else { | |
5900 | for (i = 0; i < 8 && len; i++) { | |
5901 | len >>= 4; | |
5902 | @@ -44,7 +44,7 @@ | |
5903 | b->ptr[b->used++] = '\0'; | |
5904 | } | |
5905 | ||
5906 | - buffer_append_string(b, "\r\n"); | |
5907 | + buffer_append_string_len(b, CONST_STR_LEN("\r\n")); | |
5908 | chunkqueue_append_buffer(con->write_queue, b); | |
5909 | ||
5910 | return 0; | |
49b4da39 ER |
5911 | Index: src/mod_magnet.c |
5912 | =================================================================== | |
54b68997 ER |
5913 | --- src/mod_magnet.c (.../tags/lighttpd-1.4.19) (revision 2303) |
5914 | +++ src/mod_magnet.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
49b4da39 ER |
5915 | @@ -414,10 +414,16 @@ |
5916 | case MAGNET_ENV_URI_AUTHORITY: dest = con->uri.authority; break; | |
5917 | case MAGNET_ENV_URI_QUERY: dest = con->uri.query; break; | |
5918 | ||
5919 | - case MAGNET_ENV_REQUEST_METHOD: break; | |
5920 | + case MAGNET_ENV_REQUEST_METHOD: | |
5921 | + buffer_copy_string(srv->tmp_buf, get_http_method_name(con->request.http_method)); | |
5922 | + dest = srv->tmp_buf; | |
5923 | + break; | |
5924 | case MAGNET_ENV_REQUEST_URI: dest = con->request.uri; break; | |
5925 | case MAGNET_ENV_REQUEST_ORIG_URI: dest = con->request.orig_uri; break; | |
5926 | - case MAGNET_ENV_REQUEST_PROTOCOL: break; | |
5927 | + case MAGNET_ENV_REQUEST_PROTOCOL: | |
5928 | + buffer_copy_string(srv->tmp_buf, get_http_version_name(con->request.http_version)); | |
5929 | + dest = srv->tmp_buf; | |
5930 | + break; | |
a34aaa25 | 5931 | |
49b4da39 | 5932 | case MAGNET_ENV_UNSET: break; |
a34aaa25 | 5933 | } |
54b68997 ER |
5934 | @@ -647,6 +653,7 @@ |
5935 | assert(lua_gettop(L) == 0); /* only the function should be on the stack */ | |
ad6a5263 | 5936 | |
54b68997 ER |
5937 | con->http_status = 500; |
5938 | + con->mode = DIRECT; | |
5939 | ||
5940 | return HANDLER_FINISHED; | |
5941 | } | |
5942 | @@ -744,6 +751,7 @@ | |
5943 | assert(lua_gettop(L) == 1); /* only the function should be on the stack */ | |
ad6a5263 | 5944 | |
54b68997 ER |
5945 | con->http_status = 500; |
5946 | + con->mode = DIRECT; | |
5947 | ||
5948 | return HANDLER_FINISHED; | |
5949 | } | |
5950 | @@ -766,9 +774,13 @@ | |
ad6a5263 ER |
5951 | /* try { ...*/ |
5952 | if (0 == setjmp(exceptionjmp)) { | |
5953 | magnet_attach_content(srv, con, p, L); | |
5954 | + if (!chunkqueue_is_empty(con->write_queue)) { | |
5955 | + con->mode = p->id; | |
5956 | + } | |
5957 | } else { | |
5958 | /* } catch () { */ | |
5959 | con->http_status = 500; | |
54b68997 ER |
5960 | + con->mode = DIRECT; |
5961 | } | |
5962 | ||
5963 | assert(lua_gettop(L) == 1); /* only the function should be on the stack */ | |
ad6a5263 ER |
5964 | Index: src/log.c |
5965 | =================================================================== | |
54b68997 ER |
5966 | --- src/log.c (.../tags/lighttpd-1.4.19) (revision 2303) |
5967 | +++ src/log.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
ad6a5263 ER |
5968 | @@ -31,6 +31,29 @@ |
5969 | # define O_LARGEFILE 0 | |
5970 | #endif | |
5971 | ||
5972 | +/* Close fd and _try_ to get a /dev/null for it instead. | |
5973 | + * close() alone may trigger some bugs when a | |
5974 | + * process opens another file and gets fd = STDOUT_FILENO or STDERR_FILENO | |
5975 | + * and later tries to just print on stdout/stderr | |
5976 | + * | |
5977 | + * Returns 0 on success and -1 on failure (fd gets closed in all cases) | |
5978 | + */ | |
5979 | +int openDevNull(int fd) { | |
5980 | + int tmpfd; | |
5981 | + close(fd); | |
5982 | +#if defined(__WIN32) | |
5983 | + /* Cygwin should work with /dev/null */ | |
5984 | + tmpfd = open("nul", O_RDWR); | |
5985 | +#else | |
5986 | + tmpfd = open("/dev/null", O_RDWR); | |
5987 | +#endif | |
5988 | + if (tmpfd != -1 && tmpfd != fd) { | |
5989 | + dup2(tmpfd, fd); | |
5990 | + close(tmpfd); | |
5991 | + } | |
5992 | + return (tmpfd != -1) ? 0 : -1; | |
5993 | +} | |
5994 | + | |
5995 | /** | |
5996 | * open the errorlog | |
5997 | * | |
5998 | @@ -44,7 +67,6 @@ | |
5999 | */ | |
6000 | ||
6001 | int log_error_open(server *srv) { | |
6002 | - int fd; | |
6003 | int close_stderr = 1; | |
6004 | ||
6005 | #ifdef HAVE_SYSLOG_H | |
6006 | @@ -78,15 +100,16 @@ | |
6007 | /* don't close stderr for debugging purposes if run in valgrind */ | |
6008 | if (RUNNING_ON_VALGRIND) close_stderr = 0; | |
6009 | #endif | |
6010 | - if (srv->errorlog_mode == ERRORLOG_STDERR) close_stderr = 0; | |
6011 | ||
6012 | + if (srv->errorlog_mode == ERRORLOG_STDERR && srv->srvconf.dont_daemonize) { | |
6013 | + /* We can only log to stderr in dont-daemonize mode; | |
6014 | + * if we do daemonize and no errorlog file is specified, we log into /dev/null | |
6015 | + */ | |
6016 | + close_stderr = 0; | |
6017 | + } | |
6018 | + | |
6019 | /* move stderr to /dev/null */ | |
6020 | - if (close_stderr && | |
6021 | - -1 != (fd = open("/dev/null", O_WRONLY))) { | |
6022 | - close(STDERR_FILENO); | |
6023 | - dup2(fd, STDERR_FILENO); | |
6024 | - close(fd); | |
6025 | - } | |
6026 | + if (close_stderr) openDevNull(STDERR_FILENO); | |
6027 | return 0; | |
6028 | } | |
6029 | ||
54b68997 ER |
6030 | @@ -162,18 +185,18 @@ |
6031 | } | |
6032 | ||
6033 | buffer_copy_string_buffer(srv->errorlog_buf, srv->ts_debug_str); | |
6034 | - BUFFER_APPEND_STRING_CONST(srv->errorlog_buf, ": ("); | |
6035 | + buffer_append_string_len(srv->errorlog_buf, CONST_STR_LEN(": (")); | |
6036 | break; | |
6037 | case ERRORLOG_SYSLOG: | |
6038 | /* syslog is generating its own timestamps */ | |
6039 | - BUFFER_COPY_STRING_CONST(srv->errorlog_buf, "("); | |
6040 | + buffer_copy_string_len(srv->errorlog_buf, CONST_STR_LEN("(")); | |
6041 | break; | |
6042 | } | |
6043 | ||
6044 | buffer_append_string(srv->errorlog_buf, filename); | |
6045 | - BUFFER_APPEND_STRING_CONST(srv->errorlog_buf, "."); | |
6046 | + buffer_append_string_len(srv->errorlog_buf, CONST_STR_LEN(".")); | |
6047 | buffer_append_long(srv->errorlog_buf, line); | |
6048 | - BUFFER_APPEND_STRING_CONST(srv->errorlog_buf, ") "); | |
6049 | + buffer_append_string_len(srv->errorlog_buf, CONST_STR_LEN(") ")); | |
6050 | ||
6051 | ||
6052 | for(va_start(ap, fmt); *fmt; fmt++) { | |
6053 | @@ -186,28 +209,28 @@ | |
6054 | case 's': /* string */ | |
6055 | s = va_arg(ap, char *); | |
6056 | buffer_append_string(srv->errorlog_buf, s); | |
6057 | - BUFFER_APPEND_STRING_CONST(srv->errorlog_buf, " "); | |
6058 | + buffer_append_string_len(srv->errorlog_buf, CONST_STR_LEN(" ")); | |
6059 | break; | |
6060 | case 'b': /* buffer */ | |
6061 | b = va_arg(ap, buffer *); | |
6062 | buffer_append_string_buffer(srv->errorlog_buf, b); | |
6063 | - BUFFER_APPEND_STRING_CONST(srv->errorlog_buf, " "); | |
6064 | + buffer_append_string_len(srv->errorlog_buf, CONST_STR_LEN(" ")); | |
6065 | break; | |
6066 | case 'd': /* int */ | |
6067 | d = va_arg(ap, int); | |
6068 | buffer_append_long(srv->errorlog_buf, d); | |
6069 | - BUFFER_APPEND_STRING_CONST(srv->errorlog_buf, " "); | |
6070 | + buffer_append_string_len(srv->errorlog_buf, CONST_STR_LEN(" ")); | |
6071 | break; | |
6072 | case 'o': /* off_t */ | |
6073 | o = va_arg(ap, off_t); | |
6074 | buffer_append_off_t(srv->errorlog_buf, o); | |
6075 | - BUFFER_APPEND_STRING_CONST(srv->errorlog_buf, " "); | |
6076 | + buffer_append_string_len(srv->errorlog_buf, CONST_STR_LEN(" ")); | |
6077 | break; | |
6078 | case 'x': /* int (hex) */ | |
6079 | d = va_arg(ap, int); | |
6080 | - BUFFER_APPEND_STRING_CONST(srv->errorlog_buf, "0x"); | |
6081 | + buffer_append_string_len(srv->errorlog_buf, CONST_STR_LEN("0x")); | |
6082 | buffer_append_long_hex(srv->errorlog_buf, d); | |
6083 | - BUFFER_APPEND_STRING_CONST(srv->errorlog_buf, " "); | |
6084 | + buffer_append_string_len(srv->errorlog_buf, CONST_STR_LEN(" ")); | |
6085 | break; | |
6086 | case 'S': /* string */ | |
6087 | s = va_arg(ap, char *); | |
6088 | @@ -221,6 +244,15 @@ | |
6089 | d = va_arg(ap, int); | |
6090 | buffer_append_long(srv->errorlog_buf, d); | |
6091 | break; | |
6092 | + case 'O': /* off_t */ | |
6093 | + o = va_arg(ap, off_t); | |
6094 | + buffer_append_off_t(srv->errorlog_buf, o); | |
6095 | + break; | |
6096 | + case 'X': /* int (hex) */ | |
6097 | + d = va_arg(ap, int); | |
6098 | + buffer_append_string_len(srv->errorlog_buf, CONST_STR_LEN("0x")); | |
6099 | + buffer_append_long_hex(srv->errorlog_buf, d); | |
6100 | + break; | |
6101 | case '(': | |
6102 | case ')': | |
6103 | case '<': | |
6104 | @@ -235,11 +267,11 @@ | |
6105 | ||
6106 | switch(srv->errorlog_mode) { | |
6107 | case ERRORLOG_FILE: | |
6108 | - BUFFER_APPEND_STRING_CONST(srv->errorlog_buf, "\n"); | |
6109 | + buffer_append_string_len(srv->errorlog_buf, CONST_STR_LEN("\n")); | |
6110 | write(srv->errorlog_fd, srv->errorlog_buf->ptr, srv->errorlog_buf->used - 1); | |
6111 | break; | |
6112 | case ERRORLOG_STDERR: | |
6113 | - BUFFER_APPEND_STRING_CONST(srv->errorlog_buf, "\n"); | |
6114 | + buffer_append_string_len(srv->errorlog_buf, CONST_STR_LEN("\n")); | |
6115 | write(STDERR_FILENO, srv->errorlog_buf->ptr, srv->errorlog_buf->used - 1); | |
6116 | break; | |
6117 | case ERRORLOG_SYSLOG: | |
6118 | Index: src/proc_open.c | |
6119 | =================================================================== | |
6120 | --- src/proc_open.c (.../tags/lighttpd-1.4.19) (revision 2303) | |
6121 | +++ src/proc_open.c (.../branches/lighttpd-1.4.x) (revision 2303) | |
6122 | @@ -184,7 +184,7 @@ | |
6123 | buffer_append_string(cmdline, shell); | |
6124 | } else { | |
6125 | buffer_append_string(cmdline, windir); | |
6126 | - buffer_append_string(cmdline, "\\system32\\cmd.exe"); | |
6127 | + buffer_append_string_len(cmdline, CONST_STR_LEN("\\system32\\cmd.exe")); | |
6128 | } | |
6129 | buffer_append_string_len(cmdline, CONST_STR_LEN(" /c ")); | |
6130 | buffer_append_string(cmdline, command); | |
ad6a5263 ER |
6131 | Index: src/log.h |
6132 | =================================================================== | |
54b68997 ER |
6133 | --- src/log.h (.../tags/lighttpd-1.4.19) (revision 2303) |
6134 | +++ src/log.h (.../branches/lighttpd-1.4.x) (revision 2303) | |
ad6a5263 ER |
6135 | @@ -3,6 +3,11 @@ |
6136 | ||
6137 | #include "server.h" | |
6138 | ||
6139 | +/* Close fd and _try_ to get a /dev/null for it instead. | |
6140 | + * Returns 0 on success and -1 on failure (fd gets closed in all cases) | |
6141 | + */ | |
6142 | +int openDevNull(int fd); | |
6143 | + | |
6144 | #define WP() log_error_write(srv, __FILE__, __LINE__, ""); | |
6145 | ||
6146 | int log_error_open(server *srv); | |
54b68997 ER |
6147 | Index: tests/env-variables.conf |
6148 | =================================================================== | |
6149 | --- tests/env-variables.conf (.../tags/lighttpd-1.4.19) (revision 2303) | |
6150 | +++ tests/env-variables.conf (.../branches/lighttpd-1.4.x) (revision 2303) | |
6151 | @@ -1 +0,0 @@ | |
6152 | -server.document-root = env.CWD | |
6153 | Index: tests/env-variables.t | |
6154 | =================================================================== | |
6155 | --- tests/env-variables.t (.../tags/lighttpd-1.4.19) (revision 2303) | |
6156 | +++ tests/env-variables.t (.../branches/lighttpd-1.4.x) (revision 2303) | |
6157 | @@ -1,21 +0,0 @@ | |
6158 | -#!/usr/bin/perl | |
6159 | -BEGIN { | |
6160 | - # add current source dir to the include-path | |
6161 | - # we need this for make distcheck | |
6162 | - (my $srcdir = $0) =~ s,/[^/]+$,/,; | |
6163 | - unshift @INC, $srcdir; | |
6164 | -} | |
6165 | - | |
6166 | -use strict; | |
6167 | -use IO::Socket; | |
6168 | -use Test::More tests => 2; | |
6169 | -use LightyTest; | |
6170 | - | |
6171 | -my $tf = LightyTest->new(); | |
6172 | -$tf->{CONFIGFILE} = 'env-variables.conf'; | |
6173 | - | |
6174 | -TODO: { | |
6175 | - local $TODO = 'we still crash on undefined environment variables'; | |
6176 | - ok($tf->start_proc == 0, "Starting lighttpd"); | |
6177 | - ok($tf->stop_proc == 0, "Stopping lighttpd"); | |
6178 | -}; | |
6179 | Index: tests/bug-12.conf | |
6180 | =================================================================== | |
6181 | --- tests/bug-12.conf (.../tags/lighttpd-1.4.19) (revision 2303) | |
6182 | +++ tests/bug-12.conf (.../branches/lighttpd-1.4.x) (revision 2303) | |
6183 | @@ -1,5 +1,4 @@ | |
6184 | server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/" | |
6185 | -server.pid-file = env.SRCDIR + "/tmp/lighttpd/lighttpd.pid" | |
6186 | ||
6187 | ## bind to port (default: 80) | |
6188 | server.port = 2048 | |
6189 | Index: tests/fastcgi-10.conf | |
6190 | =================================================================== | |
6191 | --- tests/fastcgi-10.conf (.../tags/lighttpd-1.4.19) (revision 2303) | |
6192 | +++ tests/fastcgi-10.conf (.../branches/lighttpd-1.4.x) (revision 2303) | |
6193 | @@ -1,5 +1,4 @@ | |
6194 | server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/" | |
6195 | -server.pid-file = env.SRCDIR + "/tmp/lighttpd/lighttpd.pid" | |
6196 | ||
6197 | ## bind to port (default: 80) | |
6198 | server.port = 2048 | |
6199 | Index: tests/bug-06.conf | |
6200 | =================================================================== | |
6201 | --- tests/bug-06.conf (.../tags/lighttpd-1.4.19) (revision 2303) | |
6202 | +++ tests/bug-06.conf (.../branches/lighttpd-1.4.x) (revision 2303) | |
6203 | @@ -1,5 +1,4 @@ | |
6204 | server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/" | |
6205 | -server.pid-file = env.SRCDIR + "/tmp/lighttpd/lighttpd.pid" | |
6206 | ||
6207 | ## bind to port (default: 80) | |
6208 | server.port = 2048 | |
6209 | Index: tests/mod-extforward.conf | |
6210 | =================================================================== | |
6211 | --- tests/mod-extforward.conf (.../tags/lighttpd-1.4.19) (revision 2303) | |
6212 | +++ tests/mod-extforward.conf (.../branches/lighttpd-1.4.x) (revision 2303) | |
6213 | @@ -3,7 +3,6 @@ | |
6214 | debug.log-request-header = "disable" | |
6215 | ||
6216 | server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/" | |
6217 | -server.pid-file = env.SRCDIR + "/tmp/lighttpd/lighttpd.pid" | |
6218 | ||
6219 | ## bind to port (default: 80) | |
6220 | server.port = 2048 | |
ad6a5263 ER |
6221 | |
6222 | Property changes on: tests/symlink.t | |
6223 | ___________________________________________________________________ | |
54b68997 | 6224 | Added: svn:executable |
ad6a5263 ER |
6225 | + * |
6226 | ||
6227 | Index: tests/request.t | |
6228 | =================================================================== | |
54b68997 ER |
6229 | --- tests/request.t (.../tags/lighttpd-1.4.19) (revision 2303) |
6230 | +++ tests/request.t (.../branches/lighttpd-1.4.x) (revision 2303) | |
ad6a5263 ER |
6231 | @@ -101,7 +101,7 @@ |
6232 | Expect: 100-continue | |
6233 | EOF | |
6234 | ); | |
6235 | -$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 417, '-HTTP-Content' => ''} ]; | |
6236 | +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 417 } ]; | |
6237 | ok($tf->handle_http($t) == 0, 'Continue, Expect'); | |
6238 | ||
6239 | ## ranges | |
54b68997 ER |
6240 | Index: tests/var-include.conf |
6241 | =================================================================== | |
6242 | --- tests/var-include.conf (.../tags/lighttpd-1.4.19) (revision 2303) | |
6243 | +++ tests/var-include.conf (.../branches/lighttpd-1.4.x) (revision 2303) | |
6244 | @@ -3,7 +3,6 @@ | |
6245 | debug.log-condition-handling = "enable" | |
6246 | ||
6247 | server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/" | |
6248 | -server.pid-file = env.SRCDIR + "/tmp/lighttpd/lighttpd.pid" | |
6249 | ||
6250 | ## bind to port (default: 80) | |
6251 | server.port = 2048 | |
6252 | Index: tests/mod-proxy.t | |
6253 | =================================================================== | |
6254 | --- tests/mod-proxy.t (.../tags/lighttpd-1.4.19) (revision 2303) | |
6255 | +++ tests/mod-proxy.t (.../branches/lighttpd-1.4.x) (revision 2303) | |
6256 | @@ -22,11 +22,9 @@ | |
6257 | ||
6258 | $tf_real->{PORT} = 2048; | |
6259 | $tf_real->{CONFIGFILE} = 'lighttpd.conf'; | |
6260 | -$tf_real->{LIGHTTPD_PIDFILE} = $tf_real->{TESTDIR}.'/tmp/lighttpd/lighttpd.pid'; | |
6261 | ||
6262 | $tf_proxy->{PORT} = 2050; | |
6263 | $tf_proxy->{CONFIGFILE} = 'proxy.conf'; | |
6264 | -$tf_proxy->{LIGHTTPD_PIDFILE} = $tf_proxy->{TESTDIR}.'/tmp/lighttpd/lighttpd-proxy.pid'; | |
6265 | ||
6266 | ok($tf_real->start_proc == 0, "Starting lighttpd") or die(); | |
6267 | ||
6268 | Index: tests/404-handler.conf | |
6269 | =================================================================== | |
6270 | --- tests/404-handler.conf (.../tags/lighttpd-1.4.19) (revision 2303) | |
6271 | +++ tests/404-handler.conf (.../branches/lighttpd-1.4.x) (revision 2303) | |
6272 | @@ -3,7 +3,6 @@ | |
6273 | debug.log-request-header = "enable" | |
6274 | ||
6275 | server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/" | |
6276 | -server.pid-file = env.SRCDIR + "/tmp/lighttpd/lighttpd.pid" | |
6277 | ||
6278 | ## bind to port (default: 80) | |
6279 | server.port = 2048 | |
6280 | Index: tests/lowercase.conf | |
6281 | =================================================================== | |
6282 | --- tests/lowercase.conf (.../tags/lighttpd-1.4.19) (revision 2303) | |
6283 | +++ tests/lowercase.conf (.../branches/lighttpd-1.4.x) (revision 2303) | |
6284 | @@ -1,5 +1,4 @@ | |
6285 | server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/" | |
6286 | -server.pid-file = env.SRCDIR + "/tmp/lighttpd/lighttpd.pid" | |
6287 | ||
6288 | ## bind to port (default: 80) | |
6289 | server.port = 2048 | |
6290 | Index: tests/condition.conf | |
6291 | =================================================================== | |
6292 | --- tests/condition.conf (.../tags/lighttpd-1.4.19) (revision 2303) | |
6293 | +++ tests/condition.conf (.../branches/lighttpd-1.4.x) (revision 2303) | |
6294 | @@ -3,7 +3,6 @@ | |
6295 | debug.log-condition-handling = "enable" | |
6296 | ||
6297 | server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/" | |
6298 | -server.pid-file = env.SRCDIR + "/tmp/lighttpd/lighttpd.pid" | |
6299 | ||
6300 | ## bind to port (default: 80) | |
6301 | server.port = 2048 | |
6302 | Index: tests/fastcgi-13.conf | |
6303 | =================================================================== | |
6304 | --- tests/fastcgi-13.conf (.../tags/lighttpd-1.4.19) (revision 2303) | |
6305 | +++ tests/fastcgi-13.conf (.../branches/lighttpd-1.4.x) (revision 2303) | |
6306 | @@ -1,5 +1,4 @@ | |
6307 | server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/" | |
6308 | -server.pid-file = env.SRCDIR + "/tmp/lighttpd/lighttpd.pid" | |
6309 | ||
6310 | debug.log-request-header = "enable" | |
6311 | debug.log-response-header = "enable" | |
6312 | @@ -85,7 +84,7 @@ | |
6313 | "grisu" => ( | |
6314 | "host" => "127.0.0.1", | |
6315 | "port" => 1048, | |
6316 | - "bin-path" => "/usr/bin/php-cgi", | |
6317 | + "bin-path" => env.PHP, | |
6318 | "bin-copy-environment" => ( "PATH", "SHELL", "USER" ), | |
6319 | ) | |
6320 | ) | |
ad6a5263 ER |
6321 | Index: tests/mod-fastcgi.t |
6322 | =================================================================== | |
54b68997 ER |
6323 | --- tests/mod-fastcgi.t (.../tags/lighttpd-1.4.19) (revision 2303) |
6324 | +++ tests/mod-fastcgi.t (.../branches/lighttpd-1.4.x) (revision 2303) | |
6325 | @@ -7,17 +7,27 @@ | |
6326 | } | |
6327 | ||
6328 | use strict; | |
6329 | -use Test::More tests => 47; | |
6330 | +use Test::More tests => 49; | |
6331 | use LightyTest; | |
6332 | ||
6333 | my $tf = LightyTest->new(); | |
6334 | ||
6335 | my $t; | |
6336 | +my $php_child = -1; | |
6337 | ||
6338 | +my $phpbin = (defined $ENV{'PHP'} ? $ENV{'PHP'} : '/usr/bin/php-cgi'); | |
6339 | +$ENV{'PHP'} = $phpbin; | |
6340 | + | |
6341 | SKIP: { | |
6342 | + skip "PHP already running on port 1026", 1 if $tf->listening_on(1026); | |
6343 | + skip "no php binary found", 1 unless -x $phpbin; | |
6344 | + ok(-1 != ($php_child = $tf->spawnfcgi($phpbin, 1026)), "Spawning php"); | |
6345 | +} | |
6346 | + | |
6347 | +SKIP: { | |
6348 | skip "no PHP running on port 1026", 29 unless $tf->listening_on(1026); | |
6349 | ||
6350 | - ok($tf->start_proc == 0, "Starting lighttpd") or die(); | |
6351 | + ok($tf->start_proc == 0, "Starting lighttpd") or goto cleanup; | |
6352 | ||
6353 | $t->{REQUEST} = ( <<EOF | |
6354 | GET /phpinfo.php HTTP/1.0 | |
6355 | @@ -65,7 +75,7 @@ | |
ad6a5263 ER |
6356 | EOF |
6357 | ); | |
6358 | $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '/get-server-env.php' } ]; | |
6359 | - ok($tf->handle_http($t) == 0, '$_SERVER["PHP_SELF"]'); | |
6360 | + ok($tf->handle_http($t) == 0, '$_SERVER["SCRIPT_NAME"]'); | |
6361 | ||
6362 | $t->{REQUEST} = ( <<EOF | |
6363 | GET /get-server-env.php/foo?env=PATH_INFO HTTP/1.0 | |
54b68997 ER |
6364 | @@ -161,7 +171,7 @@ |
6365 | ||
6366 | ||
6367 | $tf->{CONFIGFILE} = 'fastcgi-10.conf'; | |
6368 | - ok($tf->start_proc == 0, "Starting lighttpd with $tf->{CONFIGFILE}") or die(); | |
6369 | + ok($tf->start_proc == 0, "Starting lighttpd with $tf->{CONFIGFILE}") or goto cleanup; | |
6370 | $t->{REQUEST} = ( <<EOF | |
6371 | GET /get-server-env.php?env=SERVER_NAME HTTP/1.0 | |
6372 | Host: zzz.example.org | |
6373 | @@ -173,7 +183,7 @@ | |
6374 | ok($tf->stop_proc == 0, "Stopping lighttpd"); | |
6375 | ||
6376 | $tf->{CONFIGFILE} = 'bug-06.conf'; | |
6377 | - ok($tf->start_proc == 0, "Starting lighttpd with $tf->{CONFIGFILE}") or die(); | |
6378 | + ok($tf->start_proc == 0, "Starting lighttpd with $tf->{CONFIGFILE}") or goto cleanup; | |
6379 | $t->{REQUEST} = ( <<EOF | |
6380 | GET /indexfile/ HTTP/1.0 | |
6381 | Host: www.example.org | |
6382 | @@ -185,7 +195,7 @@ | |
6383 | ok($tf->stop_proc == 0, "Stopping lighttpd"); | |
6384 | ||
6385 | $tf->{CONFIGFILE} = 'bug-12.conf'; | |
6386 | - ok($tf->start_proc == 0, "Starting lighttpd with bug-12.conf") or die(); | |
6387 | + ok($tf->start_proc == 0, "Starting lighttpd with bug-12.conf") or goto cleanup; | |
6388 | $t->{REQUEST} = ( <<EOF | |
6389 | POST /indexfile/abc HTTP/1.0 | |
6390 | Host: www.example.org | |
6391 | @@ -199,6 +209,12 @@ | |
6392 | } | |
6393 | ||
6394 | SKIP: { | |
6395 | + skip "PHP not started, cannot stop it", 1 unless $php_child != -1; | |
6396 | + ok(0 == $tf->endspawnfcgi($php_child), "Stopping php"); | |
6397 | + $php_child = -1; | |
6398 | +} | |
6399 | + | |
6400 | +SKIP: { | |
6401 | skip "no fcgi-auth found", 4 unless -x $tf->{BASEDIR}."/tests/fcgi-auth" || -x $tf->{BASEDIR}."/tests/fcgi-auth.exe"; | |
6402 | ||
6403 | $tf->{CONFIGFILE} = 'fastcgi-auth.conf'; | |
6404 | @@ -223,7 +239,7 @@ | |
6405 | } | |
6406 | ||
6407 | SKIP: { | |
6408 | - skip "no php found", 5 unless -x "/usr/bin/php-cgi"; | |
6409 | + skip "no php found", 5 unless -x $phpbin; | |
6410 | $tf->{CONFIGFILE} = 'fastcgi-13.conf'; | |
6411 | ok($tf->start_proc == 0, "Starting lighttpd with $tf->{CONFIGFILE}") or die(); | |
6412 | $t->{REQUEST} = ( <<EOF | |
6413 | @@ -325,3 +341,10 @@ | |
6414 | ok($tf->stop_proc == 0, "Stopping lighttpd"); | |
6415 | } | |
6416 | ||
6417 | +exit 0; | |
6418 | + | |
6419 | +cleanup: ; | |
6420 | + | |
6421 | +$tf->endspawnfcgi($php_child) if $php_child != -1; | |
6422 | + | |
6423 | +die(); | |
6424 | Index: tests/mod-rewrite.t | |
6425 | =================================================================== | |
6426 | --- tests/mod-rewrite.t (.../tags/lighttpd-1.4.19) (revision 2303) | |
6427 | +++ tests/mod-rewrite.t (.../branches/lighttpd-1.4.x) (revision 2303) | |
6428 | @@ -8,18 +8,26 @@ | |
6429 | ||
6430 | use strict; | |
6431 | use IO::Socket; | |
6432 | -use Test::More tests => 5; | |
6433 | +use Test::More tests => 8; | |
6434 | use LightyTest; | |
6435 | ||
6436 | my $tf = LightyTest->new(); | |
6437 | my $t; | |
6438 | +my $php_child = -1; | |
6439 | ||
6440 | +my $phpbin = (defined $ENV{'PHP'} ? $ENV{'PHP'} : '/usr/bin/php-cgi'); | |
6441 | ||
6442 | SKIP: { | |
6443 | - skip "no PHP running on port 1026", 5 unless $tf->listening_on(1026); | |
6444 | + skip "PHP already running on port 1026", 1 if $tf->listening_on(1026); | |
6445 | + skip "no php binary found", 1 unless -x $phpbin; | |
6446 | + ok(-1 != ($php_child = $tf->spawnfcgi($phpbin, 1026)), "Spawning php"); | |
6447 | +} | |
6448 | ||
6449 | - ok($tf->start_proc == 0, "Starting lighttpd") or die(); | |
6450 | +SKIP: { | |
6451 | + skip "no PHP running on port 1026", 6 unless $tf->listening_on(1026); | |
6452 | ||
6453 | + ok($tf->start_proc == 0, "Starting lighttpd") or goto cleanup; | |
6454 | + | |
6455 | $t->{REQUEST} = ( <<EOF | |
6456 | GET /rewrite/foo HTTP/1.0 | |
6457 | Host: www.example.org | |
6458 | @@ -44,5 +52,27 @@ | |
6459 | $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'bar&a=b' } ]; | |
6460 | ok($tf->handle_http($t) == 0, 'valid request'); | |
6461 | ||
6462 | + $t->{REQUEST} = ( <<EOF | |
6463 | +GET %2Frewrite/f%6Fo?a=b HTTP/1.0 | |
6464 | +Host: www.example.org | |
6465 | +EOF | |
6466 | + ); | |
6467 | + $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'a=b' } ]; | |
6468 | + ok($tf->handle_http($t) == 0, 'valid request with url encoded characters'); | |
6469 | + | |
6470 | ok($tf->stop_proc == 0, "Stopping lighttpd"); | |
6471 | } | |
6472 | + | |
6473 | +SKIP: { | |
6474 | + skip "PHP not started, cannot stop it", 1 unless $php_child != -1; | |
6475 | + ok(0 == $tf->endspawnfcgi($php_child), "Stopping php"); | |
6476 | +} | |
6477 | + | |
6478 | + | |
6479 | +exit 0; | |
6480 | + | |
6481 | +cleanup: ; | |
6482 | + | |
6483 | +$tf->endspawnfcgi($php_child) if $php_child != -1; | |
6484 | + | |
6485 | +die(); | |
6486 | Index: tests/lighttpd.conf | |
6487 | =================================================================== | |
6488 | --- tests/lighttpd.conf (.../tags/lighttpd-1.4.19) (revision 2303) | |
6489 | +++ tests/lighttpd.conf (.../branches/lighttpd-1.4.x) (revision 2303) | |
6490 | @@ -3,7 +3,6 @@ | |
6491 | debug.log-response-header = "enable" | |
6492 | debug.log-condition-handling = "enable" | |
6493 | server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/" | |
6494 | -server.pid-file = env.SRCDIR + "/tmp/lighttpd/lighttpd.pid" | |
6495 | ||
6496 | ## 64 Mbyte ... nice limit | |
6497 | server.max-request-size = 65000 | |
6498 | Index: tests/fastcgi-responder.conf | |
6499 | =================================================================== | |
6500 | --- tests/fastcgi-responder.conf (.../tags/lighttpd-1.4.19) (revision 2303) | |
6501 | +++ tests/fastcgi-responder.conf (.../branches/lighttpd-1.4.x) (revision 2303) | |
6502 | @@ -1,5 +1,4 @@ | |
6503 | server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/" | |
6504 | -server.pid-file = env.SRCDIR + "/tmp/lighttpd/lighttpd.pid" | |
6505 | ||
6506 | #debug.log-request-header = "enable" | |
6507 | #debug.log-response-header = "enable" | |
6508 | Index: tests/fastcgi-auth.conf | |
6509 | =================================================================== | |
6510 | --- tests/fastcgi-auth.conf (.../tags/lighttpd-1.4.19) (revision 2303) | |
6511 | +++ tests/fastcgi-auth.conf (.../branches/lighttpd-1.4.x) (revision 2303) | |
6512 | @@ -1,5 +1,4 @@ | |
6513 | server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/" | |
6514 | -server.pid-file = env.SRCDIR + "/tmp/lighttpd/lighttpd.pid" | |
6515 | ||
6516 | debug.log-request-header = "enable" | |
6517 | debug.log-response-header = "enable" | |
6518 | Index: tests/proxy.conf | |
6519 | =================================================================== | |
6520 | --- tests/proxy.conf (.../tags/lighttpd-1.4.19) (revision 2303) | |
6521 | +++ tests/proxy.conf (.../branches/lighttpd-1.4.x) (revision 2303) | |
6522 | @@ -1,5 +1,4 @@ | |
6523 | server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/" | |
6524 | -server.pid-file = env.SRCDIR + "/tmp/lighttpd/lighttpd-proxy.pid" | |
6525 | ||
6526 | ## bind to port (default: 80) | |
6527 | server.port = 2050 | |
ad6a5263 ER |
6528 | Index: tests/docroot/www/get-env.php |
6529 | =================================================================== | |
54b68997 ER |
6530 | --- tests/docroot/www/get-env.php (.../tags/lighttpd-1.4.19) (revision 2303) |
6531 | +++ tests/docroot/www/get-env.php (.../branches/lighttpd-1.4.x) (revision 2303) | |
ad6a5263 ER |
6532 | @@ -1,3 +1,4 @@ |
6533 | <?php | |
6534 | - print $_ENV[$_GET["env"]]; | |
6535 | + $env = $_GET["env"]; | |
6536 | + print isset($_ENV[$env]) ? $_ENV[$env] : ''; | |
6537 | ?> | |
54b68997 ER |
6538 | Index: tests/docroot/www/Makefile.am |
6539 | =================================================================== | |
6540 | --- tests/docroot/www/Makefile.am (.../tags/lighttpd-1.4.19) (revision 2303) | |
6541 | +++ tests/docroot/www/Makefile.am (.../branches/lighttpd-1.4.x) (revision 2303) | |
6542 | @@ -1,4 +1,4 @@ | |
6543 | -EXTRA_DIST=cgi.php cgi.pl dummydir index.html index.txt phpinfo.php \ | |
6544 | +EXTRA_DIST=cgi.php cgi.pl index.html index.txt phpinfo.php \ | |
6545 | redirect.php cgi-pathinfo.pl get-env.php get-server-env.php \ | |
6546 | nph-status.pl prefix.fcgi get-header.pl ssi.shtml get-post-len.pl \ | |
6547 | exec-date.shtml index.html~ 404.fcgi 404.html 404.pl send404.pl crlfcrash.pl | |
6548 | Index: tests/Makefile.am | |
6549 | =================================================================== | |
6550 | --- tests/Makefile.am (.../tags/lighttpd-1.4.19) (revision 2303) | |
6551 | +++ tests/Makefile.am (.../branches/lighttpd-1.4.x) (revision 2303) | |
6552 | @@ -42,8 +42,6 @@ | |
6553 | mod-redirect.t \ | |
6554 | mod-rewrite.t \ | |
6555 | mod-userdir.t \ | |
6556 | - env-variables.t \ | |
6557 | - env-variables.conf \ | |
6558 | symlink.t \ | |
6559 | request.t \ | |
6560 | mod-ssi.t \ | |
ad6a5263 ER |
6561 | |
6562 | Property changes on: tests/core-404-handler.t | |
6563 | ___________________________________________________________________ | |
54b68997 | 6564 | Added: svn:executable |
ad6a5263 ER |
6565 | + * |
6566 | ||
54b68997 ER |
6567 | Index: tests/LightyTest.pm |
6568 | =================================================================== | |
6569 | --- tests/LightyTest.pm (.../tags/lighttpd-1.4.19) (revision 2303) | |
6570 | +++ tests/LightyTest.pm (.../branches/lighttpd-1.4.x) (revision 2303) | |
6571 | @@ -6,6 +6,7 @@ | |
6572 | use Test::More; | |
6573 | use Socket; | |
6574 | use Cwd 'abs_path'; | |
6575 | +use POSIX ":sys_wait_h"; | |
6576 | ||
6577 | sub mtime { | |
6578 | my $file = shift; | |
6579 | @@ -30,14 +31,17 @@ | |
6580 | ||
6581 | ||
6582 | if (mtime($self->{BASEDIR}.'/src/lighttpd') > mtime($self->{BASEDIR}.'/build/lighttpd')) { | |
6583 | - $self->{LIGHTTPD_PATH} = $self->{BASEDIR}.'/src/lighttpd'; | |
6584 | - $self->{MODULES_PATH} = $self->{BASEDIR}.'/src/.libs'; | |
6585 | + $self->{BINDIR} = $self->{BASEDIR}.'/src'; | |
6586 | + if (mtime($self->{BASEDIR}.'/src/.libs')) { | |
6587 | + $self->{MODULES_PATH} = $self->{BASEDIR}.'/src/.libs'; | |
6588 | + } else { | |
6589 | + $self->{MODULES_PATH} = $self->{BASEDIR}.'/src'; | |
6590 | + } | |
6591 | } else { | |
6592 | - $self->{LIGHTTPD_PATH} = $self->{BASEDIR}.'/build/lighttpd'; | |
6593 | + $self->{BINDIR} = $self->{BASEDIR}.'/build'; | |
6594 | $self->{MODULES_PATH} = $self->{BASEDIR}.'/build'; | |
6595 | } | |
6596 | - $self->{LIGHTTPD_PIDFILE} = $self->{TESTDIR}.'/tmp/lighttpd/lighttpd.pid'; | |
6597 | - $self->{PIDOF_PIDFILE} = $self->{TESTDIR}.'/tmp/lighttpd/pidof.pid'; | |
6598 | + $self->{LIGHTTPD_PATH} = $self->{BINDIR}.'/lighttpd'; | |
6599 | $self->{PORT} = 2048; | |
6600 | ||
6601 | my ($name, $aliases, $addrtype, $net) = gethostbyaddr(inet_aton("127.0.0.1"), AF_INET); | |
6602 | @@ -66,59 +70,73 @@ | |
6603 | sub stop_proc { | |
6604 | my $self = shift; | |
6605 | ||
6606 | - open F, $self->{LIGHTTPD_PIDFILE} or return -1; | |
6607 | - my $pid = <F>; | |
6608 | - close F; | |
6609 | + my $pid = $self->{LIGHTTPD_PID}; | |
6610 | + if (defined $pid && $pid != -1) { | |
6611 | + kill('TERM', $pid) or return -1; | |
6612 | + return -1 if ($pid != waitpid($pid, 0)); | |
6613 | + } else { | |
6614 | + diag("Process not started, nothing to stop"); | |
6615 | + return -1; | |
6616 | + } | |
6617 | ||
6618 | - if (defined $pid) { | |
6619 | - kill('TERM',$pid) or return -1; | |
6620 | + return 0; | |
6621 | +} | |
6622 | + | |
6623 | +sub wait_for_port_with_proc { | |
6624 | + my $self = shift; | |
6625 | + my $port = shift; | |
6626 | + my $child = shift; | |
6627 | + | |
6628 | + while (0 == $self->listening_on($port)) { | |
6629 | select(undef, undef, undef, 0.1); | |
6630 | + | |
6631 | + # the process is gone, we failed | |
6632 | + if (0 != waitpid($child, WNOHANG)) { | |
6633 | + return -1; | |
6634 | + } | |
6635 | } | |
6636 | ||
6637 | return 0; | |
6638 | } | |
6639 | ||
6640 | - | |
6641 | sub start_proc { | |
6642 | my $self = shift; | |
6643 | # kill old proc if necessary | |
6644 | - $self->stop_proc; | |
6645 | + #$self->stop_proc; | |
6646 | ||
6647 | # pre-process configfile if necessary | |
6648 | # | |
6649 | ||
6650 | $ENV{'SRCDIR'} = $self->{BASEDIR}.'/tests'; | |
6651 | + $ENV{'PORT'} = $self->{PORT}; | |
6652 | ||
6653 | - unlink($self->{LIGHTTPD_PIDFILE}); | |
6654 | + my $cmdline = $self->{LIGHTTPD_PATH}." -D -f ".$self->{SRCDIR}."/".$self->{CONFIGFILE}." -m ".$self->{MODULES_PATH}; | |
6655 | if (defined $ENV{"TRACEME"} && $ENV{"TRACEME"} eq 'strace') { | |
6656 | - system("strace -tt -s 512 -o strace ".$self->{LIGHTTPD_PATH}." -D -f ".$self->{SRCDIR}."/".$self->{CONFIGFILE}." -m ".$self->{MODULES_PATH}." &"); | |
6657 | + $cmdline = "strace -tt -s 512 -o strace ".$cmdline; | |
6658 | } elsif (defined $ENV{"TRACEME"} && $ENV{"TRACEME"} eq 'truss') { | |
6659 | - system("/usr/dtrctkit/bin/dtruss -d -e ".$self->{LIGHTTPD_PATH}." -D -f ".$self->{SRCDIR}."/".$self->{CONFIGFILE}." -m ".$self->{MODULES_PATH}." 2> strace &"); | |
6660 | + $cmdline = "truss -a -l -w all -v all -o strace ".$cmdline; | |
6661 | + } elsif (defined $ENV{"TRACEME"} && $ENV{"TRACEME"} eq 'gdb') { | |
6662 | + $cmdline = "gdb --batch --ex 'run' --ex 'bt' --args ".$cmdline." > gdb.out"; | |
6663 | } elsif (defined $ENV{"TRACEME"} && $ENV{"TRACEME"} eq 'valgrind') { | |
6664 | - system("valgrind --tool=memcheck --show-reachable=yes --leak-check=yes --log-file=valgrind ".$self->{LIGHTTPD_PATH}." -D -f ".$self->{SRCDIR}."/".$self->{CONFIGFILE}." -m ".$self->{MODULES_PATH}." &"); | |
6665 | - } else { | |
6666 | - system($self->{LIGHTTPD_PATH}." -f ".$self->{SRCDIR}."/".$self->{CONFIGFILE}." -m ".$self->{MODULES_PATH}); | |
6667 | + $cmdline = "valgrind --tool=memcheck --show-reachable=yes --leak-check=yes --log-file=valgrind ".$cmdline; | |
6668 | } | |
6669 | - | |
6670 | - select(undef, undef, undef, 0.1); | |
6671 | - if (not -e $self->{LIGHTTPD_PIDFILE} or 0 == kill 0, `cat $self->{LIGHTTPD_PIDFILE}`) { | |
6672 | - select(undef, undef, undef, 2); | |
6673 | - } | |
6674 | - | |
6675 | - unlink($self->{TESTDIR}."/tmp/cfg.file"); | |
6676 | - | |
6677 | - # no pidfile, we failed | |
6678 | - if (not -e $self->{LIGHTTPD_PIDFILE}) { | |
6679 | - diag(sprintf('Could not find pidfile: %s', $self->{LIGHTTPD_PIDFILE})); | |
6680 | + # diag("starting lighttpd at :".$self->{PORT}.", cmdline: ".$cmdline ); | |
6681 | + my $child = fork(); | |
6682 | + if (not defined $child) { | |
6683 | + diag("Fork failed"); | |
6684 | return -1; | |
6685 | } | |
6686 | + if ($child == 0) { | |
6687 | + exec $cmdline or die($?); | |
6688 | + } | |
6689 | ||
6690 | - # the process is gone, we failed | |
6691 | - if (0 == kill 0, `cat $self->{LIGHTTPD_PIDFILE}`) { | |
6692 | - diag(sprintf('the process referenced by %s is not up', $self->{LIGHTTPD_PIDFILE})); | |
6693 | + if (0 != $self->wait_for_port_with_proc($self->{PORT}, $child)) { | |
6694 | + diag(sprintf('The process %i is not up', $child)); | |
6695 | return -1; | |
6696 | } | |
6697 | ||
6698 | + $self->{LIGHTTPD_PID} = $child; | |
6699 | + | |
6700 | 0; | |
6701 | } | |
6702 | ||
6703 | @@ -131,6 +149,7 @@ | |
6704 | ||
6705 | my @request = $t->{REQUEST}; | |
6706 | my @response = $t->{RESPONSE}; | |
6707 | + my $is_debug = $ENV{"TRACE_HTTP"}; | |
6708 | ||
6709 | my $remote = | |
6710 | IO::Socket::INET->new(Proto => "tcp", | |
6711 | @@ -144,20 +163,27 @@ | |
6712 | ||
6713 | $remote->autoflush(1); | |
6714 | ||
6715 | + diag("sending request header to ".$host.":".$self->{PORT}) if $is_debug; | |
6716 | foreach(@request) { | |
6717 | # pipeline requests | |
6718 | s/\r//g; | |
6719 | s/\n/$EOL/g; | |
6720 | ||
6721 | - print $remote $_.$BLANK; | |
6722 | + print $remote $_.$BLANK; | |
6723 | + diag("<< ".$_) if $is_debug; | |
6724 | } | |
6725 | + shutdown($remote, 1); # I've stopped writing data | |
6726 | + diag("... done") if $is_debug; | |
6727 | ||
6728 | my $lines = ""; | |
6729 | ||
6730 | + diag("receiving response") if $is_debug; | |
6731 | # read everything | |
6732 | while(<$remote>) { | |
6733 | $lines .= $_; | |
6734 | + diag(">> ".$_) if $is_debug; | |
6735 | } | |
6736 | + diag("... done") if $is_debug; | |
6737 | ||
6738 | close $remote; | |
6739 | ||
6740 | @@ -187,18 +213,24 @@ | |
6741 | (my $h = $1) =~ tr/[A-Z]/[a-z]/; | |
6742 | ||
6743 | if (defined $resp_hdr{$h}) { | |
6744 | - diag(sprintf("header %s is duplicated: %s and %s\n", | |
6745 | - $h, $resp_hdr{$h}, $2)); | |
6746 | +# diag(sprintf("header '%s' is duplicated: '%s' and '%s'\n", | |
6747 | +# $h, $resp_hdr{$h}, $2)); | |
6748 | + $resp_hdr{$h} .= ', '.$2; | |
6749 | } else { | |
6750 | $resp_hdr{$h} = $2; | |
6751 | } | |
6752 | } else { | |
6753 | - diag(sprintf("unexpected line '$line'\n")); | |
6754 | + diag(sprintf("unexpected line '%s'\n", $line)); | |
6755 | return -1; | |
6756 | } | |
6757 | } | |
6758 | } | |
6759 | ||
6760 | + if (not defined($resp_line)) { | |
6761 | + diag(sprintf("empty response\n")); | |
6762 | + return -1; | |
6763 | + } | |
6764 | + | |
6765 | $t->{etag} = $resp_hdr{'etag'}; | |
6766 | $t->{date} = $resp_hdr{'date'}; | |
6767 | ||
6768 | @@ -227,7 +259,7 @@ | |
6769 | return -1; | |
6770 | } | |
6771 | } else { | |
6772 | - diag(sprintf("unexpected resp_line '$resp_line'\n")); | |
6773 | + diag(sprintf("unexpected resp_line '%s'\n", $resp_line)); | |
6774 | return -1; | |
6775 | } | |
6776 | ||
6777 | @@ -237,7 +269,9 @@ | |
6778 | diag(sprintf("body failed: expected '%s', got '%s'\n", $href->{'HTTP-Content'}, $resp_body)); | |
6779 | return -1; | |
6780 | } | |
6781 | - } elsif (defined $href->{'-HTTP-Content'}) { | |
6782 | + } | |
6783 | + | |
6784 | + if (defined $href->{'-HTTP-Content'}) { | |
6785 | if (defined $resp_body && $resp_body ne '') { | |
6786 | diag(sprintf("body failed: expected empty body, got '%s'\n", $resp_body)); | |
6787 | return -1; | |
6788 | @@ -245,7 +279,6 @@ | |
6789 | } | |
6790 | ||
6791 | foreach (keys %{ $href }) { | |
6792 | - ## filter special keys | |
6793 | next if $_ eq 'HTTP-Protocol'; | |
6794 | next if $_ eq 'HTTP-Status'; | |
6795 | next if $_ eq 'HTTP-Content'; | |
6796 | @@ -257,7 +290,6 @@ | |
6797 | my $key_inverted = 0; | |
6798 | ||
6799 | if (substr($k, 0, 1) eq '+') { | |
6800 | - ## the key has to exist, but the value is ignored | |
6801 | $k = substr($k, 1); | |
6802 | $verify_value = 0; | |
6803 | } elsif (substr($k, 0, 1) eq '-') { | |
6804 | @@ -265,11 +297,11 @@ | |
6805 | $k = substr($k, 1); | |
6806 | $key_inverted = 1; | |
6807 | $verify_value = 0; ## skip the value check | |
6808 | - } | |
6809 | + } | |
6810 | ||
6811 | if ($key_inverted) { | |
6812 | if (defined $resp_hdr{$k}) { | |
6813 | - diag(sprintf("required header '%s' is missing\n", $k)); | |
6814 | + diag(sprintf("header '%s' MUST not be set\n", $k)); | |
6815 | return -1; | |
6816 | } | |
6817 | } else { | |
6818 | @@ -297,12 +329,38 @@ | |
6819 | ||
6820 | # we should have sucked up everything | |
6821 | if (defined $lines) { | |
6822 | - diag(sprintf("unexpected lines '$lines'\n")); | |
6823 | + diag(sprintf("unexpected lines '%s'\n", $lines)); | |
6824 | return -1; | |
6825 | } | |
6826 | ||
6827 | return 0; | |
6828 | } | |
6829 | - | |
6830 | + | |
6831 | +sub spawnfcgi { | |
6832 | + my ($self, $binary, $port) = @_; | |
6833 | + my $child = fork(); | |
6834 | + if (not defined $child) { | |
6835 | + diag("Couldn't fork\n"); | |
6836 | + return -1; | |
6837 | + } | |
6838 | + if ($child == 0) { | |
6839 | + my $cmd = $self->{BINDIR}.'/spawn-fcgi -n -p '.$port.' -f "'.$binary.'"'; | |
6840 | + exec $cmd or die($?); | |
6841 | + } else { | |
6842 | + if (0 != $self->wait_for_port_with_proc($port, $child)) { | |
6843 | + diag(sprintf('The process %i is not up (port %i, %s)', $child, $port, $binary)); | |
6844 | + return -1; | |
6845 | + } | |
6846 | + return $child; | |
6847 | + } | |
6848 | +} | |
6849 | + | |
6850 | +sub endspawnfcgi { | |
6851 | + my ($self, $pid) = @_; | |
6852 | + return -1 if (-1 == $pid); | |
6853 | + kill(2, $pid); | |
6854 | + waitpid($pid, 0); | |
6855 | + return 0; | |
6856 | +} | |
6857 | + | |
6858 | 1; | |
6859 | - | |
6860 | Index: tests/run-tests.pl | |
6861 | =================================================================== | |
6862 | --- tests/run-tests.pl (.../tags/lighttpd-1.4.19) (revision 2303) | |
6863 | +++ tests/run-tests.pl (.../branches/lighttpd-1.4.x) (revision 2303) | |
6864 | @@ -3,17 +3,18 @@ | |
6865 | use strict; | |
6866 | ||
6867 | use Test::Harness qw(&runtests $verbose); | |
6868 | -$verbose = (defined $ENV{'VERBOSE'} ? $ENV{'VERBOSE'} : 0);; | |
6869 | +$verbose = (defined $ENV{'VERBOSE'} ? $ENV{'VERBOSE'} : 0); | |
6870 | +my $tests = (defined $ENV{'TESTS'} ? $ENV{'TESTS'} : ''); | |
6871 | ||
6872 | my $srcdir = (defined $ENV{'srcdir'} ? $ENV{'srcdir'} : '.'); | |
6873 | ||
6874 | opendir DIR, $srcdir; | |
6875 | my (@fs, $f); | |
6876 | while ($f = readdir(DIR)) { | |
6877 | - if ($f =~ /\.t$/) { | |
6878 | + if ($f =~ /^(.*)\.t$/) { | |
6879 | + next if ($tests ne '' and $tests !~ /(^|\s+)$1(\s+|$)/); | |
6880 | push @fs, $srcdir.'/'.$f; | |
6881 | } | |
6882 | } | |
6883 | closedir DIR; | |
6884 | runtests @fs; | |
6885 | - | |
49b4da39 | 6886 | Index: doc/userdir.txt |
a34aaa25 | 6887 | =================================================================== |
54b68997 ER |
6888 | --- doc/userdir.txt (.../tags/lighttpd-1.4.19) (revision 2303) |
6889 | +++ doc/userdir.txt (.../branches/lighttpd-1.4.x) (revision 2303) | |
49b4da39 ER |
6890 | @@ -46,10 +46,10 @@ |
6891 | Options | |
6892 | ======= | |
a34aaa25 | 6893 | |
49b4da39 ER |
6894 | -userdir.path |
6895 | +userdir.path (required option) | |
6896 | usually it should be set to "public_html" to take ~/public_html/ as the document root | |
a34aaa25 | 6897 | |
49b4da39 ER |
6898 | - Default: empty (document root is the home directory) |
6899 | + Default: unset (mod_userdir disabled; set it to "" if you want the home directory to be the document root as it was the default before 1.4.19) | |
6900 | Example: :: | |
09cf44bb | 6901 | |
49b4da39 | 6902 | userdir.path = "public_html" |
54b68997 ER |
6903 | Index: doc/configuration.txt |
6904 | =================================================================== | |
6905 | --- doc/configuration.txt (.../tags/lighttpd-1.4.19) (revision 2303) | |
6906 | +++ doc/configuration.txt (.../branches/lighttpd-1.4.x) (revision 2303) | |
6907 | @@ -513,3 +513,6 @@ | |
6908 | ||
6909 | debug.log-request-handling | |
6910 | default: disabled | |
6911 | + | |
6912 | +debug.log-ssl-noise | |
6913 | + default: disabled | |
1e1cc0d1 ER |
6914 | Index: SConstruct |
6915 | =================================================================== | |
54b68997 ER |
6916 | --- SConstruct (.../tags/lighttpd-1.4.19) (revision 2303) |
6917 | +++ SConstruct (.../branches/lighttpd-1.4.x) (revision 2303) | |
49b4da39 ER |
6918 | @@ -5,7 +5,7 @@ |
6919 | from stat import * | |
6920 | ||
6921 | package = 'lighttpd' | |
6922 | -version = '1.4.19' | |
6923 | +version = '1.4.20' | |
10dbb8f0 | 6924 | |
49b4da39 ER |
6925 | def checkCHeaders(autoconf, hdrs): |
6926 | p = re.compile('[^A-Z0-9]') | |
ad6a5263 ER |
6927 | Index: Makefile.am |
6928 | =================================================================== | |
54b68997 ER |
6929 | --- Makefile.am (.../tags/lighttpd-1.4.19) (revision 2303) |
6930 | +++ Makefile.am (.../branches/lighttpd-1.4.x) (revision 2303) | |
6931 | @@ -1,3 +1,5 @@ | |
ad6a5263 ER |
6932 | SUBDIRS=src doc tests cygwin openwrt |
6933 | ||
6934 | -EXTRA_DIST=lighttpd.spec autogen.sh SConstruct | |
6935 | +EXTRA_DIST=autogen.sh SConstruct | |
54b68997 ER |
6936 | + |
6937 | +distcleancheck_listfiles = find -type f -exec sh -c 'test -f $(srcdir)/{} || echo {}' ';' | |
cc1350fa ER |
6938 | Index: NEWS |
6939 | =================================================================== | |
54b68997 ER |
6940 | --- NEWS (.../tags/lighttpd-1.4.19) (revision 2303) |
6941 | +++ NEWS (.../branches/lighttpd-1.4.x) (revision 2303) | |
6942 | @@ -3,8 +3,67 @@ | |
cc1350fa ER |
6943 | NEWS |
6944 | ==== | |
6945 | ||
49b4da39 ER |
6946 | -- 1.4.19 - |
6947 | +- 1.4.20 - | |
6948 | ||
6949 | + * Fix mod_compress to compile with old gcc version (#1592) | |
6950 | + * Fix mod_extforward to compile with old gcc version (#1591) | |
6951 | + * Update documentation for #1587 | |
6952 | + * Fix #285 again: read error after SSL_shutdown (thx marton.illes@balabit.com) and clear the error queue before some other calls (CVE-2008-1531) | |
6953 | + * Fix mod_magnet: enable "request.method" and "request.protocol" in lighty.env (#1308) | |
6954 | + * Fix segfault for appending matched parts if there was no regex matching (just give empty strings) (#1601) | |
6955 | + * Use data_response_init in mod_fastcgi x-sendfile handling for response.headers, fix a small "memleak" (#1628) | |
6956 | + * Don't send empty Server headers (#1620) | |
ad6a5263 ER |
6957 | + * Fix conditional interpretation of core options |
6958 | + * Enable escaping of % and $ in redirect/rewrite; only two cases changed their behaviour: "%%" => "%", "$$" => "$" | |
6959 | + * Fix accesslog port (should be port from the connection, not the "server.port") (#1618) | |
6960 | + * Fix mod_fastcgi prefix matching: match the prefix always against url, not the absolute filepath (regardless of check-local) | |
6961 | + * Overwrite Content-Type header in mod_dirlisting instead of inserting (#1614), patch by Henrik Holst | |
6962 | + * Handle EINTR in mod_cgi during write() (#1640) | |
6963 | + * Allow all http status codes by default; disable body only for 204,205 and 304; generate error pages for 4xx and 5xx (#1639) | |
6964 | + * Fix mod_magnet to set con->mode = p->id if it generates content, so returning 4xx/5xx doesn't append an error page | |
6965 | + * Remove lighttpd.spec* from source, fixing all problems with it ;-) | |
6966 | + * Do not rely on PATH_MAX (POSIX does not require it) (#580) | |
6967 | + * Disable logging to access.log if filename is an empty string | |
6968 | + * Implement a clean way to open /dev/null and use it to close stdin/out/err in the needed places (#624) | |
3c3043fd ER |
6969 | + * merge spawn-fcgi changes from trunk (from @2191) |
6970 | + * let spawn-fcgi propagate exit code from spawned fcgi application | |
54b68997 ER |
6971 | + * close connection after redirect in trigger_b4_dl (thx icy) |
6972 | + * close connection in mod_magnet if returned status code | |
6973 | + * fix bug with IPv6 in mod_evasive (#1579) | |
6974 | + * fix scgi HTTP/1.* status parsing (#1638), found by met@uberstats.com | |
6975 | + * [tests] fixed system, use foreground daemons and waitpid | |
6976 | + * [tests] removed pidfile from test system | |
6977 | + * [tests] fixed tests needing php running (if not running on port 1026, search php in env[PHP] or /usr/bin/php-cgi) | |
6978 | + * fixed typo in mod_accesslog (#1699) | |
6979 | + * replaced buffer_{append,copy}_string with the _len variant where possible (#1732) (thx crypt) | |
6980 | + * case insensitive match for secdownload md5 token (#1710) | |
6981 | + * Handle only HEAD, GET and POST in mod_dirlisting (same as in staticfile) (#1687) | |
6982 | + * fixed mod_secdownload problem with unsigned time_t (#1688) | |
6983 | + * handle EAGAIN and EINTR for freebsd sendfile (#1675) | |
6984 | + * Use filedescriptor 0 for mod_scgi spawn socket, redirect STDERR to /dev/null (#1716) | |
6985 | + * fixed round-robin balancing in mod_proxy (#1715) | |
6986 | + * fixed EINTR handling for waitpid in mod_fastcgi | |
6987 | + * mod_{fast,s}cgi: overwrite environment variables (#1722) | |
6988 | + * inserted many con->mode checks; they should prevent two modules to handle the same request if they shouldn't (#631) | |
6989 | + * fixed url encoding to encode more characters (#266) | |
6990 | + * allow digits in [s]cgi env vars (#1712) | |
6991 | + * fixed dropping last character of evhost pattern (#161) | |
6992 | + * print helpful error message on conditionals in global block (#1550) | |
6993 | + * decode url before matching in mod_rewrite (#1720) | |
6994 | + * fixed conditional patching of ldap filter (#1564) | |
6995 | + * Match headers case insensitive in response (removing of X-{Sendfile,LIGHTTPD-*}, catching Date/Server) | |
6996 | + * fixed bug with case-insensitive filenames in mod_userdir (#1589), spotted by "anders1" | |
6997 | + * fixed format string bugs in mod_accesslog for SYSLOG | |
6998 | + * replaced fprintf with log_error_write in fastcgi debug | |
6999 | + * fixed mem leak in ssi expression parser (#1753), thx Take5k | |
7000 | + * hide some ssl errors per default, enable them with debug.log-ssl-noise (#397) | |
7001 | + * do not send content-encoding for 304 (#1754), thx yzlai | |
7002 | + * fix segfault for stat_cache(fam) calls with relative path (without '/', can be triggered by x-sendfile) (#1750) | |
7003 | + * fix splitting of auth-ldap filter | |
7004 | + * workaround ldap connection leak if a ldap connection failed (restarting ldap) | |
09cf44bb | 7005 | + |
49b4da39 | 7006 | +- 1.4.19 - 2008-03-10 |
cc1350fa | 7007 | + |
49b4da39 ER |
7008 | * added support for If-Range: <date> (#1346) |
7009 | * added support for matching $HTTP["scheme"] in configs | |
7010 | * fixed initgroups() called after chroot (#1384) | |
ad6a5263 ER |
7011 | Index: .cvsignore |
7012 | =================================================================== | |
a34aaa25 ER |
7013 | |
7014 | Property changes on: . | |
7015 | ___________________________________________________________________ | |
54b68997 | 7016 | Modified: svk:merge |
49b4da39 ER |
7017 | - 152afb58-edef-0310-8abb-c4023f1b3aa9:/branches/lighttpd-1.3.x:499 |
7018 | 152afb58-edef-0310-8abb-c4023f1b3aa9:/branches/lighttpd-1.4.11-ssl-fixes:1346 | |
7019 | 152afb58-edef-0310-8abb-c4023f1b3aa9:/branches/lighttpd-merge-1.4.x:1041 | |
7020 | 152afb58-edef-0310-8abb-c4023f1b3aa9:/tags/lighttpd-1.4.11:1042 | |
7021 | 152afb58-edef-0310-8abb-c4023f1b3aa9:/tags/release-1.3.13:105 | |
7022 | 152afb58-edef-0310-8abb-c4023f1b3aa9:/trunk:104 | |
7023 | a98e19e4-a712-0410-8832-6551a15ffc53:/local/branches/lighttpd-1.4.x:1557 | |
7024 | ebd0e9cf-3e47-4385-9dd4-f0e25e97baa2:/local/lighttpd/branches/lighttpd-1.4.x:2164 | |
a34aaa25 ER |
7025 | + 152afb58-edef-0310-8abb-c4023f1b3aa9:/branches/lighttpd-1.3.x:499 |
7026 | 152afb58-edef-0310-8abb-c4023f1b3aa9:/branches/lighttpd-1.4.11-ssl-fixes:1346 | |
7027 | 152afb58-edef-0310-8abb-c4023f1b3aa9:/branches/lighttpd-merge-1.4.x:1041 | |
7028 | 152afb58-edef-0310-8abb-c4023f1b3aa9:/tags/lighttpd-1.4.11:1042 | |
7029 | 152afb58-edef-0310-8abb-c4023f1b3aa9:/tags/release-1.3.13:105 | |
7030 | 152afb58-edef-0310-8abb-c4023f1b3aa9:/trunk:104 | |
7031 | a98e19e4-a712-0410-8832-6551a15ffc53:/local/branches/lighttpd-1.4.x:1557 | |
ad6a5263 | 7032 | ebd0e9cf-3e47-4385-9dd4-f0e25e97baa2:/local/lighttpd/branches/lighttpd-1.4.x:2250 |
54b68997 ER |
7033 | Added: bzr:revision-info |
7034 | + timestamp: 2008-09-17 16:23:00.644000053 +0200 | |
7035 | committer: Stefan Bühler <stbuehler@web.de> | |
7036 | properties: | |
7037 | branch-nick: lighttpd-1.4.x | |
7038 | ||
7039 | Added: bzr:file-ids | |
7040 | + | |
7041 | Added: bzr:revision-id:v3-trunk0 | |
7042 | + 1127 stbuehler@web.de-20080728081644-j4cxnhduw8kbt8um | |
7043 | 1128 stbuehler@web.de-20080728084246-axvxdtjsrratxixs | |
7044 | 1129 stbuehler@web.de-20080729211700-s8v6nq2cu06qesls | |
7045 | 1130 stbuehler@web.de-20080729211726-4yxb6e5dva1cn0lz | |
7046 | 1131 stbuehler@web.de-20080729211750-4ulzigswx17uciyu | |
7047 | 1132 stbuehler@web.de-20080729211850-nliz3kd0m576ztuu | |
7048 | 1133 stbuehler@web.de-20080730163440-dg2y2sbf0u4grmn4 | |
7049 | 1134 stbuehler@web.de-20080730173952-kiutzg6geqy7mick | |
7050 | 1135 stbuehler@web.de-20080730193616-9kc2ms7rrhv1lkn7 | |
7051 | 1136 stbuehler@web.de-20080730211457-z4a6uth1y29glbqh | |
7052 | 1137 stbuehler@web.de-20080730213517-b6sjcrdwbmipl334 | |
7053 | 1138 stbuehler@web.de-20080731102617-2xw8unjfqic7lsew | |
7054 | 1139 stbuehler@web.de-20080731102703-q4tu5a6em9y8xdg0 | |
7055 | 1140 stbuehler@web.de-20080731102729-l6vn5b05w9swqbg5 | |
7056 | 1141 stbuehler@web.de-20080731102756-oj3d4tnk0l90mj77 | |
7057 | 1142 stbuehler@web.de-20080731204442-blw14cj2fkr3l8ly | |
7058 | 1143 stbuehler@web.de-20080731204508-imtfnurf922mg7tj | |
7059 | 1144 stbuehler@web.de-20080801112347-girnwswdkwm8wuip | |
7060 | 1145 stbuehler@web.de-20080801161245-kx1temr529o7xko9 | |
7061 | 1146 stbuehler@web.de-20080801175332-oc9e7x8edn1owcc0 | |
7062 | 1147 stbuehler@web.de-20080801183454-5i66v0gsdv0cgmia | |
7063 | 1148 stbuehler@web.de-20080801192849-6zklfbb832sx0hvr | |
7064 | 1149 stbuehler@web.de-20080801203119-o16elp8w854s6lol | |
7065 | 1150 stbuehler@web.de-20080802162146-a4v57svc788pwdsv | |
7066 | 1151 stbuehler@web.de-20080802162202-9udlc1wuwt09pyh2 | |
7067 | 1152 stbuehler@web.de-20080804135803-yuor9ze06px7qta4 | |
7068 | 1153 stbuehler@web.de-20080812194728-fupt781o6q058unh | |
7069 | 1154 stbuehler@web.de-20080818162116-piz0ukqsaecv2li2 | |
7070 | 1155 stbuehler@web.de-20080818235700-94t0xc6ml70zojwq | |
7071 | 1156 stbuehler@web.de-20080819163650-1qhwsqszr78cr4xx | |
7072 | 1157 stbuehler@web.de-20080819163757-1qq3t1f1wj69t8xs | |
7073 | 1158 stbuehler@web.de-20080819163914-rklhkurg8apv85l2 | |
7074 | 1159 stbuehler@web.de-20080819163953-tlqew751e43phf5b | |
7075 | 1160 stbuehler@web.de-20080819164108-8ogh68sm1uyteawe | |
7076 | 1161 stbuehler@web.de-20080819173911-w5bqpb7cp9jmdqye | |
7077 | 1162 stbuehler@web.de-20080819222242-c0ta5gnli9p3j35a | |
7078 | 1163 stbuehler@web.de-20080820100730-g1bwdh4nqb53ag9u | |
7079 | 1164 stbuehler@web.de-20080820100752-9pggugdyfnnps8qu | |
7080 | 1165 stbuehler@web.de-20080820164258-v2j00motsrsc5esp | |
7081 | 1166 stbuehler@web.de-20080827144628-hi9hf4ch3n1wf9ao | |
7082 | 1167 stbuehler@web.de-20080827144903-tfxu4yehlyu5kegc | |
7083 | 1168 stbuehler@web.de-20080827155155-7mt92orehbxkh2lh | |
7084 | 1169 stbuehler@web.de-20080917142048-zbcwpk39q9ewd516 | |
7085 | 1170 stbuehler@web.de-20080917142300-16gzt21x4nbjtj87 | |
7086 | ||
a34aaa25 | 7087 |