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)
6 -Summary: A fast webserver with minimal memory-footprint (lighttpd)
10 -Source: http://jan.kneschke.de/projects/lighttpd/download/lighttpd-%version.tar.gz
11 -Packager: Jan Kneschke <jan@kneschke.de>
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
20 -lighttpd is intented to be a frontend for ad-servers which have to deliver
21 -small files concurrently to many connections.
23 -Available rpmbuild rebuild options:
24 ---with: ssl mysql lua memcache
32 - %{?_with_mysql: --with-mysql} \
33 - %{?_with_lua: --with-lua} \
34 - %{?_with_memcache: --with-memcache} \
35 - %{?_with_ssl: --with-openssl}
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
45 - install -m 755 doc/rc.lighttpd %{buildroot}%{_sysconfdir}/init.d/lighttpd
47 -install -m 644 doc/sysconfig.lighttpd %{buildroot}%{_sysconfdir}/sysconfig/lighttpd
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
60 -if [ "$1" = "0"]; then
61 - # real uninstall, not upgrade
62 - %{_sysconfdir}/init.d/lighttpd stop
63 - /sbin/chkconfig --del lighttpd
67 -%defattr(-,root,root)
68 -%doc doc/lighttpd.conf doc/lighttpd.user README INSTALL ChangeLog COPYING AUTHORS
70 -%config(noreplace) %attr(0755,root,root) %{_sysconfdir}/init.d/lighttpd
71 -%config(noreplace) %attr(0644,root,root) %{_sysconfdir}/sysconfig/lighttpd
78 -* Thu Sep 30 2004 12:41 <jan@kneschke.de> 1.3.1
81 -* Tue Jun 29 2004 17:26 <jan@kneschke.de> 1.2.3
82 -- rpmlint'ed the package
84 -- added (noreplace) to start-script
85 -- change group to Networking/Daemon (like apache)
87 -* Sun Feb 23 2003 15:04 <jan@kneschke.de>
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)
105 -#define TK_LPARAN 10
106 -#define TK_RPARAN 11
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)
113 int config_append_cond_match_buffer(connection *con, data_config *dc, buffer *buf, int n)
115 cond_cache_t *cache = &con->cond_cache[dc->context_ndx];
116 - if (n > cache->patterncount) {
117 + if (n >= cache->patterncount) {
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)
129 + openDevNull(STDERR_FILENO);
131 /* we don't need the client socket */
132 for (i = 3; i < 256; i++) {
133 if (i != srv->errorlog_fd) close(i);
136 execve(args[0], args, env.ptr);
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]); */
143 @@ -1058,8 +1060,9 @@
146 con->http_status = 507;
152 con->http_status = 403;
154 @@ -1071,8 +1074,9 @@
157 con->http_status = 507;
163 con->http_status = 403;
165 @@ -1087,6 +1091,8 @@
169 + log_error_write(srv, __FILE__, __LINE__, "ss", "write() failed due to: ", strerror(errno));
170 + con->http_status = 500;
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)
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] == '%') {
187 size_t num = pattern[k + 1] - '0';
190 buffer_append_string_len(con->request.uri, pattern + start, end - start);
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]);
201 ===================================================================
202 --- src/lempar.c (.../tags/lighttpd-1.4.19) (revision 2190)
203 +++ src/lempar.c (.../branches/lighttpd-1.4.x) (revision 2190)
206 const char *ParseTokenName(int tokenType){
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];
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 ){
220 int iFallback; /* Fallback token */
221 if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])
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];
232 yymsp = &yypParser->yystack[yypParser->yyidx];
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]);
241 int yymajor, /* The major type of the error token */
242 YYMINORTYPE yyminor /* The minor type of the error token */
247 #define TOKEN (yyminor.yy0)
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)
255 /* don't resize the buffer if we were in SSL_ERROR_WANT_* */
259 if (!con->ssl_error_want_reuse_buffer) {
270 @@ -427,21 +430,22 @@
273 switch(con->http_status) {
274 - case 400: /* class: header + custom body */
287 + case 204: /* class: header only */
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);
295 + con->file_finished = 1;
297 + default: /* class: header + body */
298 if (con->mode != DIRECT) break;
300 + /* only custom body for 4xx and 5xx */
301 + if (con->http_status < 400 || con->http_status >= 600) break;
303 con->file_finished = 0;
305 buffer_reset(con->physical.path);
307 stat_cache_entry *sce = NULL;
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"));
314 if (HANDLER_ERROR != stat_cache_get_entry(srv, con, con->physical.path, &sce)) {
315 con->file_finished = 1;
318 response_header_overwrite(srv, con, CONST_STR_LEN("Content-Type"), CONST_STR_LEN("text/html"));
322 - case 200: /* class: header + body */
331 - case 206: /* write_queue is already prepared */
334 - case 205: /* class: header only */
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);
342 - con->file_finished = 1;
346 if (con->file_finished) {
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 */
354 } else if (qlen > 0 || con->request.http_method != HTTP_METHOD_HEAD) {
355 /* qlen = 0 is important for Redirects (301, ...) as they MAY have
359 /* The cond_cache gets reset in response.c */
360 -// config_cond_cache_reset(srv, con);
361 + /* config_cond_cache_reset(srv, con); */
364 if (con->ssl_error_want_reuse_buffer) {
365 @@ -1668,21 +1650,51 @@
368 if (srv_sock->is_ssl) {
373 switch ((ret = SSL_shutdown(con->ssl))) {
378 - SSL_shutdown(con->ssl);
381 + if (-1 != (ret = SSL_shutdown(con->ssl))) break;
385 - log_error_write(srv, __FILE__, __LINE__, "sds", "SSL:",
386 - SSL_get_error(con->ssl, ret),
387 - ERR_error_string(ERR_get_error(), NULL));
390 + switch ((ssl_r = SSL_get_error(con->ssl, ret))) {
391 + case SSL_ERROR_WANT_WRITE:
392 + case SSL_ERROR_WANT_READ:
394 + case SSL_ERROR_SYSCALL:
395 + /* perhaps we have error waiting in our error-queue */
396 + if (0 != (err = ERR_get_error())) {
398 + log_error_write(srv, __FILE__, __LINE__, "sdds", "SSL:",
400 + ERR_error_string(err, NULL));
401 + } while((err = ERR_get_error()));
403 + log_error_write(srv, __FILE__, __LINE__, "sddds", "SSL (error):",
410 + while((err = ERR_get_error())) {
411 + log_error_write(srv, __FILE__, __LINE__, "sdds", "SSL:",
413 + ERR_error_string(err, NULL));
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)
437 data_config *dc = (data_config *)srv->config_context->data[i];
438 specific_config *s = srv->config_storage[i];
440 - /* not our stage */
441 - if (comp != dc->comp) continue;
443 /* condition didn't match */
444 if (!config_check_cond(srv, con, dc)) continue;
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);
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);
468 @@ -912,15 +910,39 @@
472 +static char* getCWD() {
482 + if (!s) return NULL;
483 + while (NULL == getcwd(s, len)) {
484 + if (errno != ERANGE || SSIZE_MAX - len < len) return NULL;
486 + s1 = realloc(s, len);
496 int config_parse_cmd(server *srv, config_t *context, const char *cmd) {
502 - char oldpwd[PATH_MAX];
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));
519 ===================================================================
520 --- src/lemon.c (.../tags/lighttpd-1.4.19) (revision 2190)
521 +++ src/lemon.c (.../branches/lighttpd-1.4.x) (revision 2190)
526 +#ifdef HAVE_CONFIG_H
530 +#ifdef HAVE_STDINT_H
531 +# include <stdint.h>
533 +#ifdef HAVE_INTTYPES_H
534 +# include <inttypes.h>
537 +#define UNUSED(x) ( (void)(x) )
540 extern double strtod();
541 extern long strtol();
544 struct symbol *spx, *spy;
547 assert( apx->sp==apy->sp ); /* Otherwise there would be no conflict */
548 if( apx->type==SHIFT && apy->type==REDUCE ){
550 @@ -1347,6 +1361,7 @@
552 char *def_tmpl_name = "lempar.c";
555 OptInit(argv,options,stderr);
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);
566 fprintf(err,"%smissing argument on switch.\n",emsg);
567 @@ -1733,19 +1748,19 @@
568 *(double*)(op[j].arg) = dv;
571 - (*(void(*)())(op[j].arg))(dv);
572 + (*(void(*)())(intptr_t)(op[j].arg))(dv);
575 *(int*)(op[j].arg) = lv;
578 - (*(void(*)())(op[j].arg))((int)lv);
579 + (*(void(*)())(intptr_t)(op[j].arg))((int)lv);
582 *(char**)(op[j].arg) = sv;
585 - (*(void(*)())(op[j].arg))(sv);
586 + (*(void(*)())(intptr_t)(op[j].arg))(sv);
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".
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)
611 + * workaround for program when prefix="/"
613 + * rule to build PATH_INFO is hardcoded for when check_local is disabled
614 + * enable this option to use the workaround
618 + unsigned short fix_root_path_name;
619 ssize_t load; /* replace by host->load */
621 size_t max_id; /* corresponds most of the time to
624 buffer *key; /* like .php */
627 scgi_extension_host **hosts;
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 */
637 { NULL, NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET }
639 df->max_load_per_proc = 1;
640 df->idle_timeout = 60;
641 df->disable_time = 60;
642 + df->fix_root_path_name = 0;
644 fcv[0].destination = df->host;
645 fcv[1].destination = df->docroot;
646 @@ -1006,6 +1018,7 @@
648 fcv[11].destination = df->bin_env;
649 fcv[12].destination = df->bin_env_copy;
650 + fcv[13].destination = &(df->fix_root_path_name);
653 if (0 != config_insert_values_internal(srv, da_host->value, fcv)) {
654 @@ -2668,10 +2681,10 @@
655 plugin_data *p = p_d;
661 scgi_extension *extension = NULL;
662 + scgi_extension_host *host = NULL;
664 /* Possibly, we processed already this request */
665 if (con->file_started == 1) return HANDLER_GO_ON;
666 @@ -2712,95 +2725,59 @@
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];
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) {
682 - if (used == -1 || host->load < used) {
684 + if (used == -1 || h->load < used) {
692 - /* found a server */
694 - scgi_extension_host *host = extension->hosts[ndx];
696 + /* sorry, we don't have a server alive for this ext */
697 + buffer_reset(con->physical.path);
698 + con->http_status = 500;
701 - * if check-local is disabled, use the uri.path handler
704 + /* only send the 'no handler' once */
705 + if (!extension->note_is_sent) {
706 + extension->note_is_sent = 1;
708 - /* init handler-context */
709 - if (uri_path_handler) {
710 - if (host->check_local == 0) {
713 + log_error_write(srv, __FILE__, __LINE__, "sbsbs",
714 + "all handlers for ", con->uri.path,
715 + "on", extension->key,
719 - hctx = handler_ctx_init();
720 + return HANDLER_FINISHED;
723 - hctx->remote_conn = con;
724 - hctx->plugin_data = p;
727 + /* a note about no handler is not sent yet */
728 + extension->note_is_sent = 0;
730 - hctx->conf.exts = p->conf.exts;
731 - hctx->conf.debug = p->conf.debug;
733 + * if check-local is disabled, use the uri.path handler
737 - con->plugin_ctx[p->id] = hctx;
738 + /* init handler-context */
739 + if (uri_path_handler) {
740 + if (host->check_local == 0) {
748 - if (con->conf.log_request_handling) {
749 - log_error_write(srv, __FILE__, __LINE__, "s", "handling it in mod_scgi");
752 - /* the prefix is the SCRIPT_NAME,
753 - * everthing from start to the next slash
754 - * this is important for check-local = "disable"
756 - * if prefix = /admin.fcgi
758 - * /admin.fcgi/foo/bar
760 - * SCRIPT_NAME = /admin.fcgi
761 - * PATH_INFO = /foo/bar
763 - * if prefix = /fcgi-bin/
765 - * /fcgi-bin/foo/bar
767 - * SCRIPT_NAME = /fcgi-bin/foo
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 */
778 - buffer_copy_string(con->request.pathinfo, pathinfo);
780 - con->uri.path->used -= con->request.pathinfo->used - 1;
781 - con->uri.path->ptr[con->uri.path->used - 1] = '\0';
784 - return HANDLER_GO_ON;
787 hctx = handler_ctx_init();
789 hctx->remote_conn = con;
790 hctx->plugin_data = p;
795 hctx->conf.exts = p->conf.exts;
796 hctx->conf.debug = p->conf.debug;
797 @@ -2812,22 +2789,69 @@
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");
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"
811 + * if prefix = /admin.fcgi
813 + * /admin.fcgi/foo/bar
815 + * SCRIPT_NAME = /admin.fcgi
816 + * PATH_INFO = /foo/bar
818 + * if prefix = /fcgi-bin/
820 + * /fcgi-bin/foo/bar
822 + * SCRIPT_NAME = /fcgi-bin/foo
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 */
833 + buffer_copy_string(con->request.pathinfo, pathinfo);
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';
844 - /* no handler found */
845 - buffer_reset(con->physical.path);
846 - con->http_status = 500;
848 + hctx = handler_ctx_init();
850 - log_error_write(srv, __FILE__, __LINE__, "sb",
851 - "no fcgi-handler found for:",
853 + hctx->remote_conn = con;
854 + hctx->plugin_data = p;
858 - return HANDLER_FINISHED;
859 + hctx->conf.exts = p->conf.exts;
860 + hctx->conf.debug = p->conf.debug;
862 + con->plugin_ctx[p->id] = hctx;
868 + if (con->conf.log_request_handling) {
869 + log_error_write(srv, __FILE__, __LINE__, "s", "handling it in mod_fastcgi");
873 return HANDLER_GO_ON;
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)
881 static volatile sig_atomic_t graceful_restart = 0;
882 static volatile pid_t pid = -1;
884 +#define UNUSED(x) ( (void)(x) )
886 static void sigaction_handler(int sig, siginfo_t *si, void *context) {
895 struct sigaction act;
900 * we are running as root BEWARE
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)
910 + openDevNull(STDERR_FILENO);
912 /* we don't need the client socket */
913 for (i = 3; i < 256; i++) {
917 execv(args[0], args);
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]); */
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)
930 if (buffer_is_empty(con->conf.server_tag)) {
931 BUFFER_APPEND_STRING_CONST(b, "\r\nServer: " PACKAGE_NAME "/" PACKAGE_VERSION);
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);
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. */
944 if (con->conf.log_condition_handling) {
945 log_error_write(srv, __FILE__, __LINE__, "s", "run condition");
947 ===================================================================
948 --- src/plugin.c (.../tags/lighttpd-1.4.19) (revision 2190)
949 +++ src/plugin.c (.../branches/lighttpd-1.4.x) (revision 2190)
954 - init = (int (*)(plugin *))dlsym(p->lib, srv->tmp_buf->ptr);
955 + init = (int (*)(plugin *))(intptr_t)dlsym(p->lib, srv->tmp_buf->ptr);
957 *(void **)(&init) = dlsym(p->lib, srv->tmp_buf->ptr);
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)
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)
976 static const char *last_not_in_array(array *a, plugin_data *p)
978 array *forwarder = p->conf.forwarder;
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;
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)
991 configparser.c configparser.h:
992 mod_ssi_exprparser.c mod_ssi_exprparser.h:
994 -$(srcdir)/configparser.y: lemon
995 -$(srcdir)/mod_ssi_exprparser.y: lemon
997 -configparser.c configparser.h: $(srcdir)/configparser.y
998 +configparser.c configparser.h: lemon $(srcdir)/configparser.y $(srcdir)/lempar.c
1000 $(LEMON) -q $(srcdir)/configparser.y $(srcdir)/lempar.c
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
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
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)
1023 + ERR_clear_error();
1024 if ((r = SSL_write(ssl, offset, toSend)) <= 0) {
1031 + ERR_clear_error();
1032 if ((r = SSL_write(ssl, s, toSend)) <= 0) {
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)
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] == '%') {
1048 size_t num = pattern[k + 1] - '0';
1049 @@ -225,7 +224,10 @@
1051 buffer_append_string_len(p->location, pattern + start, end - start);
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)
1083 @@ -1154,6 +1158,7 @@
1091 @@ -1192,6 +1197,11 @@
1104 ===================================================================
1105 --- src/md5.c (.../tags/lighttpd-1.4.19) (revision 2190)
1106 +++ src/md5.c (.../branches/lighttpd-1.4.x) (revision 2190)
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);
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
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 */
1130 unsigned int i, ndx, partLen;
1131 + const unsigned char *input = (const unsigned char*) _input;
1133 /* Compute number of bytes mod 64 */
1134 ndx = (unsigned int)((context->count[0] >> 3) & 0x3F);
1137 static void MD5Transform (state, block)
1139 -unsigned char block[64];
1140 +const unsigned char block[64];
1142 UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
1146 static void Decode (output, input, len)
1148 -unsigned char *input;
1149 +const unsigned char *input;
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)
1158 return HANDLER_GO_ON;
1161 -// 0 on success, -1 for error
1162 +/* 0 on success, -1 for error */
1163 int mkdir_recursive(char *dir) {
1166 @@ -118,13 +118,13 @@
1170 - if (!*p) return 0; // Ignore trailing slash
1171 + if (!*p) return 0; /* Ignore trailing slash */
1174 return (mkdir(dir, 0700) != 0) && (errno != EEXIST) ? -1 : 0;
1177 -// 0 on success, -1 for error
1178 +/* 0 on success, -1 for error */
1179 int mkdir_for_file(char *filename) {
1186 - if (!*p) return -1; // Unexpected trailing slash in filename
1187 + if (!*p) return -1; /* Unexpected trailing slash in filename */
1194 if (!buffer_is_empty(s->compress_cache_dir)) {
1196 mkdir_recursive(s->compress_cache_dir->ptr);
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));
1203 ===================================================================
1204 --- src/md5.h (.../tags/lighttpd-1.4.19) (revision 2190)
1205 +++ src/md5.h (.../branches/lighttpd-1.4.x) (revision 2190)
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 *);
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 @@
1220 handler_t auth_ldap_init(server *srv, mod_auth_plugin_config *s) {
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");
1230 - return HANDLER_ERROR;
1232 + return HANDLER_ERROR;
1236 - if (s->auth_ldap_filter->used) {
1238 + if (s->auth_ldap_filter->used) {
1241 - /* parse filter */
1242 + /* parse filter */
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 '$'");
1249 - return HANDLER_ERROR;
1251 + return HANDLER_ERROR;
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);
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);
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));
1268 - return HANDLER_ERROR;
1270 + return HANDLER_ERROR;
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));
1280 + return HANDLER_ERROR;
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));
1292 return HANDLER_ERROR;
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));
1307 - return HANDLER_ERROR;
1310 + return HANDLER_ERROR;
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));
1317 - return HANDLER_ERROR;
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));
1325 + return HANDLER_ERROR;
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));
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));
1336 - return HANDLER_ERROR;
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));
1342 - return HANDLER_ERROR;
1345 + return HANDLER_ERROR;
1349 + return HANDLER_GO_ON;
1351 - log_error_write(srv, __FILE__, __LINE__, "s", "no ldap support available");
1352 - return HANDLER_ERROR;
1354 + log_error_write(srv, __FILE__, __LINE__, "s", "no ldap support available");
1355 + return HANDLER_ERROR;
1357 - return HANDLER_GO_ON;
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;
1369 + * workaround for program when prefix="/"
1371 + * rule to build PATH_INFO is hardcoded for when check_local is disabled
1372 + * enable this option to use the workaround
1376 + unsigned short fix_root_path_name;
1379 * If the backend includes X-LIGHTTPD-send-file in the response
1380 * we use the value as filename and ignore the content.
1386 + openDevNull(STDERR_FILENO);
1388 /* we don't need the client socket */
1389 for (i = 3; i < 256; i++) {
1391 @@ -1000,8 +1012,8 @@
1393 execve(arg.ptr[0], arg.ptr, env.ptr);
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)); */
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 */
1408 { NULL, NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET }
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;
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);
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;
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();
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 @@
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 @@
1449 ct_len = extension->key->used - 1;
1451 - if (s_len < ct_len) continue;
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))
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" */
1466 @@ -3499,16 +3516,15 @@
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];
1473 /* we should have at least one proc that can do something */
1474 - if (host->active_procs == 0) {
1477 + if (h->active_procs == 0) {
1481 /* we found one host that is alive */
1486 @@ -3582,6 +3598,13 @@
1487 * SCRIPT_NAME = /fcgi-bin/foo
1490 + * if prefix = /, and fix-root-path-name is enable
1492 + * /fcgi-bin/foo/bar
1494 + * SCRIPT_NAME = /fcgi-bin/foo
1495 + * PATH_INFO = /bar
1499 /* the rewrite is only done for /prefix/? matches */
1500 @@ -3594,6 +3617,10 @@
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';
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)
1519 - if (buffer_is_empty(s->access_logfile)) continue;
1520 + if (s->access_logfile->used < 2) continue;
1522 if (s->access_logfile->ptr[0] == '|') {
1526 close(to_log_fds[1]);
1528 + openDevNull(STDERR_FILENO);
1530 /* we don't need the client socket */
1531 for (i = 3; i < 256; i++) {
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] != '|') {
1541 close(s->log_access_fd);
1544 mod_accesslog_patch_connection(srv, con, p);
1546 + /* No output device, nothing to do */
1547 + if (!p->conf.use_syslog && p->conf.log_access_fd == -1) return HANDLER_GO_ON;
1549 b = p->conf.access_logbuffer;
1551 buffer_copy_string(b, "");
1552 @@ -806,7 +811,14 @@
1553 buffer_append_string(b, "%");
1555 case FORMAT_SERVER_PORT:
1556 - buffer_append_long(b, srv->srvconf.port);
1558 + char *colon = strchr(((server_socket*)(con->srv_socket))->srv_token->ptr, ':');
1560 + buffer_append_string(b, colon+1);
1562 + buffer_append_long(b, srv->srvconf.port);
1566 case FORMAT_QUERY_STRING:
1567 buffer_append_string_buffer(b, con->uri.query);
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 @@
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);
1582 + openDevNull(STDIN_FILENO);
1583 + openDevNull(STDOUT_FILENO);
1585 - /* move stdout to /dev/null */
1586 - if (-1 != (fd = open("/dev/null", O_WRONLY))) {
1587 - close(STDOUT_FILENO);
1588 - dup2(fd, STDOUT_FILENO);
1592 if (0 != config_set_defaults(srv)) {
1593 log_error_write(srv, __FILE__, __LINE__, "s",
1594 "setting default values failed");
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.");
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 @@
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"));
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));
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;
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;
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;
1645 case MAGNET_ENV_UNSET: break;
1647 @@ -761,11 +767,13 @@
1649 if (lua_return_value > 99) {
1650 con->http_status = lua_return_value;
1651 - con->file_finished = 1;
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;
1661 con->http_status = 500;
1663 ===================================================================
1664 --- src/log.c (.../tags/lighttpd-1.4.19) (revision 2190)
1665 +++ src/log.c (.../branches/lighttpd-1.4.x) (revision 2190)
1667 # define O_LARGEFILE 0
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
1675 + * Returns 0 on success and -1 on failure (fd gets closed in all cases)
1677 +int openDevNull(int fd) {
1680 +#if defined(__WIN32)
1681 + /* Cygwin should work with /dev/null */
1682 + tmpfd = open("nul", O_RDWR);
1684 + tmpfd = open("/dev/null", O_RDWR);
1686 + if (tmpfd != -1 && tmpfd != fd) {
1690 + return (tmpfd != -1) ? 0 : -1;
1699 int log_error_open(server *srv) {
1701 int close_stderr = 1;
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;
1708 - if (srv->errorlog_mode == ERRORLOG_STDERR) close_stderr = 0;
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
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);
1724 + if (close_stderr) openDevNull(STDERR_FILENO);
1729 ===================================================================
1730 --- src/log.h (.../tags/lighttpd-1.4.19) (revision 2190)
1731 +++ src/log.h (.../branches/lighttpd-1.4.x) (revision 2190)
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)
1739 +int openDevNull(int fd);
1741 #define WP() log_error_write(srv, __FILE__, __LINE__, "");
1743 int log_error_open(server *srv);
1745 Property changes on: tests/symlink.t
1746 ___________________________________________________________________
1747 Name: svn:executable
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)
1755 Expect: 100-continue
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');
1764 Property changes on: tests/env-variables.t
1765 ___________________________________________________________________
1766 Name: svn:executable
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)
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"]');
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)
1788 - print $_ENV[$_GET["env"]];
1789 + $env = $_GET["env"];
1790 + print isset($_ENV[$env]) ? $_ENV[$env] : '';
1793 Property changes on: tests/core-404-handler.t
1794 ___________________________________________________________________
1795 Name: svn:executable
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)
1807 +userdir.path (required option)
1808 usually it should be set to "public_html" to take ~/public_html/ as the document root
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)
1814 userdir.path = "public_html"
1816 ===================================================================
1817 --- SConstruct (.../tags/lighttpd-1.4.19) (revision 2190)
1818 +++ SConstruct (.../branches/lighttpd-1.4.x) (revision 2190)
1822 package = 'lighttpd'
1826 def checkCHeaders(autoconf, hdrs):
1827 p = re.compile('[^A-Z0-9]')
1829 ===================================================================
1830 --- Makefile.am (.../tags/lighttpd-1.4.19) (revision 2190)
1831 +++ Makefile.am (.../branches/lighttpd-1.4.x) (revision 2190)
1833 SUBDIRS=src doc tests cygwin openwrt
1835 -EXTRA_DIST=lighttpd.spec autogen.sh SConstruct
1836 +EXTRA_DIST=autogen.sh SConstruct
1838 ===================================================================
1839 --- NEWS (.../tags/lighttpd-1.4.19) (revision 2190)
1840 +++ NEWS (.../branches/lighttpd-1.4.x) (revision 2190)
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)
1869 +- 1.4.19 - 2008-03-10
1871 * added support for If-Range: <date> (#1346)
1872 * added support for matching $HTTP["scheme"] in configs
1873 * fixed initgroups() called after chroot (#1384)
1875 ===================================================================
1876 --- .cvsignore (.../tags/lighttpd-1.4.19) (revision 2190)
1877 +++ .cvsignore (.../branches/lighttpd-1.4.x) (revision 2190)
1887 Property changes on: .
1888 ___________________________________________________________________
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