--- lighttpd-1.4.13.orig/src/mod_fastcgi.c 2007-01-28 05:44:04.000000000 -0800 +++ lighttpd-1.4.13.orig/src/mod_fastcgi.c 2007-01-28 05:49:32.000000000 -0800 @@ -906,6 +906,7 @@ char *c; char_array env; char_array arg; + int fd; /* create environment */ env.ptr = NULL; @@ -922,6 +923,28 @@ close(fcgi_fd); } + /* HACK: + * This is not nice, but it works + * + * we feed the stderr of the FastCGI to our errorlog, + * for messages that were written to stderr by mistake. + * + * this violates the fastcgi SPEC because stderr + * should be closed and all errors are meant to be + * sent as FCGI_STDERR packets to the webserver and + * not written directly to the log. + */ + + if ((srv->errorlog_mode == ERRORLOG_FILE) || (srv->errorlog_mode == ERRORLOG_PIPE)) { + close(STDERR_FILENO); + dup2(srv->errorlog_fd, STDERR_FILENO); + } else { + if (-1 != (fd = open("/dev/null", O_WRONLY))) { + close(STDERR_FILENO); + dup2(fd, STDERR_FILENO); + close(fd); + } + } /* we don't need the client socket */ for (i = 3; i < 256; i++) { close(i); --- lighttpd-1.4.13.orig/src/server.c 2006-10-04 06:30:52.000000000 -0700 +++ lighttpd-1.4.13.orig/src/server.c 2007-01-28 05:49:32.000000000 -0800 @@ -844,6 +844,16 @@ pid_fd = -1; } + if (-1 == log_error_open(srv)) { + log_error_write(srv, __FILE__, __LINE__, "s", + "opening errorlog failed, dying"); + + plugins_free(srv); + network_close(srv); + server_free(srv); + return -1; + } + if (HANDLER_GO_ON != plugins_call_set_defaults(srv)) { log_error_write(srv, __FILE__, __LINE__, "s", "Configuration of plugins failed. Going down."); @@ -894,15 +904,6 @@ return -1; } - if (-1 == log_error_open(srv)) { - log_error_write(srv, __FILE__, __LINE__, "s", - "opening errorlog failed, dying"); - - plugins_free(srv); - network_close(srv); - server_free(srv); - return -1; - } #ifdef HAVE_SIGACTION