]> git.pld-linux.org Git - packages/lighttpd.git/blob - lighttpd-branch.diff
- update to 2129:
[packages/lighttpd.git] / lighttpd-branch.diff
1 Index: lighttpd.spec.in
2 ===================================================================
3 --- lighttpd.spec.in    (.../tags/lighttpd-1.4.19)      (revision 2190)
4 +++ lighttpd.spec.in    (.../branches/lighttpd-1.4.x)   (revision 2190)
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
89 Index: configure.in
90 ===================================================================
91 Index: src/mod_ssi_exprparser.h
92 ===================================================================
93 --- src/mod_ssi_exprparser.h    (.../tags/lighttpd-1.4.19)      (revision 2190)
94 +++ src/mod_ssi_exprparser.h    (.../branches/lighttpd-1.4.x)   (revision 2190)
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
108 Index: src/configfile-glue.c
109 ===================================================================
110 --- src/configfile-glue.c       (.../tags/lighttpd-1.4.19)      (revision 2190)
111 +++ src/configfile-glue.c       (.../branches/lighttpd-1.4.x)   (revision 2190)
112 @@ -529,7 +529,7 @@
113  int config_append_cond_match_buffer(connection *con, data_config *dc, buffer *buf, int n)
114  {
115         cond_cache_t *cache = &con->cond_cache[dc->context_ndx];
116 -       if (n > cache->patterncount) {
117 +       if (n >= cache->patterncount) {
118                 return 0;
119         }
120  
121 Index: src/mod_cgi.c
122 ===================================================================
123 --- src/mod_cgi.c       (.../tags/lighttpd-1.4.19)      (revision 2190)
124 +++ src/mod_cgi.c       (.../branches/lighttpd-1.4.x)   (revision 2190)
125 @@ -987,6 +987,8 @@
126                         *c = '/';
127                 }
128  
129 +               openDevNull(STDERR_FILENO);
130 +
131                 /* we don't need the client socket */
132                 for (i = 3; i < 256; i++) {
133                         if (i != srv->errorlog_fd) close(i);
134 @@ -995,7 +997,7 @@
135                 /* exec the cgi */
136                 execve(args[0], args, env.ptr);
137  
138 -               log_error_write(srv, __FILE__, __LINE__, "sss", "CGI failed:", strerror(errno), args[0]);
139 +               /* log_error_write(srv, __FILE__, __LINE__, "sss", "CGI failed:", strerror(errno), args[0]); */
140  
141                 /* */
142                 SEGFAULT();
143 @@ -1058,8 +1060,9 @@
144                                                 switch(errno) {
145                                                 case ENOSPC:
146                                                         con->http_status = 507;
147 -
148                                                         break;
149 +                                               case EINTR:
150 +                                                       continue;
151                                                 default:
152                                                         con->http_status = 403;
153                                                         break;
154 @@ -1071,8 +1074,9 @@
155                                                 switch(errno) {
156                                                 case ENOSPC:
157                                                         con->http_status = 507;
158 -
159                                                         break;
160 +                                               case EINTR:
161 +                                                       continue;
162                                                 default:
163                                                         con->http_status = 403;
164                                                         break;
165 @@ -1087,6 +1091,8 @@
166                                         c->offset += r;
167                                         cq->bytes_out += r;
168                                 } else {
169 +                                       log_error_write(srv, __FILE__, __LINE__, "ss", "write() failed due to: ", strerror(errno)); 
170 +                                       con->http_status = 500;
171                                         break;
172                                 }
173                                 chunkqueue_remove_finished_chunks(cq);
174 Index: src/mod_rewrite.c
175 ===================================================================
176 --- src/mod_rewrite.c   (.../tags/lighttpd-1.4.19)      (revision 2190)
177 +++ src/mod_rewrite.c   (.../branches/lighttpd-1.4.x)   (revision 2190)
178 @@ -385,8 +385,7 @@
179  
180                         start = 0; end = pattern_len;
181                         for (k = 0; k < pattern_len; k++) {
182 -                               if ((pattern[k] == '$' || pattern[k] == '%') &&
183 -                                   isdigit((unsigned char)pattern[k + 1])) {
184 +                               if (pattern[k] == '$' || pattern[k] == '%') {
185                                         /* got one */
186  
187                                         size_t num = pattern[k + 1] - '0';
188 @@ -395,7 +394,10 @@
189  
190                                         buffer_append_string_len(con->request.uri, pattern + start, end - start);
191  
192 -                                       if (pattern[k] == '$') {
193 +                                       if (!isdigit((unsigned char)pattern[k + 1])) {
194 +                                               /* enable escape: "%%" => "%", "%a" => "%a", "$$" => "$" */
195 +                                               buffer_append_string_len(con->request.uri, pattern+k, pattern[k] == pattern[k+1] ? 1 : 2);
196 +                                       } else if (pattern[k] == '$') {
197                                                 /* n is always > 0 */
198                                                 if (num < (size_t)n) {
199                                                         buffer_append_string(con->request.uri, list[num]);
200 Index: src/lempar.c
201 ===================================================================
202 --- src/lempar.c        (.../tags/lighttpd-1.4.19)      (revision 2190)
203 +++ src/lempar.c        (.../branches/lighttpd-1.4.x)   (revision 2190)
204 @@ -210,7 +210,7 @@
205  */
206  const char *ParseTokenName(int tokenType){
207  #ifndef NDEBUG
208 -  if( tokenType>0 && tokenType<(sizeof(yyTokenName)/sizeof(yyTokenName[0])) ){
209 +  if( tokenType>0 && (size_t)tokenType<(sizeof(yyTokenName)/sizeof(yyTokenName[0])) ){
210      return yyTokenName[tokenType];
211    }else{
212      return "Unknown";
213 @@ -335,7 +335,7 @@
214      return YY_NO_ACTION;
215    }
216    i += iLookAhead;
217 -  if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){
218 +  if( i<0 || (size_t)i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){
219  #ifdef YYFALLBACK
220      int iFallback;            /* Fallback token */
221      if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])
222 @@ -378,7 +378,7 @@
223      return YY_NO_ACTION;
224    }
225    i += iLookAhead;
226 -  if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){
227 +  if( i<0 || (size_t)i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){
228      return yy_default[stateno];
229    }else{
230      return yy_action[i];
231 @@ -456,7 +456,7 @@
232    yymsp = &yypParser->yystack[yypParser->yyidx];
233  #ifndef NDEBUG
234    if( yyTraceFILE && yyruleno>=0
235 -        && yyruleno<sizeof(yyRuleName)/sizeof(yyRuleName[0]) ){
236 +        && (size_t)yyruleno<sizeof(yyRuleName)/sizeof(yyRuleName[0]) ){
237      fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt,
238        yyRuleName[yyruleno]);
239    }
240 @@ -511,6 +511,8 @@
241    int yymajor,                   /* The major type of the error token */
242    YYMINORTYPE yyminor            /* The minor type of the error token */
243  ){
244 +  UNUSED(yymajor);
245 +  UNUSED(yyminor);
246    ParseARG_FETCH;
247  #define TOKEN (yyminor.yy0)
248  %%
249 Index: src/connections.c
250 ===================================================================
251 --- src/connections.c   (.../tags/lighttpd-1.4.19)      (revision 2190)
252 +++ src/connections.c   (.../branches/lighttpd-1.4.x)   (revision 2190)
253 @@ -199,6 +199,7 @@
254  
255         /* don't resize the buffer if we were in SSL_ERROR_WANT_* */
256  
257 +       ERR_clear_error();
258         do {
259                 if (!con->ssl_error_want_reuse_buffer) {
260                         b = buffer_init();
261 @@ -299,6 +300,8 @@
262  
263         return 0;
264  #else
265 +       UNUSED(srv);
266 +       UNUSED(con);
267         return -1;
268  #endif
269  }
270 @@ -427,21 +430,22 @@
271         }
272  
273         switch(con->http_status) {
274 -       case 400: /* class: header + custom body */
275 -       case 401:
276 -       case 403:
277 -       case 404:
278 -       case 408:
279 -       case 409:
280 -       case 411:
281 -       case 416:
282 -       case 423:
283 -       case 500:
284 -       case 501:
285 -       case 503:
286 -       case 505:
287 +       case 204: /* class: header only */
288 +       case 205:
289 +       case 304:
290 +               /* disable chunked encoding again as we have no body */
291 +               con->response.transfer_encoding &= ~HTTP_TRANSFER_ENCODING_CHUNKED;
292 +               con->parsed_response &= ~HTTP_CONTENT_LENGTH;
293 +               chunkqueue_reset(con->write_queue);
294 +
295 +               con->file_finished = 1;
296 +               break;
297 +       default: /* class: header + body */
298                 if (con->mode != DIRECT) break;
299  
300 +               /* only custom body for 4xx and 5xx */
301 +               if (con->http_status < 400 || con->http_status >= 600) break;
302 +
303                 con->file_finished = 0;
304  
305                 buffer_reset(con->physical.path);
306 @@ -451,7 +455,8 @@
307                         stat_cache_entry *sce = NULL;
308  
309                         buffer_copy_string_buffer(con->physical.path, con->conf.errorfile_prefix);
310 -                       buffer_append_string(con->physical.path, get_http_status_body_name(con->http_status));
311 +                       buffer_append_long(con->physical.path, con->http_status);
312 +                       buffer_append_string_len(con->physical.path, CONST_STR_LEN(".html"));
313  
314                         if (HANDLER_ERROR != stat_cache_get_entry(srv, con, con->physical.path, &sce)) {
315                                 con->file_finished = 1;
316 @@ -497,30 +502,7 @@
317  
318                         response_header_overwrite(srv, con, CONST_STR_LEN("Content-Type"), CONST_STR_LEN("text/html"));
319                 }
320 -               /* fall through */
321 -       case 207:
322 -       case 200: /* class: header + body */
323 -       case 201:
324 -       case 300:
325 -       case 301:
326 -       case 302:
327 -       case 303:
328 -       case 307:
329                 break;
330 -
331 -       case 206: /* write_queue is already prepared */
332 -               break;
333 -       case 204:
334 -       case 205: /* class: header only */
335 -       case 304:
336 -       default:
337 -               /* disable chunked encoding again as we have no body */
338 -               con->response.transfer_encoding &= ~HTTP_TRANSFER_ENCODING_CHUNKED;
339 -               con->parsed_response &= ~HTTP_CONTENT_LENGTH;
340 -               chunkqueue_reset(con->write_queue);
341 -
342 -               con->file_finished = 1;
343 -               break;
344         }
345  
346         if (con->file_finished) {
347 @@ -544,7 +526,7 @@
348                                 data_string *ds;
349                                 /* no Content-Body, no Content-Length */
350                                 if (NULL != (ds = (data_string*) array_get_element(con->response.headers, "Content-Length"))) {
351 -                                       buffer_reset(ds->value); // Headers with empty values are ignored for output
352 +                                       buffer_reset(ds->value); /* Headers with empty values are ignored for output */
353                                 }
354                         } else if (qlen > 0 || con->request.http_method != HTTP_METHOD_HEAD) {
355                                 /* qlen = 0 is important for Redirects (301, ...) as they MAY have
356 @@ -846,7 +828,7 @@
357         }
358  
359         /* The cond_cache gets reset in response.c */
360 -//     config_cond_cache_reset(srv, con);
361 +       /* config_cond_cache_reset(srv, con); */
362  
363  #ifdef USE_OPENSSL
364         if (con->ssl_error_want_reuse_buffer) {
365 @@ -1668,21 +1650,51 @@
366                         }
367  #ifdef USE_OPENSSL
368                         if (srv_sock->is_ssl) {
369 -                               int ret;
370 +                               int ret, ssl_r;
371 +                               unsigned long err;
372 +                               ERR_clear_error();
373                                 switch ((ret = SSL_shutdown(con->ssl))) {
374                                 case 1:
375                                         /* ok */
376                                         break;
377                                 case 0:
378 -                                       SSL_shutdown(con->ssl);
379 -                                       break;
380 +                                       ERR_clear_error();
381 +                                       if (-1 != (ret = SSL_shutdown(con->ssl))) break;
382 +
383 +                                       /* fall through */
384                                 default:
385 -                                       log_error_write(srv, __FILE__, __LINE__, "sds", "SSL:",
386 -                                                       SSL_get_error(con->ssl, ret),
387 -                                                       ERR_error_string(ERR_get_error(), NULL));
388 -                                       return -1;
389 +
390 +                                       switch ((ssl_r = SSL_get_error(con->ssl, ret))) {
391 +                                       case SSL_ERROR_WANT_WRITE:
392 +                                       case SSL_ERROR_WANT_READ:
393 +                                               break;
394 +                                       case SSL_ERROR_SYSCALL:
395 +                                               /* perhaps we have error waiting in our error-queue */
396 +                                               if (0 != (err = ERR_get_error())) {
397 +                                                       do {
398 +                                                               log_error_write(srv, __FILE__, __LINE__, "sdds", "SSL:",
399 +                                                                               ssl_r, ret,
400 +                                                                               ERR_error_string(err, NULL));
401 +                                                       } while((err = ERR_get_error()));
402 +                                               } else {
403 +                                                       log_error_write(srv, __FILE__, __LINE__, "sddds", "SSL (error):",
404 +                                                                       ssl_r, ret, errno,
405 +                                                                       strerror(errno));
406 +                                               }
407 +       
408 +                                               break;
409 +                                       default:
410 +                                               while((err = ERR_get_error())) {
411 +                                                       log_error_write(srv, __FILE__, __LINE__, "sdds", "SSL:",
412 +                                                                       ssl_r, ret,
413 +                                                                       ERR_error_string(err, NULL));
414 +                                               }
415 +       
416 +                                               break;
417 +                                       }
418                                 }
419                         }
420 +                       ERR_clear_error();
421  #endif
422  
423                         switch(con->mode) {
424 Index: src/configfile.c
425 ===================================================================
426 --- src/configfile.c    (.../tags/lighttpd-1.4.19)      (revision 2190)
427 +++ src/configfile.c    (.../branches/lighttpd-1.4.x)   (revision 2190)
428 @@ -7,6 +7,7 @@
429  #include <string.h>
430  #include <stdio.h>
431  #include <ctype.h>
432 +#include <limits.h>
433  #include <assert.h>
434  
435  #include "server.h"
436 @@ -305,9 +306,6 @@
437                 data_config *dc = (data_config *)srv->config_context->data[i];
438                 specific_config *s = srv->config_storage[i];
439  
440 -               /* not our stage */
441 -               if (comp != dc->comp) continue;
442 -
443                 /* condition didn't match */
444                 if (!config_check_cond(srv, con, dc)) continue;
445  
446 @@ -410,8 +408,8 @@
447  
448  #if 0
449  static int tokenizer_open(server *srv, tokenizer_t *t, buffer *basedir, const char *fn) {
450 -       if (buffer_is_empty(basedir) &&
451 -                       (fn[0] == '/' || fn[0] == '\\') &&
452 +       if (buffer_is_empty(basedir) ||
453 +                       (fn[0] == '/' || fn[0] == '\\') ||
454                         (fn[0] == '.' && (fn[1] == '/' || fn[1] == '\\'))) {
455                 t->file = buffer_init_string(fn);
456         } else {
457 @@ -884,8 +882,8 @@
458         int ret;
459         buffer *filename;
460  
461 -       if (buffer_is_empty(context->basedir) &&
462 -                       (fn[0] == '/' || fn[0] == '\\') &&
463 +       if (buffer_is_empty(context->basedir) ||
464 +                       (fn[0] == '/' || fn[0] == '\\') ||
465                         (fn[0] == '.' && (fn[1] == '/' || fn[1] == '\\'))) {
466                 filename = buffer_init_string(fn);
467         } else {
468 @@ -912,15 +910,39 @@
469         return ret;
470  }
471  
472 +static char* getCWD() {
473 +       char *s, *s1;
474 +       size_t len;
475 +#ifdef PATH_MAX
476 +       len = PATH_MAX;
477 +#else
478 +       len = 4096;
479 +#endif
480 +
481 +       s = malloc(len);
482 +       if (!s) return NULL;
483 +       while (NULL == getcwd(s, len)) {
484 +               if (errno != ERANGE || SSIZE_MAX - len < len) return NULL;
485 +               len *= 2;
486 +               s1 = realloc(s, len);
487 +               if (!s1) {
488 +                       free(s);
489 +                       return NULL;
490 +               }
491 +               s = s1;
492 +       }
493 +       return s;
494 +}
495 +
496  int config_parse_cmd(server *srv, config_t *context, const char *cmd) {
497         proc_handler_t proc;
498         tokenizer_t t;
499         int ret;
500         buffer *source;
501         buffer *out;
502 -       char oldpwd[PATH_MAX];
503 +       char *oldpwd;
504  
505 -       if (NULL == getcwd(oldpwd, sizeof(oldpwd))) {
506 +       if (NULL == (oldpwd = getCWD())) {
507                 log_error_write(srv, __FILE__, __LINE__, "s",
508                                 "cannot get cwd", strerror(errno));
509                 return -1;
510 @@ -945,6 +967,7 @@
511         buffer_free(source);
512         buffer_free(out);
513         chdir(oldpwd);
514 +       free(oldpwd);
515         return ret;
516  }
517  
518 Index: src/lemon.c
519 ===================================================================
520 --- src/lemon.c (.../tags/lighttpd-1.4.19)      (revision 2190)
521 +++ src/lemon.c (.../branches/lighttpd-1.4.x)   (revision 2190)
522 @@ -12,6 +12,19 @@
523  #include <ctype.h>
524  #include <stdlib.h>
525  
526 +#ifdef HAVE_CONFIG_H
527 +#include "config.h"
528 +#endif
529 +
530 +#ifdef HAVE_STDINT_H
531 +# include <stdint.h>
532 +#endif
533 +#ifdef HAVE_INTTYPES_H
534 +# include <inttypes.h>
535 +#endif
536 +
537 +#define UNUSED(x) ( (void)(x) )
538 +
539  extern void qsort();
540  extern double strtod();
541  extern long strtol();
542 @@ -983,6 +996,7 @@
543  {
544    struct symbol *spx, *spy;
545    int errcnt = 0;
546 +  UNUSED(errsym);
547    assert( apx->sp==apy->sp );  /* Otherwise there would be no conflict */
548    if( apx->type==SHIFT && apy->type==REDUCE ){
549      spx = apx->sp;
550 @@ -1347,6 +1361,7 @@
551    struct lemon lem;
552    char *def_tmpl_name = "lempar.c";
553  
554 +  UNUSED(argc);
555    OptInit(argv,options,stderr);
556    if( version ){
557       printf("Lemon version 1.0\n");
558 @@ -1651,7 +1666,7 @@
559    }else if( op[j].type==OPT_FLAG ){
560      *((int*)op[j].arg) = v;
561    }else if( op[j].type==OPT_FFLAG ){
562 -    (*(void(*)())(op[j].arg))(v);
563 +    (*(void(*)())(intptr_t)(op[j].arg))(v);
564    }else{
565      if( err ){
566        fprintf(err,"%smissing argument on switch.\n",emsg);
567 @@ -1733,19 +1748,19 @@
568          *(double*)(op[j].arg) = dv;
569          break;
570        case OPT_FDBL:
571 -        (*(void(*)())(op[j].arg))(dv);
572 +        (*(void(*)())(intptr_t)(op[j].arg))(dv);
573          break;
574        case OPT_INT:
575          *(int*)(op[j].arg) = lv;
576          break;
577        case OPT_FINT:
578 -        (*(void(*)())(op[j].arg))((int)lv);
579 +        (*(void(*)())(intptr_t)(op[j].arg))((int)lv);
580          break;
581        case OPT_STR:
582          *(char**)(op[j].arg) = sv;
583          break;
584        case OPT_FSTR:
585 -        (*(void(*)())(op[j].arg))(sv);
586 +        (*(void(*)())(intptr_t)(op[j].arg))(sv);
587          break;
588      }
589    }
590 @@ -2286,10 +2301,10 @@
591  ** token is passed to the function "parseonetoken" which builds all
592  ** the appropriate data structures in the global state vector "gp".
593  */
594 +struct pstate ps;
595  void Parse(gp)
596  struct lemon *gp;
597  {
598 -  struct pstate ps;
599    FILE *fp;
600    char *filebuf;
601    size_t filesize;
602 Index: src/mod_scgi.c
603 ===================================================================
604 --- src/mod_scgi.c      (.../tags/lighttpd-1.4.19)      (revision 2190)
605 +++ src/mod_scgi.c      (.../branches/lighttpd-1.4.x)   (revision 2190)
606 @@ -202,6 +202,15 @@
607          *
608          */
609  
610 +       /*
611 +        * workaround for program when prefix="/"
612 +        *
613 +        * rule to build PATH_INFO is hardcoded for when check_local is disabled
614 +        * enable this option to use the workaround
615 +        *
616 +        */
617 +
618 +       unsigned short fix_root_path_name;
619         ssize_t load; /* replace by host->load */
620  
621         size_t max_id; /* corresponds most of the time to
622 @@ -233,6 +242,7 @@
623  typedef struct {
624         buffer *key; /* like .php */
625  
626 +       int note_is_sent;
627         scgi_extension_host **hosts;
628  
629         size_t used;
630 @@ -968,6 +978,7 @@
631  
632                                                 { "bin-environment",   NULL, T_CONFIG_ARRAY, T_CONFIG_SCOPE_CONNECTION },        /* 11 */
633                                                 { "bin-copy-environment", NULL, T_CONFIG_ARRAY, T_CONFIG_SCOPE_CONNECTION },     /* 12 */
634 +                                               { "fix-root-scriptname",  NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION },   /* 13 */
635  
636  
637                                                 { NULL,                NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET }
638 @@ -990,6 +1001,7 @@
639                                         df->max_load_per_proc = 1;
640                                         df->idle_timeout = 60;
641                                         df->disable_time = 60;
642 +                                       df->fix_root_path_name = 0;
643  
644                                         fcv[0].destination = df->host;
645                                         fcv[1].destination = df->docroot;
646 @@ -1006,6 +1018,7 @@
647  
648                                         fcv[11].destination = df->bin_env;
649                                         fcv[12].destination = df->bin_env_copy;
650 +                                       fcv[13].destination = &(df->fix_root_path_name);
651  
652  
653                                         if (0 != config_insert_values_internal(srv, da_host->value, fcv)) {
654 @@ -2668,10 +2681,10 @@
655         plugin_data *p = p_d;
656         size_t s_len;
657         int used = -1;
658 -       int ndx;
659         size_t k;
660         buffer *fn;
661         scgi_extension *extension = NULL;
662 +       scgi_extension_host *host = NULL;
663  
664         /* Possibly, we processed already this request */
665         if (con->file_started == 1) return HANDLER_GO_ON;
666 @@ -2712,95 +2725,59 @@
667         }
668  
669         /* get best server */
670 -       for (k = 0, ndx = -1; k < extension->used; k++) {
671 -               scgi_extension_host *host = extension->hosts[k];
672 +       for (k = 0; k < extension->used; k++) {
673 +               scgi_extension_host *h = extension->hosts[k];
674  
675 -               /* we should have at least one proc that can do somthing */
676 -               if (host->active_procs == 0) continue;
677 +               /* we should have at least one proc that can do something */
678 +               if (h->active_procs == 0) {
679 +                       continue;
680 +               }
681  
682 -               if (used == -1 || host->load < used) {
683 -                       used = host->load;
684 +               if (used == -1 || h->load < used) {
685 +                       used = h->load;
686  
687 -                       ndx = k;
688 +                       host = h;
689                 }
690         }
691  
692 -       /* found a server */
693 -       if (ndx != -1) {
694 -               scgi_extension_host *host = extension->hosts[ndx];
695 +       if (!host) {
696 +               /* sorry, we don't have a server alive for this ext */
697 +               buffer_reset(con->physical.path);
698 +               con->http_status = 500;
699  
700 -               /*
701 -                * if check-local is disabled, use the uri.path handler
702 -                *
703 -                */
704 +               /* only send the 'no handler' once */
705 +               if (!extension->note_is_sent) {
706 +                       extension->note_is_sent = 1;
707  
708 -               /* init handler-context */
709 -               if (uri_path_handler) {
710 -                       if (host->check_local == 0) {
711 -                               handler_ctx *hctx;
712 -                               char *pathinfo;
713 +                       log_error_write(srv, __FILE__, __LINE__, "sbsbs",
714 +                                       "all handlers for ", con->uri.path,
715 +                                       "on", extension->key,
716 +                                       "are down.");
717 +               }
718  
719 -                               hctx = handler_ctx_init();
720 +               return HANDLER_FINISHED;
721 +       }
722  
723 -                               hctx->remote_conn      = con;
724 -                               hctx->plugin_data      = p;
725 -                               hctx->host             = host;
726 -                               hctx->proc             = NULL;
727 +       /* a note about no handler is not sent yet */
728 +       extension->note_is_sent = 0;
729  
730 -                               hctx->conf.exts        = p->conf.exts;
731 -                               hctx->conf.debug       = p->conf.debug;
732 +       /*
733 +        * if check-local is disabled, use the uri.path handler
734 +        *
735 +        */
736  
737 -                               con->plugin_ctx[p->id] = hctx;
738 +       /* init handler-context */
739 +       if (uri_path_handler) {
740 +               if (host->check_local == 0) {
741 +                       handler_ctx *hctx;
742 +                       char *pathinfo;
743  
744 -                               host->load++;
745 -
746 -                               con->mode = p->id;
747 -
748 -                               if (con->conf.log_request_handling) {
749 -                                       log_error_write(srv, __FILE__, __LINE__, "s", "handling it in mod_scgi");
750 -                               }
751 -
752 -                               /* the prefix is the SCRIPT_NAME,
753 -                                * everthing from start to the next slash
754 -                                * this is important for check-local = "disable"
755 -                                *
756 -                                * if prefix = /admin.fcgi
757 -                                *
758 -                                * /admin.fcgi/foo/bar
759 -                                *
760 -                                * SCRIPT_NAME = /admin.fcgi
761 -                                * PATH_INFO   = /foo/bar
762 -                                *
763 -                                * if prefix = /fcgi-bin/
764 -                                *
765 -                                * /fcgi-bin/foo/bar
766 -                                *
767 -                                * SCRIPT_NAME = /fcgi-bin/foo
768 -                                * PATH_INFO   = /bar
769 -                                *
770 -                                */
771 -
772 -                               /* the rewrite is only done for /prefix/? matches */
773 -                               if (extension->key->ptr[0] == '/' &&
774 -                                   con->uri.path->used > extension->key->used &&
775 -                                   NULL != (pathinfo = strchr(con->uri.path->ptr + extension->key->used - 1, '/'))) {
776 -                                       /* rewrite uri.path and pathinfo */
777 -
778 -                                       buffer_copy_string(con->request.pathinfo, pathinfo);
779 -
780 -                                       con->uri.path->used -= con->request.pathinfo->used - 1;
781 -                                       con->uri.path->ptr[con->uri.path->used - 1] = '\0';
782 -                               }
783 -                       }
784 -                       return HANDLER_GO_ON;
785 -               } else {
786 -                       handler_ctx *hctx;
787                         hctx = handler_ctx_init();
788  
789                         hctx->remote_conn      = con;
790                         hctx->plugin_data      = p;
791                         hctx->host             = host;
792 -                       hctx->proc             = NULL;
793 +                       hctx->proc             = NULL;
794  
795                         hctx->conf.exts        = p->conf.exts;
796                         hctx->conf.debug       = p->conf.debug;
797 @@ -2812,22 +2789,69 @@
798                         con->mode = p->id;
799  
800                         if (con->conf.log_request_handling) {
801 -                               log_error_write(srv, __FILE__, __LINE__, "s", "handling it in mod_fastcgi");
802 +                               log_error_write(srv, __FILE__, __LINE__, "s",
803 +                               "handling it in mod_fastcgi");
804                         }
805  
806 -                       return HANDLER_GO_ON;
807 +                       /* the prefix is the SCRIPT_NAME,
808 +                        * everything from start to the next slash
809 +                        * this is important for check-local = "disable"
810 +                        *
811 +                        * if prefix = /admin.fcgi
812 +                        *
813 +                        * /admin.fcgi/foo/bar
814 +                        *
815 +                        * SCRIPT_NAME = /admin.fcgi
816 +                        * PATH_INFO   = /foo/bar
817 +                        *
818 +                        * if prefix = /fcgi-bin/
819 +                        *
820 +                        * /fcgi-bin/foo/bar
821 +                        *
822 +                        * SCRIPT_NAME = /fcgi-bin/foo
823 +                        * PATH_INFO   = /bar
824 +                        *
825 +                        */
826 +
827 +                       /* the rewrite is only done for /prefix/? matches */
828 +                       if (extension->key->ptr[0] == '/' &&
829 +                           con->uri.path->used > extension->key->used &&
830 +                           NULL != (pathinfo = strchr(con->uri.path->ptr + extension->key->used - 1, '/'))) {
831 +                               /* rewrite uri.path and pathinfo */
832 +
833 +                               buffer_copy_string(con->request.pathinfo, pathinfo);
834 +
835 +                               con->uri.path->used -= con->request.pathinfo->used - 1;
836 +                               con->uri.path->ptr[con->uri.path->used - 1] = '\0';
837 +                       } else if (host->fix_root_path_name && extension->key->ptr[0] == '/' && extension->key->ptr[1] == '\0') {
838 +                               buffer_copy_string(con->request.pathinfo, con->uri.path->ptr);
839 +                               con->uri.path->used = 1;
840 +                               con->uri.path->ptr[con->uri.path->used - 1] = '\0';
841 +                       }
842                 }
843         } else {
844 -               /* no handler found */
845 -               buffer_reset(con->physical.path);
846 -               con->http_status = 500;
847 +               handler_ctx *hctx;
848 +               hctx = handler_ctx_init();
849  
850 -               log_error_write(srv, __FILE__, __LINE__,  "sb",
851 -                               "no fcgi-handler found for:",
852 -                               fn);
853 +               hctx->remote_conn      = con;
854 +               hctx->plugin_data      = p;
855 +               hctx->host             = host;
856 +               hctx->proc             = NULL;
857  
858 -               return HANDLER_FINISHED;
859 +               hctx->conf.exts        = p->conf.exts;
860 +               hctx->conf.debug       = p->conf.debug;
861 +
862 +               con->plugin_ctx[p->id] = hctx;
863 +
864 +               host->load++;
865 +
866 +               con->mode = p->id;
867 +
868 +               if (con->conf.log_request_handling) {
869 +                       log_error_write(srv, __FILE__, __LINE__, "s", "handling it in mod_fastcgi");
870 +               }
871         }
872 +
873         return HANDLER_GO_ON;
874  }
875  
876 Index: src/lighttpd-angel.c
877 ===================================================================
878 --- src/lighttpd-angel.c        (.../tags/lighttpd-1.4.19)      (revision 2190)
879 +++ src/lighttpd-angel.c        (.../branches/lighttpd-1.4.x)   (revision 2190)
880 @@ -28,9 +28,12 @@
881  static volatile sig_atomic_t graceful_restart = 0;
882  static volatile pid_t pid = -1;
883  
884 +#define UNUSED(x) ( (void)(x) )
885 +
886  static void sigaction_handler(int sig, siginfo_t *si, void *context) {
887         int exitcode;
888  
889 +       UNUSED(context);
890         switch (sig) {
891         case SIGINT: 
892         case SIGTERM:
893 @@ -60,6 +63,8 @@
894         int is_shutdown = 0;
895         struct sigaction act;
896  
897 +       UNUSED(argc);
898 +
899         /**
900          * we are running as root BEWARE
901          */
902 Index: src/mod_rrdtool.c
903 ===================================================================
904 --- src/mod_rrdtool.c   (.../tags/lighttpd-1.4.19)      (revision 2190)
905 +++ src/mod_rrdtool.c   (.../branches/lighttpd-1.4.x)   (revision 2190)
906 @@ -148,6 +148,8 @@
907                 args[i++] = dash;
908                 args[i++] = NULL;
909  
910 +               openDevNull(STDERR_FILENO);
911 +       
912                 /* we don't need the client socket */
913                 for (i = 3; i < 256; i++) {
914                         close(i);
915 @@ -156,7 +158,7 @@
916                 /* exec the cgi */
917                 execv(args[0], args);
918  
919 -               log_error_write(srv, __FILE__, __LINE__, "sss", "spawing rrdtool failed: ", strerror(errno), args[0]);
920 +               /* log_error_write(srv, __FILE__, __LINE__, "sss", "spawing rrdtool failed: ", strerror(errno), args[0]); */
921  
922                 /* */
923                 SEGFAULT();
924 Index: src/response.c
925 ===================================================================
926 --- src/response.c      (.../tags/lighttpd-1.4.19)      (revision 2190)
927 +++ src/response.c      (.../branches/lighttpd-1.4.x)   (revision 2190)
928 @@ -101,7 +101,7 @@
929         if (!have_server) {
930                 if (buffer_is_empty(con->conf.server_tag)) {
931                         BUFFER_APPEND_STRING_CONST(b, "\r\nServer: " PACKAGE_NAME "/" PACKAGE_VERSION);
932 -               } else {
933 +               } else if (con->conf.server_tag->used > 1) {
934                         BUFFER_APPEND_STRING_CONST(b, "\r\nServer: ");
935                         buffer_append_string_encoded(b, CONST_BUF_LEN(con->conf.server_tag), ENCODING_HTTP_HEADER);
936                 }
937 @@ -152,7 +152,7 @@
938                  *  */
939  
940                 config_cond_cache_reset(srv, con);
941 -               config_setup_connection(srv, con); // Perhaps this could be removed at other places.
942 +               config_setup_connection(srv, con); /* Perhaps this could be removed at other places. */
943  
944                 if (con->conf.log_condition_handling) {
945                         log_error_write(srv, __FILE__, __LINE__,  "s",  "run condition");
946 Index: src/plugin.c
947 ===================================================================
948 --- src/plugin.c        (.../tags/lighttpd-1.4.19)      (revision 2190)
949 +++ src/plugin.c        (.../branches/lighttpd-1.4.x)   (revision 2190)
950 @@ -197,7 +197,7 @@
951  
952  #else
953  #if 1
954 -               init = (int (*)(plugin *))dlsym(p->lib, srv->tmp_buf->ptr);
955 +               init = (int (*)(plugin *))(intptr_t)dlsym(p->lib, srv->tmp_buf->ptr);
956  #else
957                 *(void **)(&init) = dlsym(p->lib, srv->tmp_buf->ptr);
958  #endif
959 Index: src/SConscript
960 ===================================================================
961 --- src/SConscript      (.../tags/lighttpd-1.4.19)      (revision 2190)
962 +++ src/SConscript      (.../branches/lighttpd-1.4.x)   (revision 2190)
963 @@ -43,6 +43,7 @@
964         'mod_cgi' : { 'src' : [ 'mod_cgi.c' ] },
965         'mod_fastcgi' : { 'src' : [ 'mod_fastcgi.c' ] },
966         'mod_scgi' : { 'src' : [ 'mod_scgi.c' ] },
967 +       'mod_extforward' : { 'src' : [ 'mod_extforward.c' ] },
968         'mod_staticfile' : { 'src' : [ 'mod_staticfile.c' ] },
969         'mod_dirlisting' : { 'src' : [ 'mod_dirlisting.c' ], 'lib' : [ env['LIBPCRE'] ] },
970         'mod_indexfile' : { 'src' : [ 'mod_indexfile.c' ] },
971 Index: src/mod_extforward.c
972 ===================================================================
973 --- src/mod_extforward.c        (.../tags/lighttpd-1.4.19)      (revision 2190)
974 +++ src/mod_extforward.c        (.../branches/lighttpd-1.4.x)   (revision 2190)
975 @@ -281,8 +281,9 @@
976  static const char *last_not_in_array(array *a, plugin_data *p)
977  {
978         array *forwarder = p->conf.forwarder;
979 +       int i;
980  
981 -       for (int i = a->used - 1; i >= 0; i--) {
982 +       for (i = a->used - 1; i >= 0; i--) {
983                 data_string *ds = (data_string *)a->data[i];
984                 const char *ip = ds->value->ptr;
985  
986 Index: src/Makefile.am
987 ===================================================================
988 --- src/Makefile.am     (.../tags/lighttpd-1.4.19)      (revision 2190)
989 +++ src/Makefile.am     (.../branches/lighttpd-1.4.x)   (revision 2190)
990 @@ -16,20 +16,17 @@
991  configparser.c configparser.h:
992  mod_ssi_exprparser.c mod_ssi_exprparser.h:
993  else
994 -$(srcdir)/configparser.y: lemon
995 -$(srcdir)/mod_ssi_exprparser.y: lemon
996 -
997 -configparser.c configparser.h: $(srcdir)/configparser.y
998 +configparser.c configparser.h: lemon $(srcdir)/configparser.y $(srcdir)/lempar.c
999         rm -f configparser.h
1000         $(LEMON) -q $(srcdir)/configparser.y $(srcdir)/lempar.c
1001  
1002 -mod_ssi_exprparser.c mod_ssi_exprparser.h: $(srcdir)/mod_ssi_exprparser.y
1003 +mod_ssi_exprparser.c mod_ssi_exprparser.h: lemon $(srcdir)/mod_ssi_exprparser.y $(srcdir)/lempar.c
1004         rm -f mod_ssi_exprparser.h
1005         $(LEMON) -q $(srcdir)/mod_ssi_exprparser.y $(srcdir)/lempar.c
1006  endif
1007  
1008 -$(srcdir)/configfile.c: configparser.h
1009 -$(srcdir)/mod_ssi_expr.c: mod_ssi_exprparser.h
1010 +configfile.o: configparser.h
1011 +mod_ssi_expr.o: mod_ssi_exprparser.h
1012  
1013  common_src=buffer.c log.c \
1014        keyvalue.c chunk.c  \
1015 Index: src/network_openssl.c
1016 ===================================================================
1017 --- src/network_openssl.c       (.../tags/lighttpd-1.4.19)      (revision 2190)
1018 +++ src/network_openssl.c       (.../branches/lighttpd-1.4.x)   (revision 2190)
1019 @@ -85,6 +85,7 @@
1020                          *
1021                          */
1022  
1023 +                       ERR_clear_error();
1024                         if ((r = SSL_write(ssl, offset, toSend)) <= 0) {
1025                                 unsigned long err;
1026  
1027 @@ -187,6 +188,7 @@
1028  
1029                                 close(ifd);
1030  
1031 +                               ERR_clear_error();
1032                                 if ((r = SSL_write(ssl, s, toSend)) <= 0) {
1033                                         unsigned long err;
1034  
1035 Index: src/mod_redirect.c
1036 ===================================================================
1037 --- src/mod_redirect.c  (.../tags/lighttpd-1.4.19)      (revision 2190)
1038 +++ src/mod_redirect.c  (.../branches/lighttpd-1.4.x)   (revision 2190)
1039 @@ -215,8 +215,7 @@
1040  
1041                         start = 0; end = pattern_len;
1042                         for (k = 0; k < pattern_len; k++) {
1043 -                               if ((pattern[k] == '$' || pattern[k] == '%') &&
1044 -                                   isdigit((unsigned char)pattern[k + 1])) {
1045 +                               if (pattern[k] == '$' || pattern[k] == '%') {
1046                                         /* got one */
1047  
1048                                         size_t num = pattern[k + 1] - '0';
1049 @@ -225,7 +224,10 @@
1050  
1051                                         buffer_append_string_len(p->location, pattern + start, end - start);
1052  
1053 -                                       if (pattern[k] == '$') {
1054 +                                       if (!isdigit((unsigned char)pattern[k + 1])) {
1055 +                                               /* enable escape: "%%" => "%", "%a" => "%a", "$$" => "$" */
1056 +                                               buffer_append_string_len(p->location, pattern+k, pattern[k] == pattern[k+1] ? 1 : 2);
1057 +                                       } else if (pattern[k] == '$') {
1058                                                 /* n is always > 0 */
1059                                                 if (num < (size_t)n) {
1060                                                         buffer_append_string(p->location, list[num]);
1061 Index: src/mod_webdav.c
1062 ===================================================================
1063 --- src/mod_webdav.c    (.../tags/lighttpd-1.4.19)      (revision 2190)
1064 +++ src/mod_webdav.c    (.../branches/lighttpd-1.4.x)   (revision 2190)
1065 @@ -570,6 +570,8 @@
1066                                 /* */
1067                         }
1068                 }
1069 +#else
1070 +               UNUSED(p);
1071  #endif
1072         }
1073  
1074 @@ -730,6 +732,8 @@
1075                         }
1076                 }
1077         }
1078 +#else
1079 +       UNUSED(p);
1080  #endif
1081         return status;
1082  }
1083 @@ -1154,6 +1158,7 @@
1084         int has_lock = 1;
1085  
1086  #ifdef USE_LOCKS
1087 +       UNUSED(srv);
1088         data_string *ds;
1089  
1090         /**
1091 @@ -1192,6 +1197,11 @@
1092                         has_lock = 0;
1093                 }
1094         }
1095 +#else
1096 +       UNUSED(srv);
1097 +       UNUSED(con);
1098 +       UNUSED(p);
1099 +       UNUSED(uri);
1100  #endif
1101  
1102         return has_lock;
1103 Index: src/md5.c
1104 ===================================================================
1105 --- src/md5.c   (.../tags/lighttpd-1.4.19)      (revision 2190)
1106 +++ src/md5.c   (.../branches/lighttpd-1.4.x)   (revision 2190)
1107 @@ -52,9 +52,9 @@
1108  #define S43 15
1109  #define S44 21
1110  
1111 -static void MD5Transform (UINT4 [4], unsigned char [64]);
1112 +static void MD5Transform (UINT4 [4], const unsigned char [64]);
1113  static void Encode (unsigned char *, UINT4 *, unsigned int);
1114 -static void Decode (UINT4 *, unsigned char *, unsigned int);
1115 +static void Decode (UINT4 *, const unsigned char *, unsigned int);
1116  
1117  #ifdef HAVE_MEMCPY
1118  #define MD5_memcpy(output, input, len) memcpy((output), (input), (len))
1119 @@ -126,12 +126,13 @@
1120    operation, processing another message block, and updating the
1121    context.
1122   */
1123 -void MD5_Update (context, input, inputLen)
1124 +void MD5_Update (context, _input, inputLen)
1125  MD5_CTX *context;                                        /* context */
1126 -unsigned char *input;                                /* input block */
1127 +const void *_input;                                /* input block */
1128  unsigned int inputLen;                     /* length of input block */
1129  {
1130    unsigned int i, ndx, partLen;
1131 +  const unsigned char *input = (const unsigned char*) _input;
1132  
1133    /* Compute number of bytes mod 64 */
1134    ndx = (unsigned int)((context->count[0] >> 3) & 0x3F);
1135 @@ -200,7 +201,7 @@
1136   */
1137  static void MD5Transform (state, block)
1138  UINT4 state[4];
1139 -unsigned char block[64];
1140 +const unsigned char block[64];
1141  {
1142    UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
1143  
1144 @@ -313,7 +314,7 @@
1145   */
1146  static void Decode (output, input, len)
1147  UINT4 *output;
1148 -unsigned char *input;
1149 +const unsigned char *input;
1150  unsigned int len;
1151  {
1152    unsigned int i, j;
1153 Index: src/mod_compress.c
1154 ===================================================================
1155 --- src/mod_compress.c  (.../tags/lighttpd-1.4.19)      (revision 2190)
1156 +++ src/mod_compress.c  (.../branches/lighttpd-1.4.x)   (revision 2190)
1157 @@ -102,7 +102,7 @@
1158         return HANDLER_GO_ON;
1159  }
1160  
1161 -// 0 on success, -1 for error
1162 +/* 0 on success, -1 for error */
1163  int mkdir_recursive(char *dir) {
1164         char *p = dir;
1165  
1166 @@ -118,13 +118,13 @@
1167                 }
1168  
1169                 *p++ = '/';
1170 -               if (!*p) return 0; // Ignore trailing slash
1171 +               if (!*p) return 0; /* Ignore trailing slash */
1172         }
1173  
1174         return (mkdir(dir, 0700) != 0) && (errno != EEXIST) ? -1 : 0;
1175  }
1176  
1177 -// 0 on success, -1 for error
1178 +/* 0 on success, -1 for error */
1179  int mkdir_for_file(char *filename) {
1180         char *p = filename;
1181  
1182 @@ -140,7 +140,7 @@
1183                 }
1184  
1185                 *p++ = '/';
1186 -               if (!*p) return -1; // Unexpected trailing slash in filename
1187 +               if (!*p) return -1; /* Unexpected trailing slash in filename */
1188         }
1189  
1190         return 0;
1191 @@ -178,9 +178,9 @@
1192                 }
1193  
1194                 if (!buffer_is_empty(s->compress_cache_dir)) {
1195 +                       struct stat st;
1196                         mkdir_recursive(s->compress_cache_dir->ptr);
1197  
1198 -                       struct stat st;
1199                         if (0 != stat(s->compress_cache_dir->ptr, &st)) {
1200                                 log_error_write(srv, __FILE__, __LINE__, "sbs", "can't stat compress.cache-dir",
1201                                                 s->compress_cache_dir, strerror(errno));
1202 Index: src/md5.h
1203 ===================================================================
1204 --- src/md5.h   (.../tags/lighttpd-1.4.19)      (revision 2190)
1205 +++ src/md5.h   (.../branches/lighttpd-1.4.x)   (revision 2190)
1206 @@ -42,6 +42,6 @@
1207  } MD5_CTX;
1208  
1209  void MD5_Init (MD5_CTX *);
1210 -void MD5_Update (MD5_CTX *, unsigned char *, unsigned int);
1211 +void MD5_Update (MD5_CTX *, const void *, unsigned int);
1212  void MD5_Final (unsigned char [16], MD5_CTX *);
1213  
1214 Index: src/mod_auth.c
1215 ===================================================================
1216 --- src/mod_auth.c      (.../tags/lighttpd-1.4.19)      (revision 2190)
1217 +++ src/mod_auth.c      (.../branches/lighttpd-1.4.x)   (revision 2190)
1218 @@ -519,85 +519,86 @@
1219  
1220  handler_t auth_ldap_init(server *srv, mod_auth_plugin_config *s) {
1221  #ifdef USE_LDAP
1222 -                       int ret;
1223 +       int ret;
1224  #if 0
1225 -                       if (s->auth_ldap_basedn->used == 0) {
1226 -                               log_error_write(srv, __FILE__, __LINE__, "s", "ldap: auth.backend.ldap.base-dn has to be set");
1227 +       if (s->auth_ldap_basedn->used == 0) {
1228 +               log_error_write(srv, __FILE__, __LINE__, "s", "ldap: auth.backend.ldap.base-dn has to be set");
1229  
1230 -                               return HANDLER_ERROR;
1231 -                       }
1232 +               return HANDLER_ERROR;
1233 +       }
1234  #endif
1235  
1236 -                       if (s->auth_ldap_filter->used) {
1237 -                               char *dollar;
1238 +       if (s->auth_ldap_filter->used) {
1239 +               char *dollar;
1240  
1241 -                               /* parse filter */
1242 +               /* parse filter */
1243  
1244 -                               if (NULL == (dollar = strchr(s->auth_ldap_filter->ptr, '$'))) {
1245 -                                       log_error_write(srv, __FILE__, __LINE__, "s", "ldap: auth.backend.ldap.filter is missing a replace-operator '$'");
1246 +               if (NULL == (dollar = strchr(s->auth_ldap_filter->ptr, '$'))) {
1247 +                       log_error_write(srv, __FILE__, __LINE__, "s", "ldap: auth.backend.ldap.filter is missing a replace-operator '$'");
1248  
1249 -                                       return HANDLER_ERROR;
1250 -                               }
1251 +                       return HANDLER_ERROR;
1252 +               }
1253  
1254 -                               buffer_copy_string_len(s->ldap_filter_pre, s->auth_ldap_filter->ptr, dollar - s->auth_ldap_filter->ptr);
1255 -                               buffer_copy_string(s->ldap_filter_post, dollar+1);
1256 -                       }
1257 +               buffer_copy_string_len(s->ldap_filter_pre, s->auth_ldap_filter->ptr, dollar - s->auth_ldap_filter->ptr);
1258 +               buffer_copy_string(s->ldap_filter_post, dollar+1);
1259 +       }
1260  
1261 -                       if (s->auth_ldap_hostname->used) {
1262 -                               if (NULL == (s->ldap = ldap_init(s->auth_ldap_hostname->ptr, LDAP_PORT))) {
1263 -                                       log_error_write(srv, __FILE__, __LINE__, "ss", "ldap ...", strerror(errno));
1264 +       if (s->auth_ldap_hostname->used) {
1265 +               if (NULL == (s->ldap = ldap_init(s->auth_ldap_hostname->ptr, LDAP_PORT))) {
1266 +                       log_error_write(srv, __FILE__, __LINE__, "ss", "ldap ...", strerror(errno));
1267  
1268 -                                       return HANDLER_ERROR;
1269 -                               }
1270 +                       return HANDLER_ERROR;
1271 +               }
1272  
1273 -                               ret = LDAP_VERSION3;
1274 -                               if (LDAP_OPT_SUCCESS != (ret = ldap_set_option(s->ldap, LDAP_OPT_PROTOCOL_VERSION, &ret))) {
1275 -                                       log_error_write(srv, __FILE__, __LINE__, "ss", "ldap:", ldap_err2string(ret));
1276 +               ret = LDAP_VERSION3;
1277 +               if (LDAP_OPT_SUCCESS != (ret = ldap_set_option(s->ldap, LDAP_OPT_PROTOCOL_VERSION, &ret))) {
1278 +                       log_error_write(srv, __FILE__, __LINE__, "ss", "ldap:", ldap_err2string(ret));
1279  
1280 +                       return HANDLER_ERROR;
1281 +               }
1282 +
1283 +               if (s->auth_ldap_starttls) {
1284 +                       /* if no CA file is given, it is ok, as we will use encryption
1285 +                               * if the server requires a CAfile it will tell us */
1286 +                       if (!buffer_is_empty(s->auth_ldap_cafile)) {
1287 +                               if (LDAP_OPT_SUCCESS != (ret = ldap_set_option(NULL, LDAP_OPT_X_TLS_CACERTFILE,
1288 +                                                               s->auth_ldap_cafile->ptr))) {
1289 +                                       log_error_write(srv, __FILE__, __LINE__, "ss",
1290 +                                                       "Loading CA certificate failed:", ldap_err2string(ret));
1291 +
1292                                         return HANDLER_ERROR;
1293                                 }
1294 +                       }
1295  
1296 -                               if (s->auth_ldap_starttls) {
1297 -                                       /* if no CA file is given, it is ok, as we will use encryption
1298 -                                        * if the server requires a CAfile it will tell us */
1299 -                                       if (!buffer_is_empty(s->auth_ldap_cafile)) {
1300 -                                               if (LDAP_OPT_SUCCESS != (ret = ldap_set_option(NULL, LDAP_OPT_X_TLS_CACERTFILE,
1301 -                                                                               s->auth_ldap_cafile->ptr))) {
1302 -                                                       log_error_write(srv, __FILE__, __LINE__, "ss",
1303 -                                                                       "Loading CA certificate failed:", ldap_err2string(ret));
1304 +                       if (LDAP_OPT_SUCCESS != (ret = ldap_start_tls_s(s->ldap, NULL,  NULL))) {
1305 +                               log_error_write(srv, __FILE__, __LINE__, "ss", "ldap startTLS failed:", ldap_err2string(ret));
1306  
1307 -                                                       return HANDLER_ERROR;
1308 -                                               }
1309 -                                       }
1310 +                               return HANDLER_ERROR;
1311 +                       }
1312 +               }
1313  
1314 -                                       if (LDAP_OPT_SUCCESS != (ret = ldap_start_tls_s(s->ldap, NULL,  NULL))) {
1315 -                                               log_error_write(srv, __FILE__, __LINE__, "ss", "ldap startTLS failed:", ldap_err2string(ret));
1316  
1317 -                                               return HANDLER_ERROR;
1318 -                                       }
1319 -                               }
1320 +               /* 1. */
1321 +               if (s->auth_ldap_binddn->used) {
1322 +                       if (LDAP_SUCCESS != (ret = ldap_simple_bind_s(s->ldap, s->auth_ldap_binddn->ptr, s->auth_ldap_bindpw->ptr))) {
1323 +                               log_error_write(srv, __FILE__, __LINE__, "ss", "ldap:", ldap_err2string(ret));
1324  
1325 +                               return HANDLER_ERROR;
1326 +                       }
1327 +               } else {
1328 +                       if (LDAP_SUCCESS != (ret = ldap_simple_bind_s(s->ldap, NULL, NULL))) {
1329 +                               log_error_write(srv, __FILE__, __LINE__, "ss", "ldap:", ldap_err2string(ret));
1330  
1331 -                               /* 1. */
1332 -                               if (s->auth_ldap_binddn->used) {
1333 -                                       if (LDAP_SUCCESS != (ret = ldap_simple_bind_s(s->ldap, s->auth_ldap_binddn->ptr, s->auth_ldap_bindpw->ptr))) {
1334 -                                               log_error_write(srv, __FILE__, __LINE__, "ss", "ldap:", ldap_err2string(ret));
1335 -
1336 -                                               return HANDLER_ERROR;
1337 -                                       }
1338 -                               } else {
1339 -                                       if (LDAP_SUCCESS != (ret = ldap_simple_bind_s(s->ldap, NULL, NULL))) {
1340 -                                               log_error_write(srv, __FILE__, __LINE__, "ss", "ldap:", ldap_err2string(ret));
1341 -
1342 -                                               return HANDLER_ERROR;
1343 -                                       }
1344 -                               }
1345 +                               return HANDLER_ERROR;
1346                         }
1347 +               }
1348 +       }
1349 +       return HANDLER_GO_ON;
1350  #else
1351 -                       log_error_write(srv, __FILE__, __LINE__, "s", "no ldap support available");
1352 -                       return HANDLER_ERROR;
1353 +       UNUSED(s);
1354 +       log_error_write(srv, __FILE__, __LINE__, "s", "no ldap support available");
1355 +       return HANDLER_ERROR;
1356  #endif
1357 -               return HANDLER_GO_ON;
1358  }
1359  
1360  int mod_auth_plugin_init(plugin *p) {
1361 Index: src/mod_fastcgi.c
1362 ===================================================================
1363 --- src/mod_fastcgi.c   (.../tags/lighttpd-1.4.19)      (revision 2190)
1364 +++ src/mod_fastcgi.c   (.../branches/lighttpd-1.4.x)   (revision 2190)
1365 @@ -236,6 +236,16 @@
1366         unsigned short break_scriptfilename_for_php;
1367  
1368         /*
1369 +        * workaround for program when prefix="/"
1370 +        *
1371 +        * rule to build PATH_INFO is hardcoded for when check_local is disabled
1372 +        * enable this option to use the workaround
1373 +        *
1374 +        */
1375 +
1376 +       unsigned short fix_root_path_name;
1377 +
1378 +       /*
1379          * If the backend includes X-LIGHTTPD-send-file in the response
1380          * we use the value as filename and ignore the content.
1381          *
1382 @@ -937,6 +947,8 @@
1383                                 close(fcgi_fd);
1384                         }
1385  
1386 +                       openDevNull(STDERR_FILENO);
1387 +
1388                         /* we don't need the client socket */
1389                         for (i = 3; i < 256; i++) {
1390                                 close(i);
1391 @@ -1000,8 +1012,8 @@
1392                         /* exec the cgi */
1393                         execve(arg.ptr[0], arg.ptr, env.ptr);
1394  
1395 -                       log_error_write(srv, __FILE__, __LINE__, "sbs",
1396 -                                       "execve failed for:", host->bin_path, strerror(errno));
1397 +                       /* log_error_write(srv, __FILE__, __LINE__, "sbs",
1398 +                                       "execve failed for:", host->bin_path, strerror(errno)); */
1399  
1400                         exit(errno);
1401  
1402 @@ -1193,6 +1205,7 @@
1403                                                 { "allow-x-send-file",  NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION },      /* 15 */
1404                                                 { "strip-request-uri",  NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION },      /* 16 */
1405                                                 { "kill-signal",        NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION },      /* 17 */
1406 +                                               { "fix-root-scriptname",   NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION },  /* 18 */
1407  
1408                                                 { NULL,                NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET }
1409                                         };
1410 @@ -1220,6 +1233,7 @@
1411                                         host->break_scriptfilename_for_php = 0;
1412                                         host->allow_xsendfile = 0; /* handle X-LIGHTTPD-send-file */
1413                                         host->kill_signal = SIGTERM;
1414 +                                       host->fix_root_path_name = 0;
1415  
1416                                         fcv[0].destination = host->host;
1417                                         fcv[1].destination = host->docroot;
1418 @@ -1241,6 +1255,7 @@
1419                                         fcv[15].destination = &(host->allow_xsendfile);
1420                                         fcv[16].destination = host->strip_request_uri;
1421                                         fcv[17].destination = &(host->kill_signal);
1422 +                                       fcv[18].destination = &(host->fix_root_path_name);
1423  
1424                                         if (0 != config_insert_values_internal(srv, da_host->value, fcv)) {
1425                                                 return HANDLER_ERROR;
1426 @@ -2544,7 +2559,10 @@
1427                                         stat_cache_entry *sce;
1428  
1429                                         if (HANDLER_ERROR != stat_cache_get_entry(srv, con, ds->value, &sce)) {
1430 -                                               data_string *dcls = data_string_init();
1431 +                                               data_string *dcls;
1432 +                                               if (NULL == (dcls = (data_string *)array_get_unused_element(con->response.headers, TYPE_STRING))) {
1433 +                                                       dcls = data_response_init();
1434 +                                               }
1435                                                 /* found */
1436                                                 http_chunk_append_file(srv, con, ds->value, 0, sce->st.st_size);
1437                                                 hctx->send_content_body = 0; /* ignore the content */
1438 @@ -3074,7 +3092,7 @@
1439  
1440                 /* check if the next server has no load. */
1441                 ndx = hctx->ext->last_used_ndx + 1;
1442 -               if(ndx >= hctx->ext->used || ndx < 0) ndx = 0;
1443 +               if(ndx >= (int) hctx->ext->used || ndx < 0) ndx = 0;
1444                 host = hctx->ext->hosts[ndx];
1445                 if (host->load > 0) {
1446                         /* get backend with the least load. */
1447 @@ -3480,13 +3498,12 @@
1448  
1449                         ct_len = extension->key->used - 1;
1450  
1451 -                       if (s_len < ct_len) continue;
1452 -
1453 -                       /* check extension in the form "/fcgi_pattern" */
1454 -                       if (*(extension->key->ptr) == '/') {
1455 -                               if (strncmp(fn->ptr, extension->key->ptr, ct_len) == 0)
1456 +                       /* check _url_ in the form "/fcgi_pattern" */
1457 +                       if (extension->key->ptr[0] == '/') {
1458 +                               if ((ct_len <= con->uri.path->used -1) &&
1459 +                                   (strncmp(con->uri.path->ptr, extension->key->ptr, ct_len) == 0))
1460                                         break;
1461 -                       } else if (0 == strncmp(fn->ptr + s_len - ct_len, extension->key->ptr, ct_len)) {
1462 +                       } else if ((ct_len <= s_len) && (0 == strncmp(fn->ptr + s_len - ct_len, extension->key->ptr, ct_len))) {
1463                                 /* check extension in the form ".fcg" */
1464                                 break;
1465                         }
1466 @@ -3499,16 +3516,15 @@
1467  
1468         /* check if we have at least one server for this extension up and running */
1469         for (k = 0; k < extension->used; k++) {
1470 -               host = extension->hosts[k];
1471 +               fcgi_extension_host *h = extension->hosts[k];
1472  
1473                 /* we should have at least one proc that can do something */
1474 -               if (host->active_procs == 0) {
1475 -                       host = NULL;
1476 -
1477 +               if (h->active_procs == 0) {
1478                         continue;
1479                 }
1480  
1481                 /* we found one host that is alive */
1482 +               host = h;
1483                 break;
1484         }
1485  
1486 @@ -3582,6 +3598,13 @@
1487                          * SCRIPT_NAME = /fcgi-bin/foo
1488                          * PATH_INFO   = /bar
1489                          *
1490 +                        * if prefix = /, and fix-root-path-name is enable
1491 +                        *
1492 +                        * /fcgi-bin/foo/bar
1493 +                        *
1494 +                        * SCRIPT_NAME = /fcgi-bin/foo
1495 +                        * PATH_INFO   = /bar
1496 +                        *
1497                          */
1498  
1499                         /* the rewrite is only done for /prefix/? matches */
1500 @@ -3594,6 +3617,10 @@
1501  
1502                                 con->uri.path->used -= con->request.pathinfo->used - 1;
1503                                 con->uri.path->ptr[con->uri.path->used - 1] = '\0';
1504 +                       } else if (host->fix_root_path_name && extension->key->ptr[0] == '/' && extension->key->ptr[1] == '\0') {
1505 +                               buffer_copy_string(con->request.pathinfo, con->uri.path->ptr);
1506 +                               con->uri.path->used = 1;
1507 +                               con->uri.path->ptr[con->uri.path->used - 1] = '\0';
1508                         }
1509                 }
1510         } else {
1511 Index: src/mod_accesslog.c
1512 ===================================================================
1513 --- src/mod_accesslog.c (.../tags/lighttpd-1.4.19)      (revision 2190)
1514 +++ src/mod_accesslog.c (.../branches/lighttpd-1.4.x)   (revision 2190)
1515 @@ -473,7 +473,7 @@
1516                         continue;
1517                 }
1518  
1519 -               if (buffer_is_empty(s->access_logfile)) continue;
1520 +               if (s->access_logfile->used < 2) continue;
1521  
1522                 if (s->access_logfile->ptr[0] == '|') {
1523  #ifdef HAVE_FORK
1524 @@ -498,6 +498,8 @@
1525                                 /* not needed */
1526                                 close(to_log_fds[1]);
1527  
1528 +                               openDevNull(STDERR_FILENO);
1529 +
1530                                 /* we don't need the client socket */
1531                                 for (i = 3; i < 256; i++) {
1532                                         close(i);
1533 @@ -570,7 +572,7 @@
1534                 }
1535  
1536                 if (s->use_syslog == 0 &&
1537 -                   !buffer_is_empty(s->access_logfile) &&
1538 +                   s->access_logfile->used > 1 &&
1539                     s->access_logfile->ptr[0] != '|') {
1540  
1541                         close(s->log_access_fd);
1542 @@ -647,6 +649,9 @@
1543  
1544         mod_accesslog_patch_connection(srv, con, p);
1545  
1546 +       /* No output device, nothing to do */
1547 +       if (!p->conf.use_syslog && p->conf.log_access_fd == -1) return HANDLER_GO_ON;
1548 +
1549         b = p->conf.access_logbuffer;
1550         if (b->used == 0) {
1551                 buffer_copy_string(b, "");
1552 @@ -806,7 +811,14 @@
1553                                 buffer_append_string(b, "%");
1554                                 break;
1555                         case FORMAT_SERVER_PORT:
1556 -                               buffer_append_long(b, srv->srvconf.port);
1557 +                               {
1558 +                                       char *colon = strchr(((server_socket*)(con->srv_socket))->srv_token->ptr, ':');
1559 +                                       if (colon) {
1560 +                                               buffer_append_string(b, colon+1);
1561 +                                       } else {
1562 +                                               buffer_append_long(b, srv->srvconf.port);
1563 +                                       }
1564 +                               }
1565                                 break;
1566                         case FORMAT_QUERY_STRING:
1567                                 buffer_append_string_buffer(b, con->uri.query);
1568 Index: src/server.c
1569 ===================================================================
1570 --- src/server.c        (.../tags/lighttpd-1.4.19)      (revision 2190)
1571 +++ src/server.c        (.../branches/lighttpd-1.4.x)   (revision 2190)
1572 @@ -573,20 +573,9 @@
1573         }
1574  
1575         /* close stdin and stdout, as they are not needed */
1576 -       /* move stdin to /dev/null */
1577 -       if (-1 != (fd = open("/dev/null", O_RDONLY))) {
1578 -               close(STDIN_FILENO);
1579 -               dup2(fd, STDIN_FILENO);
1580 -               close(fd);
1581 -       }
1582 +       openDevNull(STDIN_FILENO);
1583 +       openDevNull(STDOUT_FILENO);
1584  
1585 -       /* move stdout to /dev/null */
1586 -       if (-1 != (fd = open("/dev/null", O_WRONLY))) {
1587 -               close(STDOUT_FILENO);
1588 -               dup2(fd, STDOUT_FILENO);
1589 -               close(fd);
1590 -       }
1591 -
1592         if (0 != config_set_defaults(srv)) {
1593                 log_error_write(srv, __FILE__, __LINE__, "s",
1594                                 "setting default values failed");
1595 @@ -893,8 +882,8 @@
1596                 pid_fd = -1;
1597         }
1598  
1599 -       // Close stderr ASAP in the child process to make sure that nothing
1600 -       // is being written to that fd which may not be valid anymore.
1601 +       /* Close stderr ASAP in the child process to make sure that nothing
1602 +        * is being written to that fd which may not be valid anymore. */
1603         if (-1 == log_error_open(srv)) {
1604                 log_error_write(srv, __FILE__, __LINE__, "s", "Opening errorlog failed. Going down.");
1605  
1606 Index: src/mod_dirlisting.c
1607 ===================================================================
1608 --- src/mod_dirlisting.c        (.../tags/lighttpd-1.4.19)      (revision 2190)
1609 +++ src/mod_dirlisting.c        (.../branches/lighttpd-1.4.x)   (revision 2190)
1610 @@ -841,11 +841,11 @@
1611  
1612         /* Insert possible charset to Content-Type */
1613         if (buffer_is_empty(p->conf.encoding)) {
1614 -               response_header_insert(srv, con, CONST_STR_LEN("Content-Type"), CONST_STR_LEN("text/html"));
1615 +               response_header_overwrite(srv, con, CONST_STR_LEN("Content-Type"), CONST_STR_LEN("text/html"));
1616         } else {
1617                 buffer_copy_string(p->content_charset, "text/html; charset=");
1618                 buffer_append_string_buffer(p->content_charset, p->conf.encoding);
1619 -               response_header_insert(srv, con, CONST_STR_LEN("Content-Type"), CONST_BUF_LEN(p->content_charset));
1620 +               response_header_overwrite(srv, con, CONST_STR_LEN("Content-Type"), CONST_BUF_LEN(p->content_charset));
1621         }
1622  
1623         con->file_finished = 1;
1624 Index: src/mod_magnet.c
1625 ===================================================================
1626 --- src/mod_magnet.c    (.../tags/lighttpd-1.4.19)      (revision 2190)
1627 +++ src/mod_magnet.c    (.../branches/lighttpd-1.4.x)   (revision 2190)
1628 @@ -414,10 +414,16 @@
1629         case MAGNET_ENV_URI_AUTHORITY: dest = con->uri.authority; break;
1630         case MAGNET_ENV_URI_QUERY: dest = con->uri.query; break;
1631  
1632 -       case MAGNET_ENV_REQUEST_METHOD:   break;
1633 +       case MAGNET_ENV_REQUEST_METHOD:
1634 +               buffer_copy_string(srv->tmp_buf, get_http_method_name(con->request.http_method));
1635 +               dest = srv->tmp_buf;
1636 +               break;
1637         case MAGNET_ENV_REQUEST_URI:      dest = con->request.uri; break;
1638         case MAGNET_ENV_REQUEST_ORIG_URI: dest = con->request.orig_uri; break;
1639 -       case MAGNET_ENV_REQUEST_PROTOCOL: break;
1640 +       case MAGNET_ENV_REQUEST_PROTOCOL:
1641 +               buffer_copy_string(srv->tmp_buf, get_http_version_name(con->request.http_version));
1642 +               dest = srv->tmp_buf;
1643 +               break;
1644  
1645         case MAGNET_ENV_UNSET: break;
1646         }
1647 @@ -761,11 +767,13 @@
1648  
1649         if (lua_return_value > 99) {
1650                 con->http_status = lua_return_value;
1651 -               con->file_finished = 1;
1652  
1653                 /* try { ...*/
1654                 if (0 == setjmp(exceptionjmp)) {
1655                         magnet_attach_content(srv, con, p, L);
1656 +                       if (!chunkqueue_is_empty(con->write_queue)) {
1657 +                               con->mode = p->id;
1658 +                       }
1659                 } else {
1660                         /* } catch () { */
1661                         con->http_status = 500;
1662 Index: src/log.c
1663 ===================================================================
1664 --- src/log.c   (.../tags/lighttpd-1.4.19)      (revision 2190)
1665 +++ src/log.c   (.../branches/lighttpd-1.4.x)   (revision 2190)
1666 @@ -31,6 +31,29 @@
1667  # define O_LARGEFILE 0
1668  #endif
1669  
1670 +/* Close fd and _try_ to get a /dev/null for it instead.
1671 + * close() alone may trigger some bugs when a
1672 + * process opens another file and gets fd = STDOUT_FILENO or STDERR_FILENO
1673 + * and later tries to just print on stdout/stderr
1674 + *
1675 + * Returns 0 on success and -1 on failure (fd gets closed in all cases)
1676 + */
1677 +int openDevNull(int fd) {
1678 +       int tmpfd;
1679 +       close(fd);
1680 +#if defined(__WIN32)
1681 +       /* Cygwin should work with /dev/null */
1682 +       tmpfd = open("nul", O_RDWR);
1683 +#else
1684 +       tmpfd = open("/dev/null", O_RDWR);
1685 +#endif
1686 +       if (tmpfd != -1 && tmpfd != fd) {
1687 +               dup2(tmpfd, fd);
1688 +               close(tmpfd);
1689 +       }
1690 +       return (tmpfd != -1) ? 0 : -1;
1691 +}
1692 +
1693  /**
1694   * open the errorlog
1695   *
1696 @@ -44,7 +67,6 @@
1697   */
1698  
1699  int log_error_open(server *srv) {
1700 -       int fd;
1701         int close_stderr = 1;
1702  
1703  #ifdef HAVE_SYSLOG_H
1704 @@ -78,15 +100,16 @@
1705         /* don't close stderr for debugging purposes if run in valgrind */
1706         if (RUNNING_ON_VALGRIND) close_stderr = 0;
1707  #endif
1708 -       if (srv->errorlog_mode == ERRORLOG_STDERR) close_stderr = 0;
1709  
1710 +       if (srv->errorlog_mode == ERRORLOG_STDERR && srv->srvconf.dont_daemonize) {
1711 +               /* We can only log to stderr in dont-daemonize mode;
1712 +                * if we do daemonize and no errorlog file is specified, we log into /dev/null
1713 +                */
1714 +               close_stderr = 0;
1715 +       }
1716 +
1717         /* move stderr to /dev/null */
1718 -       if (close_stderr &&
1719 -           -1 != (fd = open("/dev/null", O_WRONLY))) {
1720 -               close(STDERR_FILENO);
1721 -               dup2(fd, STDERR_FILENO);
1722 -               close(fd);
1723 -       }
1724 +       if (close_stderr) openDevNull(STDERR_FILENO);
1725         return 0;
1726  }
1727  
1728 Index: src/log.h
1729 ===================================================================
1730 --- src/log.h   (.../tags/lighttpd-1.4.19)      (revision 2190)
1731 +++ src/log.h   (.../branches/lighttpd-1.4.x)   (revision 2190)
1732 @@ -3,6 +3,11 @@
1733  
1734  #include "server.h"
1735  
1736 +/* Close fd and _try_ to get a /dev/null for it instead.
1737 + * Returns 0 on success and -1 on failure (fd gets closed in all cases)
1738 + */
1739 +int openDevNull(int fd);
1740 +
1741  #define WP() log_error_write(srv, __FILE__, __LINE__, "");
1742  
1743  int log_error_open(server *srv);
1744
1745 Property changes on: tests/symlink.t
1746 ___________________________________________________________________
1747 Name: svn:executable
1748    + *
1749
1750 Index: tests/request.t
1751 ===================================================================
1752 --- tests/request.t     (.../tags/lighttpd-1.4.19)      (revision 2190)
1753 +++ tests/request.t     (.../branches/lighttpd-1.4.x)   (revision 2190)
1754 @@ -101,7 +101,7 @@
1755  Expect: 100-continue
1756  EOF
1757   );
1758 -$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 417, '-HTTP-Content' => ''} ];
1759 +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 417 } ];
1760  ok($tf->handle_http($t) == 0, 'Continue, Expect');
1761  
1762  ## ranges
1763
1764 Property changes on: tests/env-variables.t
1765 ___________________________________________________________________
1766 Name: svn:executable
1767    + *
1768
1769 Index: tests/mod-fastcgi.t
1770 ===================================================================
1771 --- tests/mod-fastcgi.t (.../tags/lighttpd-1.4.19)      (revision 2190)
1772 +++ tests/mod-fastcgi.t (.../branches/lighttpd-1.4.x)   (revision 2190)
1773 @@ -65,7 +65,7 @@
1774  EOF
1775   );
1776         $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '/get-server-env.php' } ];
1777 -       ok($tf->handle_http($t) == 0, '$_SERVER["PHP_SELF"]');
1778 +       ok($tf->handle_http($t) == 0, '$_SERVER["SCRIPT_NAME"]');
1779  
1780         $t->{REQUEST}  = ( <<EOF
1781  GET /get-server-env.php/foo?env=PATH_INFO HTTP/1.0
1782 Index: tests/docroot/www/get-env.php
1783 ===================================================================
1784 --- tests/docroot/www/get-env.php       (.../tags/lighttpd-1.4.19)      (revision 2190)
1785 +++ tests/docroot/www/get-env.php       (.../branches/lighttpd-1.4.x)   (revision 2190)
1786 @@ -1,3 +1,4 @@
1787  <?php
1788 -       print $_ENV[$_GET["env"]];
1789 +       $env = $_GET["env"];
1790 +       print isset($_ENV[$env]) ? $_ENV[$env] : '';
1791  ?>
1792
1793 Property changes on: tests/core-404-handler.t
1794 ___________________________________________________________________
1795 Name: svn:executable
1796    + *
1797
1798 Index: doc/userdir.txt
1799 ===================================================================
1800 --- doc/userdir.txt     (.../tags/lighttpd-1.4.19)      (revision 2190)
1801 +++ doc/userdir.txt     (.../branches/lighttpd-1.4.x)   (revision 2190)
1802 @@ -46,10 +46,10 @@
1803  Options
1804  =======
1805  
1806 -userdir.path
1807 +userdir.path (required option)
1808    usually it should be set to "public_html" to take ~/public_html/ as the document root
1809  
1810 -  Default: empty (document root is the home directory)
1811 +  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)
1812    Example: ::
1813  
1814      userdir.path = "public_html"
1815 Index: SConstruct
1816 ===================================================================
1817 --- SConstruct  (.../tags/lighttpd-1.4.19)      (revision 2190)
1818 +++ SConstruct  (.../branches/lighttpd-1.4.x)   (revision 2190)
1819 @@ -5,7 +5,7 @@
1820  from stat import *
1821  
1822  package = 'lighttpd'
1823 -version = '1.4.19'
1824 +version = '1.4.20'
1825  
1826  def checkCHeaders(autoconf, hdrs):
1827         p = re.compile('[^A-Z0-9]')
1828 Index: Makefile.am
1829 ===================================================================
1830 --- Makefile.am (.../tags/lighttpd-1.4.19)      (revision 2190)
1831 +++ Makefile.am (.../branches/lighttpd-1.4.x)   (revision 2190)
1832 @@ -1,3 +1,3 @@
1833  SUBDIRS=src doc tests cygwin openwrt
1834  
1835 -EXTRA_DIST=lighttpd.spec autogen.sh SConstruct
1836 +EXTRA_DIST=autogen.sh SConstruct
1837 Index: NEWS
1838 ===================================================================
1839 --- NEWS        (.../tags/lighttpd-1.4.19)      (revision 2190)
1840 +++ NEWS        (.../branches/lighttpd-1.4.x)   (revision 2190)
1841 @@ -3,8 +3,31 @@
1842  NEWS
1843  ====
1844  
1845 -- 1.4.19 -
1846 +- 1.4.20 -
1847  
1848 +  * Fix mod_compress to compile with old gcc version (#1592)
1849 +  * Fix mod_extforward to compile with old gcc version (#1591)
1850 +  * Update documentation for #1587
1851 +  * 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)
1852 +  * Fix mod_magnet: enable "request.method" and "request.protocol" in lighty.env (#1308)
1853 +  * Fix segfault for appending matched parts if there was no regex matching (just give empty strings) (#1601)
1854 +  * Use data_response_init in mod_fastcgi x-sendfile handling for response.headers, fix a small "memleak" (#1628)
1855 +  * Don't send empty Server headers (#1620)
1856 +  * Fix conditional interpretation of core options
1857 +  * Enable escaping of % and $ in redirect/rewrite; only two cases changed their behaviour: "%%" => "%", "$$" => "$"
1858 +  * Fix accesslog port (should be port from the connection, not the "server.port") (#1618)
1859 +  * Fix mod_fastcgi prefix matching: match the prefix always against url, not the absolute filepath (regardless of check-local)
1860 +  * Overwrite Content-Type header in mod_dirlisting instead of inserting (#1614), patch by Henrik Holst
1861 +  * Handle EINTR in mod_cgi during write() (#1640)
1862 +  * Allow all http status codes by default; disable body only for 204,205 and 304; generate error pages for 4xx and 5xx (#1639)
1863 +  * Fix mod_magnet to set con->mode = p->id if it generates content, so returning 4xx/5xx doesn't append an error page
1864 +  * Remove lighttpd.spec* from source, fixing all problems with it ;-)
1865 +  * Do not rely on PATH_MAX (POSIX does not require it) (#580)
1866 +  * Disable logging to access.log if filename is an empty string
1867 +  * Implement a clean way to open /dev/null and use it to close stdin/out/err in the needed places (#624)
1868 +
1869 +- 1.4.19 - 2008-03-10
1870 +
1871    * added support for If-Range: <date> (#1346)
1872    * added support for matching $HTTP["scheme"] in configs
1873    * fixed initgroups() called after chroot (#1384)
1874 Index: .cvsignore
1875 ===================================================================
1876 --- .cvsignore  (.../tags/lighttpd-1.4.19)      (revision 2190)
1877 +++ .cvsignore  (.../branches/lighttpd-1.4.x)   (revision 2190)
1878 @@ -3,7 +3,6 @@
1879  configure
1880  depcomp
1881  config.*
1882 -lighttpd.spec
1883  mkinstalldirs
1884  distribute.sh
1885  autom4te.cache
1886
1887 Property changes on: .
1888 ___________________________________________________________________
1889 Name: svk:merge
1890    - 152afb58-edef-0310-8abb-c4023f1b3aa9:/branches/lighttpd-1.3.x:499
1891 152afb58-edef-0310-8abb-c4023f1b3aa9:/branches/lighttpd-1.4.11-ssl-fixes:1346
1892 152afb58-edef-0310-8abb-c4023f1b3aa9:/branches/lighttpd-merge-1.4.x:1041
1893 152afb58-edef-0310-8abb-c4023f1b3aa9:/tags/lighttpd-1.4.11:1042
1894 152afb58-edef-0310-8abb-c4023f1b3aa9:/tags/release-1.3.13:105
1895 152afb58-edef-0310-8abb-c4023f1b3aa9:/trunk:104
1896 a98e19e4-a712-0410-8832-6551a15ffc53:/local/branches/lighttpd-1.4.x:1557
1897 ebd0e9cf-3e47-4385-9dd4-f0e25e97baa2:/local/lighttpd/branches/lighttpd-1.4.x:2164
1898    + 152afb58-edef-0310-8abb-c4023f1b3aa9:/branches/lighttpd-1.3.x:499
1899 152afb58-edef-0310-8abb-c4023f1b3aa9:/branches/lighttpd-1.4.11-ssl-fixes:1346
1900 152afb58-edef-0310-8abb-c4023f1b3aa9:/branches/lighttpd-merge-1.4.x:1041
1901 152afb58-edef-0310-8abb-c4023f1b3aa9:/tags/lighttpd-1.4.11:1042
1902 152afb58-edef-0310-8abb-c4023f1b3aa9:/tags/release-1.3.13:105
1903 152afb58-edef-0310-8abb-c4023f1b3aa9:/trunk:104
1904 a98e19e4-a712-0410-8832-6551a15ffc53:/local/branches/lighttpd-1.4.x:1557
1905 ebd0e9cf-3e47-4385-9dd4-f0e25e97baa2:/local/lighttpd/branches/lighttpd-1.4.x:2250
1906
This page took 0.263261 seconds and 4 git commands to generate.