2 ===================================================================
3 Index: src/configfile-glue.c
4 ===================================================================
5 --- src/configfile-glue.c (.../tags/lighttpd-1.4.18) (revision 2060)
6 +++ src/configfile-glue.c (.../branches/lighttpd-1.4.x) (revision 2060)
11 + case COMP_HTTP_SCHEME:
12 + l = con->uri.scheme;
19 ===================================================================
20 --- src/base.h (.../tags/lighttpd-1.4.18) (revision 2060)
21 +++ src/base.h (.../branches/lighttpd-1.4.x) (revision 2060)
26 + unsigned short is_proxy_ssl;
31 ===================================================================
32 --- src/array.h (.../tags/lighttpd-1.4.18) (revision 2060)
33 +++ src/array.h (.../branches/lighttpd-1.4.x) (revision 2060)
37 COMP_HTTP_QUERYSTRING,
42 Index: src/mod_staticfile.c
43 ===================================================================
44 --- src/mod_staticfile.c (.../tags/lighttpd-1.4.18) (revision 2060)
45 +++ src/mod_staticfile.c (.../branches/lighttpd-1.4.x) (revision 2060)
47 /* if the value is the same as our ETag, we do a Range-request,
48 * otherwise a full 200 */
50 - if (!buffer_is_equal(ds->value, con->physical.etag)) {
51 + if (ds->value->ptr[0] == '"') {
53 + * client wants a ETag
55 + if (!con->physical.etag) {
56 + do_range_request = 0;
57 + } else if (!buffer_is_equal(ds->value, con->physical.etag)) {
58 + do_range_request = 0;
60 + } else if (!mtime) {
62 + * we don't have a Last-Modified and can match the If-Range:
67 + } else if (!buffer_is_equal(ds->value, mtime)) {
68 + do_range_request = 0;
73 ===================================================================
74 --- src/mod_scgi.c (.../tags/lighttpd-1.4.18) (revision 2060)
75 +++ src/mod_scgi.c (.../branches/lighttpd-1.4.x) (revision 2060)
77 if (s_len < ct_len) continue;
79 /* check extension in the form "/scgi_pattern" */
80 - if (*(extension->key->ptr) == '/' && strncmp(fn->ptr, extension->key->ptr, ct_len) == 0) {
82 + if (*(extension->key->ptr) == '/') {
83 + if (strncmp(fn->ptr, extension->key->ptr, ct_len) == 0)
85 } else if (0 == strncmp(fn->ptr + s_len - ct_len, extension->key->ptr, ct_len)) {
86 /* check extension in the form ".fcg" */
89 ===================================================================
90 --- src/response.c (.../tags/lighttpd-1.4.18) (revision 2060)
91 +++ src/response.c (.../branches/lighttpd-1.4.x) (revision 2060)
93 ds = (data_string *)con->response.headers->data[i];
95 if (ds->value->used && ds->key->used &&
96 - 0 != strncmp(ds->key->ptr, "X-LIGHTTPD-", sizeof("X-LIGHTTPD-") - 1)) {
97 + 0 != strncmp(ds->key->ptr, "X-LIGHTTPD-", sizeof("X-LIGHTTPD-") - 1) &&
98 + 0 != strncmp(ds->key->ptr, "X-Sendfile", sizeof("X-Sendfile") - 1)) {
99 if (buffer_is_equal_string(ds->key, CONST_STR_LEN("Date"))) have_date = 1;
100 if (buffer_is_equal_string(ds->key, CONST_STR_LEN("Server"))) have_server = 1;
103 buffer_copy_string_buffer(con->uri.authority, con->request.http_host);
104 buffer_to_lower(con->uri.authority);
106 + config_patch_connection(srv, con, COMP_HTTP_SCHEME); /* Scheme: */
107 config_patch_connection(srv, con, COMP_HTTP_HOST); /* Host: */
108 config_patch_connection(srv, con, COMP_HTTP_REMOTEIP); /* Client-IP */
109 config_patch_connection(srv, con, COMP_HTTP_REFERER); /* Referer: */
110 Index: src/mod_userdir.c
111 ===================================================================
112 --- src/mod_userdir.c (.../tags/lighttpd-1.4.18) (revision 2060)
113 +++ src/mod_userdir.c (.../branches/lighttpd-1.4.x) (revision 2060)
118 + unsigned short letterhomes;
123 { "userdir.exclude-user", NULL, T_CONFIG_ARRAY, T_CONFIG_SCOPE_CONNECTION }, /* 1 */
124 { "userdir.include-user", NULL, T_CONFIG_ARRAY, T_CONFIG_SCOPE_CONNECTION }, /* 2 */
125 { "userdir.basepath", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 3 */
126 + { "userdir.letterhomes", NULL, T_CONFIG_BOOLEAN,T_CONFIG_SCOPE_CONNECTION }, /* 4 */
127 { NULL, NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET }
130 @@ -102,11 +104,13 @@
131 s->include_user = array_init();
132 s->path = buffer_init();
133 s->basepath = buffer_init();
134 + s->letterhomes = 0;
136 cv[0].destination = s->path;
137 cv[1].destination = s->exclude_user;
138 cv[2].destination = s->include_user;
139 cv[3].destination = s->basepath;
140 + cv[4].destination = &(s->letterhomes);
142 p->config_storage[i] = s;
148 + PATCH(letterhomes);
150 /* skip the first, the global context */
151 for (i = 1; i < srv->config_context->used; i++) {
154 } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("userdir.basepath"))) {
156 + } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("userdir.letterhomes"))) {
157 + PATCH(letterhomes);
163 buffer_copy_string_buffer(p->temp_path, p->conf.basepath);
164 BUFFER_APPEND_SLASH(p->temp_path);
165 + if (p->conf.letterhomes) {
166 + buffer_append_string_len(p->temp_path, p->username->ptr, 1);
167 + BUFFER_APPEND_SLASH(p->temp_path);
169 buffer_append_string_buffer(p->temp_path, p->username);
171 BUFFER_APPEND_SLASH(p->temp_path);
172 Index: src/mod_proxy.c
173 ===================================================================
174 --- src/mod_proxy.c (.../tags/lighttpd-1.4.18) (revision 2060)
175 +++ src/mod_proxy.c (.../branches/lighttpd-1.4.x) (revision 2060)
176 @@ -1093,15 +1093,17 @@
177 if (s_len < ct_len) continue;
179 /* check extension in the form "/proxy_pattern" */
180 - if (*(extension->key->ptr) == '/' && strncmp(fn->ptr, extension->key->ptr, ct_len) == 0) {
181 - if (s_len > ct_len + 1) {
183 + if (*(extension->key->ptr) == '/') {
184 + if (strncmp(fn->ptr, extension->key->ptr, ct_len) == 0) {
185 + if (s_len > ct_len + 1) {
188 - if (0 != (pi_offset = strchr(fn->ptr + ct_len + 1, '/'))) {
189 - path_info_offset = pi_offset - fn->ptr;
190 + if (0 != (pi_offset = strchr(fn->ptr + ct_len + 1, '/'))) {
191 + path_info_offset = pi_offset - fn->ptr;
197 } else if (0 == strncmp(fn->ptr + s_len - ct_len, extension->key->ptr, ct_len)) {
198 /* check extension in the form ".fcg" */
200 Index: src/mod_extforward.c
201 ===================================================================
202 --- src/mod_extforward.c (.../tags/lighttpd-1.4.18) (revision 2060)
203 +++ src/mod_extforward.c (.../branches/lighttpd-1.4.x) (revision 2060)
206 if (real_remote_addr != NULL) { /* parsed */
209 struct addrinfo *addrs_left;
210 + server_socket *srv_sock = con->srv_socket;
211 + data_string *forwarded_proto = (data_string *) array_get_element(con->request.headers,"X-Forwarded-Proto");
213 + if (forwarded_proto && !strcmp(forwarded_proto->value->ptr, "https"))
214 + srv_sock->is_proxy_ssl = 1;
216 + srv_sock->is_proxy_ssl = 0;
218 if (con->conf.log_request_handling) {
219 log_error_write(srv, __FILE__, __LINE__, "ss",
220 "using address:", real_remote_addr);
221 Index: src/Makefile.am
222 ===================================================================
223 --- src/Makefile.am (.../tags/lighttpd-1.4.18) (revision 2060)
224 +++ src/Makefile.am (.../branches/lighttpd-1.4.x) (revision 2060)
228 noinst_HEADERS = $(hdr)
229 -EXTRA_DIST = mod_skeleton.c configparser.y mod_ssi_exprparser.y lempar.c
230 +EXTRA_DIST = mod_skeleton.c configparser.y mod_ssi_exprparser.y lempar.c SConscript
231 Index: src/configparser.y
232 ===================================================================
233 --- src/configparser.y (.../tags/lighttpd-1.4.18) (revision 2060)
234 +++ src/configparser.y (.../branches/lighttpd-1.4.x) (revision 2060)
236 { COMP_HTTP_COOKIE, CONST_STR_LEN("HTTP[\"cookie\"]" ) },
237 { COMP_HTTP_REMOTEIP, CONST_STR_LEN("HTTP[\"remoteip\"]" ) },
238 { COMP_HTTP_QUERYSTRING, CONST_STR_LEN("HTTP[\"querystring\"]") },
239 + { COMP_HTTP_SCHEME, CONST_STR_LEN("HTTP[\"scheme\"]" ) },
240 { COMP_UNSET, NULL, 0 },
243 Index: src/mod_status.c
244 ===================================================================
245 --- src/mod_status.c (.../tags/lighttpd-1.4.18) (revision 2060)
246 +++ src/mod_status.c (.../branches/lighttpd-1.4.x) (revision 2060)
254 b = chunkqueue_get_append_buffer(con->write_queue);
257 buffer_append_long(b, srv->conns->used);
258 BUFFER_APPEND_STRING_CONST(b, "\n");
260 + BUFFER_APPEND_STRING_CONST(b, "IdleServers: ");
261 + buffer_append_long(b, srv->conns->size - srv->conns->used);
262 + BUFFER_APPEND_STRING_CONST(b, "\n");
264 + /* output scoreboard */
265 + BUFFER_APPEND_STRING_CONST(b, "Scoreboard: ");
266 + for (k = 0; k < srv->conns->used; k++) {
267 + connection *c = srv->conns->ptr[k];
268 + const char *state = connection_get_short_state(c->state);
269 + buffer_append_string_len(b, state, 1);
271 + for (l = 0; l < srv->conns->size - srv->conns->used; l++) {
272 + BUFFER_APPEND_STRING_CONST(b, "_");
274 + BUFFER_APPEND_STRING_CONST(b, "\n");
276 /* set text/plain output */
278 response_header_overwrite(srv, con, CONST_STR_LEN("Content-Type"), CONST_STR_LEN("text/plain"));
280 ===================================================================
281 --- src/mod_ssi.c (.../tags/lighttpd-1.4.18) (revision 2060)
282 +++ src/mod_ssi.c (.../branches/lighttpd-1.4.x) (revision 2060)
284 #include <sys/filio.h>
289 +/* The newest modified time of included files for include statement */
290 +static volatile time_t include_file_last_mtime = 0;
292 /* init the plugin data */
293 INIT_FUNC(mod_ssi_init) {
298 chunkqueue_append_file(con->write_queue, p->stat_fn, 0, st.st_size);
300 + /* Keep the newest mtime of included files */
301 + if (st.st_mtime > include_file_last_mtime)
302 + include_file_last_mtime = st.st_mtime;
308 build_ssi_cgi_vars(srv, con, p);
311 + /* Reset the modified time of included files */
312 + include_file_last_mtime = 0;
314 if (-1 == stream_open(&s, con->physical.path)) {
315 log_error_write(srv, __FILE__, __LINE__, "sb",
316 "stream-open: ", con->physical.path);
317 @@ -1010,6 +1023,30 @@
319 response_header_overwrite(srv, con, CONST_STR_LEN("Content-Type"), CONST_STR_LEN("text/html"));
322 + /* Generate "ETag" & "Last-Modified" headers */
324 + stat_cache_entry *sce = NULL;
325 + time_t lm_time = 0;
326 + buffer *mtime = NULL;
328 + stat_cache_get_entry(srv, con, con->physical.path, &sce);
330 + etag_mutate(con->physical.etag, sce->etag);
331 + response_header_overwrite(srv, con, CONST_STR_LEN("ETag"), CONST_BUF_LEN(con->physical.etag));
333 + if (sce->st.st_mtime > include_file_last_mtime)
334 + lm_time = sce->st.st_mtime;
336 + lm_time = include_file_last_mtime;
338 + mtime = strftime_cache_get(srv, lm_time);
339 + response_header_overwrite(srv, con, CONST_STR_LEN("Last-Modified"), CONST_BUF_LEN(mtime));
342 + /* Reset the modified time of included files */
343 + include_file_last_mtime = 0;
345 /* reset physical.path */
346 buffer_reset(con->physical.path);
348 Index: src/spawn-fcgi.c
349 ===================================================================
350 --- src/spawn-fcgi.c (.../tags/lighttpd-1.4.18) (revision 2060)
351 +++ src/spawn-fcgi.c (.../branches/lighttpd-1.4.x) (revision 2060)
356 -int fcgi_spawn_connection(char *appPath, char *addr, unsigned short port, const char *unixsocket, int child_count, int pid_fd, int nofork) {
357 +int fcgi_spawn_connection(char *appPath, char **appArgv, char *addr, unsigned short port, const char *unixsocket, int child_count, int pid_fd, int nofork) {
359 int socket_type, status;
360 struct timeval tv = { 0, 100 * 1000 };
361 @@ -137,11 +137,10 @@
369 - /* is save as we limit to 256 childs */
370 + /* is safe as we limit to 256 childs */
371 sprintf(cgi_childs, "PHP_FCGI_CHILDREN=%d", child_count);
373 if(fcgi_fd != FCGI_LISTENSOCK_FILENO) {
374 @@ -160,13 +159,18 @@
377 /* fork and replace shell */
378 - b = malloc(strlen("exec ") + strlen(appPath) + 1);
379 - strcpy(b, "exec ");
380 - strcat(b, appPath);
382 + execv(appArgv[0], appArgv);
385 - execl("/bin/sh", "sh", "-c", b, (char *)NULL);
387 + char *b = malloc(strlen("exec ") + strlen(appPath) + 1);
388 + strcpy(b, "exec ");
389 + strcat(b, appPath);
392 + execl("/bin/sh", "sh", "-c", b, (char *)NULL);
402 - char *b = "spawn-fcgi" "-" PACKAGE_VERSION \
403 -" - spawns fastcgi processes\n" \
406 +"Usage: spawn-fcgi [options] -- <fcgiapp> [fcgi app arguments]\n" \
408 +"spawn-fcgi v" PACKAGE_VERSION " - spawns fastcgi processes\n" \
411 " -f <fcgiapp> filename of the fcgi-application\n" \
412 " -a <addr> bind to ip address\n" \
413 " -p <port> bind to tcp-port\n" \
415 char *fcgi_app = NULL, *changeroot = NULL, *username = NULL,
416 *groupname = NULL, *unixsocket = NULL, *pid_file = NULL,
418 + char **fcgi_app_argv = { NULL };
419 unsigned short port = 0;
424 i_am_root = (getuid() == 0);
426 - while(-1 != (o = getopt(argc, argv, "c:f:g:hna:p:u:vC:s:P:"))) {
427 + while(-1 != (o = getopt(argc, argv, "c:f:g:hna:p:u:vC:s:P:"))) {
429 case 'f': fcgi_app = optarg; break;
430 case 'a': addr = optarg;/* ip addr */ break;
435 - if (fcgi_app == NULL || (port == 0 && unixsocket == NULL)) {
436 + if (optind < argc) {
437 + fcgi_app_argv = &argv[optind];
440 + if ((fcgi_app == NULL && fcgi_app_argv == NULL) || (port == 0 && unixsocket == NULL)) {
449 + * Change group before chroot, when we have access
453 + setgid(grp->gr_gid);
454 + setgroups(0, NULL);
456 + initgroups(username, grp->gr_gid);
461 if (-1 == chroot(changeroot)) {
462 fprintf(stderr, "%s.%d: %s %s\n",
463 @@ -420,18 +444,12 @@
466 /* drop root privs */
468 - setgid(grp->gr_gid);
472 - initgroups(username, grp->gr_gid);
478 - return fcgi_spawn_connection(fcgi_app, addr, port, unixsocket, child_count, pid_fd, nofork);
479 + return fcgi_spawn_connection(fcgi_app, fcgi_app_argv, addr, port, unixsocket, child_count, pid_fd, nofork);
483 Index: src/mod_auth.c
484 ===================================================================
485 --- src/mod_auth.c (.../tags/lighttpd-1.4.18) (revision 2060)
486 +++ src/mod_auth.c (.../branches/lighttpd-1.4.x) (revision 2060)
487 @@ -238,13 +238,13 @@
488 int auth_type_len = auth_realm - http_authorization;
490 if ((auth_type_len == 5) &&
491 - (0 == strncmp(http_authorization, "Basic", auth_type_len))) {
492 + (0 == strncasecmp(http_authorization, "Basic", auth_type_len))) {
494 if (0 == strcmp(method->value->ptr, "basic")) {
495 auth_satisfied = http_auth_basic_check(srv, con, p, req, con->uri.path, auth_realm+1);
497 } else if ((auth_type_len == 6) &&
498 - (0 == strncmp(http_authorization, "Digest", auth_type_len))) {
499 + (0 == strncasecmp(http_authorization, "Digest", auth_type_len))) {
500 if (0 == strcmp(method->value->ptr, "digest")) {
501 if (-1 == (auth_satisfied = http_auth_digest_check(srv, con, p, req, con->uri.path, auth_realm+1))) {
502 con->http_status = 400;
503 Index: src/mod_fastcgi.c
504 ===================================================================
505 --- src/mod_fastcgi.c (.../tags/lighttpd-1.4.18) (revision 2060)
506 +++ src/mod_fastcgi.c (.../branches/lighttpd-1.4.x) (revision 2060)
508 * if host is one of the local IP adresses the
509 * whole connection is local
511 - * if tcp/ip should be used host AND port have
513 + * if port is not 0, and host is not specified,
514 + * "localhost" (INADDR_LOOPBACK) is assumed.
518 @@ -823,12 +823,12 @@
519 fcgi_addr_in.sin_family = AF_INET;
521 if (buffer_is_empty(host->host)) {
522 - fcgi_addr_in.sin_addr.s_addr = htonl(INADDR_ANY);
523 + fcgi_addr_in.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
527 /* set a useful default */
528 - fcgi_addr_in.sin_addr.s_addr = htonl(INADDR_ANY);
529 + fcgi_addr_in.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
532 if (NULL == (he = gethostbyname(host->host->ptr))) {
534 fcgi_addr = (struct sockaddr *) &fcgi_addr_in;
536 buffer_copy_string(proc->connection_name, "tcp:");
537 - buffer_append_string_buffer(proc->connection_name, host->host);
538 + if (!buffer_is_empty(host->host)) {
539 + buffer_append_string_buffer(proc->connection_name, host->host);
541 + buffer_append_string(proc->connection_name, "localhost");
543 buffer_append_string(proc->connection_name, ":");
544 buffer_append_long(proc->connection_name, proc->port);
546 @@ -1687,12 +1691,16 @@
549 fcgi_addr_in.sin_family = AF_INET;
550 - if (0 == inet_aton(host->host->ptr, &(fcgi_addr_in.sin_addr))) {
551 - log_error_write(srv, __FILE__, __LINE__, "sbs",
552 - "converting IP address failed for", host->host,
553 - "\nBe sure to specify an IP address here");
556 + if (!buffer_is_empty(host->host)) {
557 + if (0 == inet_aton(host->host->ptr, &(fcgi_addr_in.sin_addr))) {
558 + log_error_write(srv, __FILE__, __LINE__, "sbs",
559 + "converting IP address failed for", host->host,
560 + "\nBe sure to specify an IP address here");
565 + fcgi_addr_in.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
567 fcgi_addr_in.sin_port = htons(proc->port);
568 servlen = sizeof(fcgi_addr_in);
569 @@ -1702,7 +1710,11 @@
570 if (buffer_is_empty(proc->connection_name)) {
571 /* on remote spawing we have to set the connection-name now */
572 buffer_copy_string(proc->connection_name, "tcp:");
573 - buffer_append_string_buffer(proc->connection_name, host->host);
574 + if (!buffer_is_empty(host->host)) {
575 + buffer_append_string_buffer(proc->connection_name, host->host);
577 + buffer_append_string(proc->connection_name, "localhost");
579 buffer_append_string(proc->connection_name, ":");
580 buffer_append_long(proc->connection_name, proc->port);
582 @@ -2045,13 +2057,10 @@
583 s = get_http_version_name(con->request.http_version);
584 FCGI_ENV_ADD_CHECK(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("SERVER_PROTOCOL"), s, strlen(s)),con)
587 - if (srv_sock->is_ssl) {
588 + if (srv_sock->is_ssl || srv_sock->is_proxy_ssl) {
589 FCGI_ENV_ADD_CHECK(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("HTTPS"), CONST_STR_LEN("on")),con)
594 FCGI_ENV_ADD_CHECK(fcgi_env_add_request_headers(srv, con, p), con);
596 fcgi_header(&(header), FCGI_PARAMS, request_id, p->fcgi_env->used, 0);
597 @@ -2530,15 +2539,28 @@
600 if (host->allow_xsendfile &&
601 - NULL != (ds = (data_string *) array_get_element(con->response.headers, "X-LIGHTTPD-send-file"))) {
602 + (NULL != (ds = (data_string *) array_get_element(con->response.headers, "X-LIGHTTPD-send-file"))
603 + || NULL != (ds = (data_string *) array_get_element(con->response.headers, "X-Sendfile")))) {
604 stat_cache_entry *sce;
606 if (HANDLER_ERROR != stat_cache_get_entry(srv, con, ds->value, &sce)) {
607 + data_string *dcls = data_string_init();
610 http_chunk_append_file(srv, con, ds->value, 0, sce->st.st_size);
611 hctx->send_content_body = 0; /* ignore the content */
612 joblist_append(srv, con);
614 + buffer_copy_string_len(dcls->key, "Content-Length", sizeof("Content-Length")-1);
615 + buffer_copy_long(dcls->value, sce->st.st_size);
616 + dcls = (data_string*) array_replace(con->response.headers, (data_unset *)dcls);
617 + if (dcls) dcls->free((data_unset*)dcls);
619 + con->parsed_response |= HTTP_CONTENT_LENGTH;
620 + con->response.content_length = sce->st.st_size;
622 + log_error_write(srv, __FILE__, __LINE__, "sb",
623 + "send-file error: couldn't get stat_cache entry for:",
628 @@ -2719,9 +2741,14 @@
636 + * - tcp socket (do not check host->host->uses, as it may be not set which means INADDR_LOOPBACK)
640 - ((!host->host->used || !host->port) && !host->unixsocket->used)) {
641 + (!host->port && !host->unixsocket->used)) {
642 log_error_write(srv, __FILE__, __LINE__, "sxddd",
645 @@ -3456,8 +3483,9 @@
646 if (s_len < ct_len) continue;
648 /* check extension in the form "/fcgi_pattern" */
649 - if (*(extension->key->ptr) == '/' && strncmp(fn->ptr, extension->key->ptr, ct_len) == 0) {
651 + if (*(extension->key->ptr) == '/') {
652 + if (strncmp(fn->ptr, extension->key->ptr, ct_len) == 0)
654 } else if (0 == strncmp(fn->ptr + s_len - ct_len, extension->key->ptr, ct_len)) {
655 /* check extension in the form ".fcg" */
657 @@ -3473,7 +3501,7 @@
658 for (k = 0; k < extension->used; k++) {
659 host = extension->hosts[k];
661 - /* we should have at least one proc that can do somthing */
662 + /* we should have at least one proc that can do something */
663 if (host->active_procs == 0) {
667 ===================================================================
668 --- src/server.c (.../tags/lighttpd-1.4.18) (revision 2060)
669 +++ src/server.c (.../branches/lighttpd-1.4.x) (revision 2060)
676 + * Change group before chroot, when we have access
679 + if (srv->srvconf.groupname->used) {
680 + setgid(grp->gr_gid);
681 + setgroups(0, NULL);
682 + if (srv->srvconf.username->used) {
683 + initgroups(srv->srvconf.username->ptr, grp->gr_gid);
688 if (srv->srvconf.changeroot->used) {
693 /* drop root privs */
694 - if (srv->srvconf.groupname->used) {
695 - setgid(grp->gr_gid);
696 - setgroups(0, NULL);
699 if (srv->srvconf.username->used) {
700 - if (srv->srvconf.groupname->used) {
701 - initgroups(srv->srvconf.username->ptr, grp->gr_gid);
710 + // Close stderr ASAP in the child process to make sure that nothing
711 + // is being written to that fd which may not be valid anymore.
712 + if (-1 == log_error_open(srv)) {
713 + log_error_write(srv, __FILE__, __LINE__, "s", "Opening errorlog failed. Going down.");
716 + network_close(srv);
721 if (HANDLER_GO_ON != plugins_call_set_defaults(srv)) {
722 log_error_write(srv, __FILE__, __LINE__, "s", "Configuration of plugins failed. Going down.");
728 - if (-1 == log_error_open(srv)) {
729 - log_error_write(srv, __FILE__, __LINE__, "s",
730 - "opening errorlog failed, dying");
733 - network_close(srv);
739 #ifdef HAVE_SIGACTION
740 Index: tests/mod-access.t
741 ===================================================================
742 --- tests/mod-access.t (.../tags/lighttpd-1.4.18) (revision 2060)
743 +++ tests/mod-access.t (.../branches/lighttpd-1.4.x) (revision 2060)
747 - # add current source dir to the include-path
748 - # we need this for make distcheck
749 - (my $srcdir = $0) =~ s#/[^/]+$#/#;
750 - unshift @INC, $srcdir;
751 + # add current source dir to the include-path
752 + # we need this for make distcheck
753 + (my $srcdir = $0) =~ s,/[^/]+$,/,;
754 + unshift @INC, $srcdir;
758 Index: tests/mod-auth.t
759 ===================================================================
760 --- tests/mod-auth.t (.../tags/lighttpd-1.4.18) (revision 2060)
761 +++ tests/mod-auth.t (.../branches/lighttpd-1.4.x) (revision 2060)
765 - # add current source dir to the include-path
766 - # we need this for make distcheck
767 - (my $srcdir = $0) =~ s#/[^/]+$#/#;
768 - unshift @INC, $srcdir;
769 + # add current source dir to the include-path
770 + # we need this for make distcheck
771 + (my $srcdir = $0) =~ s,/[^/]+$,/,;
772 + unshift @INC, $srcdir;
777 -use Test::More tests => 13;
778 +use Test::More tests => 14;
781 my $tf = LightyTest->new();
783 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
784 ok($tf->handle_http($t) == 0, 'Basic-Auth: Valid Auth-token - htpasswd (des)');
786 +$t->{REQUEST} = ( <<EOF
787 +GET /server-config HTTP/1.0
788 +Host: auth-htpasswd.example.org
789 +Authorization: basic ZGVzOmRlcw==
792 +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
793 +ok($tf->handle_http($t) == 0, 'Basic-Auth: Valid Auth-token - htpasswd (des) (lowercase)');
797 skip "no md5 for crypt under cygwin", 1 if $^O eq 'cygwin';
798 $t->{REQUEST} = ( <<EOF
799 Index: tests/mod-secdownload.t
800 ===================================================================
801 Index: tests/core-response.t
802 ===================================================================
803 --- tests/core-response.t (.../tags/lighttpd-1.4.18) (revision 2060)
804 +++ tests/core-response.t (.../branches/lighttpd-1.4.x) (revision 2060)
809 - # add current source dir to the include-path
810 - # we need this for make distcheck
811 - (my $srcdir = $0) =~ s#/[^/]+$#/#;
812 - unshift @INC, $srcdir;
813 + # add current source dir to the include-path
814 + # we need this for make distcheck
815 + (my $srcdir = $0) =~ s,/[^/]+$,/,;
816 + unshift @INC, $srcdir;
820 Index: tests/mod-extforward.conf
821 ===================================================================
822 --- tests/mod-extforward.conf (.../tags/lighttpd-1.4.18) (revision 0)
823 +++ tests/mod-extforward.conf (.../branches/lighttpd-1.4.x) (revision 2060)
825 +debug.log-request-handling = "enable"
826 +debug.log-response-header = "enable"
827 +debug.log-request-header = "enable"
829 +server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/"
830 +server.pid-file = env.SRCDIR + "/tmp/lighttpd/lighttpd.pid"
832 +## bind to port (default: 80)
835 +## bind to localhost (default: all interfaces)
836 +server.bind = "localhost"
837 +server.errorlog = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log"
838 +server.name = "www.example.org"
839 +server.tag = "Apache 1.3.29"
846 +######################## MODULE CONFIG ############################
848 +mimetype.assign = ( ".html" => "text/html" )
850 +cgi.assign = (".pl" => "/usr/bin/perl" )
852 +extforward.forwarder = (
853 + "127.0.0.1" => "trust",
855 Index: tests/symlink.t
856 ===================================================================
857 Index: tests/request.t
858 ===================================================================
859 --- tests/request.t (.../tags/lighttpd-1.4.18) (revision 2060)
860 +++ tests/request.t (.../branches/lighttpd-1.4.x) (revision 2060)
864 - # add current source dir to the include-path
865 - # we need this for make distcheck
866 - (my $srcdir = $0) =~ s#/[^/]+$#/#;
867 - unshift @INC, $srcdir;
868 + # add current source dir to the include-path
869 + # we need this for make distcheck
870 + (my $srcdir = $0) =~ s,/[^/]+$,/,;
871 + unshift @INC, $srcdir;
875 Index: tests/mod-userdir.t
876 ===================================================================
877 --- tests/mod-userdir.t (.../tags/lighttpd-1.4.18) (revision 2060)
878 +++ tests/mod-userdir.t (.../branches/lighttpd-1.4.x) (revision 2060)
882 - # add current source dir to the include-path
883 - # we need this for make distcheck
884 - (my $srcdir = $0) =~ s#/[^/]+$#/#;
885 - unshift @INC, $srcdir;
886 + # add current source dir to the include-path
887 + # we need this for make distcheck
888 + (my $srcdir = $0) =~ s,/[^/]+$,/,;
889 + unshift @INC, $srcdir;
893 Index: tests/core-keepalive.t
894 ===================================================================
895 --- tests/core-keepalive.t (.../tags/lighttpd-1.4.18) (revision 2060)
896 +++ tests/core-keepalive.t (.../branches/lighttpd-1.4.x) (revision 2060)
901 - # add current source dir to the include-path
902 - # we need this for make distcheck
903 - (my $srcdir = $0) =~ s#/[^/]+$#/#;
904 - unshift @INC, $srcdir;
905 + # add current source dir to the include-path
906 + # we need this for make distcheck
907 + (my $srcdir = $0) =~ s,/[^/]+$,/,;
908 + unshift @INC, $srcdir;
912 Index: tests/mod-proxy.t
913 ===================================================================
914 Index: tests/env-variables.t
915 ===================================================================
916 Index: tests/core-var-include.t
917 ===================================================================
918 --- tests/core-var-include.t (.../tags/lighttpd-1.4.18) (revision 2060)
919 +++ tests/core-var-include.t (.../branches/lighttpd-1.4.x) (revision 2060)
923 - # add current source dir to the include-path
924 - # we need this for make distcheck
925 - (my $srcdir = $0) =~ s#/[^/]+$#/#;
926 - unshift @INC, $srcdir;
927 + # add current source dir to the include-path
928 + # we need this for make distcheck
929 + (my $srcdir = $0) =~ s,/[^/]+$,/,;
930 + unshift @INC, $srcdir;
934 Index: tests/mod-extforward.t
935 ===================================================================
936 --- tests/mod-extforward.t (.../tags/lighttpd-1.4.18) (revision 0)
937 +++ tests/mod-extforward.t (.../branches/lighttpd-1.4.x) (revision 2060)
941 + # add current source dir to the include-path
942 + # we need this for make distcheck
943 + (my $srcdir = $0) =~ s,/[^/]+$,/,;
944 + unshift @INC, $srcdir;
949 +use Test::More tests => 2;
952 +my $tf = LightyTest->new();
955 +$tf->{CONFIGFILE} = 'mod-extforward.conf';
957 +ok($tf->start_proc == 0, "Starting lighttpd") or die();
959 +## check if If-Modified-Since, If-None-Match works
961 +$t->{REQUEST} = ( <<EOF
963 +Host: www.example.org
964 +X-Forwarded-For: 127.0.10.1
967 +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '127.0.10.1' } ];
968 +ok($tf->handle_http($t) == 0, 'expect 127.0.10.1');
970 +$t->{REQUEST} = ( <<EOF
972 +Host: www.example.org
973 +X-Forwarded-For: 127.0.10.1, 127.0.20.1
976 +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '127.0.20.1' } ];
977 +ok($tf->handle_http($t) == 0, 'expect 127.0.20.1');
979 +ok($tf->stop_proc == 0, "Stopping lighttpd");
981 Property changes on: tests/mod-extforward.t
982 ___________________________________________________________________
986 Index: tests/core-request.t
987 ===================================================================
988 --- tests/core-request.t (.../tags/lighttpd-1.4.18) (revision 2060)
989 +++ tests/core-request.t (.../branches/lighttpd-1.4.x) (revision 2060)
993 - # add current source dir to the include-path
994 - # we need this for make distcheck
995 - (my $srcdir = $0) =~ s#/[^/]+$#/#;
996 - unshift @INC, $srcdir;
997 + # add current source dir to the include-path
998 + # we need this for make distcheck
999 + (my $srcdir = $0) =~ s,/[^/]+$,/,;
1000 + unshift @INC, $srcdir;
1004 Index: tests/mod-redirect.t
1005 ===================================================================
1006 --- tests/mod-redirect.t (.../tags/lighttpd-1.4.18) (revision 2060)
1007 +++ tests/mod-redirect.t (.../branches/lighttpd-1.4.x) (revision 2060)
1011 - # add current source dir to the include-path
1012 - # we need this for make distcheck
1013 - (my $srcdir = $0) =~ s#/[^/]+$#/#;
1014 - unshift @INC, $srcdir;
1015 + # add current source dir to the include-path
1016 + # we need this for make distcheck
1017 + (my $srcdir = $0) =~ s,/[^/]+$,/,;
1018 + unshift @INC, $srcdir;
1022 Index: tests/mod-cgi.t
1023 ===================================================================
1024 --- tests/mod-cgi.t (.../tags/lighttpd-1.4.18) (revision 2060)
1025 +++ tests/mod-cgi.t (.../branches/lighttpd-1.4.x) (revision 2060)
1029 - # add current source dir to the include-path
1030 - # we need this for make distcheck
1031 - (my $srcdir = $0) =~ s#/[^/]+$#/#;
1032 - unshift @INC, $srcdir;
1033 + # add current source dir to the include-path
1034 + # we need this for make distcheck
1035 + (my $srcdir = $0) =~ s,/[^/]+$,/,;
1036 + unshift @INC, $srcdir;
1040 Index: tests/mod-setenv.t
1041 ===================================================================
1042 --- tests/mod-setenv.t (.../tags/lighttpd-1.4.18) (revision 2060)
1043 +++ tests/mod-setenv.t (.../branches/lighttpd-1.4.x) (revision 2060)
1048 - # add current source dir to the include-path
1049 - # we need this for make distcheck
1050 - (my $srcdir = $0) =~ s#/[^/]+$#/#;
1051 - unshift @INC, $srcdir;
1052 + # add current source dir to the include-path
1053 + # we need this for make distcheck
1054 + (my $srcdir = $0) =~ s,/[^/]+$,/,;
1055 + unshift @INC, $srcdir;
1059 Index: tests/cachable.t
1060 ===================================================================
1061 --- tests/cachable.t (.../tags/lighttpd-1.4.18) (revision 2060)
1062 +++ tests/cachable.t (.../branches/lighttpd-1.4.x) (revision 2060)
1066 - # add current source dir to the include-path
1067 - # we need this for make distcheck
1068 - (my $srcdir = $0) =~ s#/[^/]+$#/#;
1069 - unshift @INC, $srcdir;
1070 + # add current source dir to the include-path
1071 + # we need this for make distcheck
1072 + (my $srcdir = $0) =~ s,/[^/]+$,/,;
1073 + unshift @INC, $srcdir;
1077 Index: tests/lowercase.t
1078 ===================================================================
1079 --- tests/lowercase.t (.../tags/lighttpd-1.4.18) (revision 2060)
1080 +++ tests/lowercase.t (.../branches/lighttpd-1.4.x) (revision 2060)
1084 - # add current source dir to the include-path
1085 - # we need this for make distcheck
1086 - (my $srcdir = $0) =~ s#/[^/]+$#/#;
1087 - unshift @INC, $srcdir;
1088 + # add current source dir to the include-path
1089 + # we need this for make distcheck
1090 + (my $srcdir = $0) =~ s,/[^/]+$,/,;
1091 + unshift @INC, $srcdir;
1096 ===================================================================
1097 --- tests/core.t (.../tags/lighttpd-1.4.18) (revision 2060)
1098 +++ tests/core.t (.../branches/lighttpd-1.4.x) (revision 2060)
1103 - # add current source dir to the include-path
1104 - # we need this for make distcheck
1105 - (my $srcdir = $0) =~ s#/[^/]+$#/#;
1106 - unshift @INC, $srcdir;
1107 + # add current source dir to the include-path
1108 + # we need this for make distcheck
1109 + (my $srcdir = $0) =~ s,/[^/]+$,/,;
1110 + unshift @INC, $srcdir;
1114 Index: tests/mod-fastcgi.t
1115 ===================================================================
1116 --- tests/mod-fastcgi.t (.../tags/lighttpd-1.4.18) (revision 2060)
1117 +++ tests/mod-fastcgi.t (.../branches/lighttpd-1.4.x) (revision 2060)
1121 - # add current source dir to the include-path
1122 - # we need this for make distcheck
1123 - (my $srcdir = $0) =~ s#/[^/]+$#/#;
1124 - unshift @INC, $srcdir;
1125 + # add current source dir to the include-path
1126 + # we need this for make distcheck
1127 + (my $srcdir = $0) =~ s,/[^/]+$,/,;
1128 + unshift @INC, $srcdir;
1132 Index: tests/mod-rewrite.t
1133 ===================================================================
1134 --- tests/mod-rewrite.t (.../tags/lighttpd-1.4.18) (revision 2060)
1135 +++ tests/mod-rewrite.t (.../branches/lighttpd-1.4.x) (revision 2060)
1139 - # add current source dir to the include-path
1140 - # we need this for make distcheck
1141 - (my $srcdir = $0) =~ s#/[^/]+$#/#;
1142 - unshift @INC, $srcdir;
1143 + # add current source dir to the include-path
1144 + # we need this for make distcheck
1145 + (my $srcdir = $0) =~ s,/[^/]+$,/,;
1146 + unshift @INC, $srcdir;
1150 Index: tests/docroot/www/ip.pl
1151 ===================================================================
1152 --- tests/docroot/www/ip.pl (.../tags/lighttpd-1.4.18) (revision 0)
1153 +++ tests/docroot/www/ip.pl (.../branches/lighttpd-1.4.x) (revision 2060)
1156 +print "Content-Type: text/html\r\n\r\n";
1157 +print $ENV{'REMOTE_ADDR'};
1161 Property changes on: tests/docroot/www/ip.pl
1162 ___________________________________________________________________
1163 Name: svn:executable
1166 Index: tests/Makefile.am
1167 ===================================================================
1168 --- tests/Makefile.am (.../tags/lighttpd-1.4.18) (revision 2060)
1169 +++ tests/Makefile.am (.../branches/lighttpd-1.4.x) (revision 2060)
1176 + mod-secdownload.t \
1187 + env-variables.conf \
1193 core-404-handler.t \
1197 TESTS_ENVIRONMENT=$(srcdir)/wrapper.sh $(srcdir) $(top_builddir)
1199 EXTRA_DIST=wrapper.sh lighttpd.conf \
1206 Index: tests/core-404-handler.t
1207 ===================================================================
1208 --- tests/core-404-handler.t (.../tags/lighttpd-1.4.18) (revision 2060)
1209 +++ tests/core-404-handler.t (.../branches/lighttpd-1.4.x) (revision 2060)
1211 # returning no status -> 200
1214 - # add current source dir to the include-path
1215 - # we need this for make distcheck
1216 - (my $srcdir = $0) =~ s#/[^/]+$#/#;
1217 - unshift @INC, $srcdir;
1218 + # add current source dir to the include-path
1219 + # we need this for make distcheck
1220 + (my $srcdir = $0) =~ s,/[^/]+$,/,;
1221 + unshift @INC, $srcdir;
1225 Index: tests/mod-compress.t
1226 ===================================================================
1227 --- tests/mod-compress.t (.../tags/lighttpd-1.4.18) (revision 2060)
1228 +++ tests/mod-compress.t (.../branches/lighttpd-1.4.x) (revision 2060)
1232 - # add current source dir to the include-path
1233 - # we need this for make distcheck
1234 - (my $srcdir = $0) =~ s#/[^/]+$#/#;
1235 - unshift @INC, $srcdir;
1236 + # add current source dir to the include-path
1237 + # we need this for make distcheck
1238 + (my $srcdir = $0) =~ s,/[^/]+$,/,;
1239 + unshift @INC, $srcdir;
1243 Index: tests/mod-ssi.t
1244 ===================================================================
1245 --- tests/mod-ssi.t (.../tags/lighttpd-1.4.18) (revision 2060)
1246 +++ tests/mod-ssi.t (.../branches/lighttpd-1.4.x) (revision 2060)
1250 - # add current source dir to the include-path
1251 - # we need this for make distcheck
1252 - (my $srcdir = $0) =~ s#/[^/]+$#/#;
1253 - unshift @INC, $srcdir;
1254 + # add current source dir to the include-path
1255 + # we need this for make distcheck
1256 + (my $srcdir = $0) =~ s,/[^/]+$,/,;
1257 + unshift @INC, $srcdir;
1261 Index: tests/core-condition.t
1262 ===================================================================
1263 --- tests/core-condition.t (.../tags/lighttpd-1.4.18) (revision 2060)
1264 +++ tests/core-condition.t (.../branches/lighttpd-1.4.x) (revision 2060)
1268 - # add current source dir to the include-path
1269 - # we need this for make distcheck
1270 - (my $srcdir = $0) =~ s#/[^/]+$#/#;
1271 - unshift @INC, $srcdir;
1272 + # add current source dir to the include-path
1273 + # we need this for make distcheck
1274 + (my $srcdir = $0) =~ s,/[^/]+$,/,;
1275 + unshift @INC, $srcdir;
1279 Index: doc/configuration.txt
1280 ===================================================================
1281 --- doc/configuration.txt (.../tags/lighttpd-1.4.18) (revision 2060)
1282 +++ doc/configuration.txt (.../branches/lighttpd-1.4.x) (revision 2060)
1292 Index: doc/lighttpd.conf
1293 ===================================================================
1294 --- doc/lighttpd.conf (.../tags/lighttpd-1.4.18) (revision 2060)
1295 +++ doc/lighttpd.conf (.../branches/lighttpd-1.4.x) (revision 2060)
1297 ".ogg" => "application/ogg",
1298 ".wav" => "audio/x-wav",
1299 ".gif" => "image/gif",
1300 + ".jar" => "application/x-java-archive",
1301 ".jpg" => "image/jpeg",
1302 ".jpeg" => "image/jpeg",
1303 ".png" => "image/png",
1305 ===================================================================
1307 ===================================================================
1308 --- Makefile.am (.../tags/lighttpd-1.4.18) (revision 2060)
1309 +++ Makefile.am (.../branches/lighttpd-1.4.x) (revision 2060)
1311 SUBDIRS=src doc tests cygwin openwrt
1313 -EXTRA_DIST=lighttpd.spec
1314 +EXTRA_DIST=lighttpd.spec autogen.sh SConstruct
1316 ===================================================================
1317 --- NEWS (.../tags/lighttpd-1.4.18) (revision 2060)
1318 +++ NEWS (.../branches/lighttpd-1.4.x) (revision 2060)
1325 + * added support for If-Range: <date> (#1346)
1326 + * added support for matching $HTTP["scheme"] in configs
1327 + * fixed initgroups() called after chroot (#1384)
1328 + * fixed case-sensitive check for Auth-Method (#1456)
1329 + * execute fcgi app without /bin/sh if used as argument to spawn-fcgi (#1428)
1330 + * fixed a bug that made /-prefixed extensions being handled also when
1331 + matching the end of the uri in fcgi,scgi and proxy modules (#1489)
1332 + * print error if X-LIGHTTPD-send-file cannot be done; reset header
1333 + Content-Length for send-file. Patches by Stefan Buhler
1334 + * prevent crash in certain php-fcgi configurations (#841)
1335 + * add IdleServers and Scoreboard directives in ?auto mode for mod_status (#1507)
1336 + * open log immediately after daemonizing, fixes SIGPIPEs on startup (#165)
1337 + * HTTPS env var should be "on" when using mod_extforward and the X-Forwarded-Proto header is set. (#1499)
1338 + * generate ETag and Last-Modified headers for mod_ssi based on newest modified include (#1491)
1339 + * support letterhomes in mod_userdir (#1473)
1341 - 1.4.18 - 2007-09-09
1343 * fixed compile error on IRIX 6.5.x on prctl() (#1333)
1344 Index: lighttpd.spec.in
1345 ===================================================================
1346 --- lighttpd.spec.in (.../tags/lighttpd-1.4.18) (revision 2060)
1347 +++ lighttpd.spec.in (.../branches/lighttpd-1.4.x) (revision 2060)
1349 Packager: Jan Kneschke <jan@kneschke.de>
1351 Group: Networking/Daemons
1352 -URL: http://jan.kneschke.de/projects/lighttpd/
1353 +URL: http://www.lighttpd.net/
1354 Requires: pcre >= 3.1 zlib
1355 -BuildPrereq: libtool zlib-devel
1356 +BuildRequires: libtool zlib-devel
1357 BuildRoot: %{_tmppath}/%{name}-root
1361 lighttpd is intented to be a frontend for ad-servers which have to deliver
1362 small files concurrently to many connections.
1364 -Available rpmbuild rebuild options :
1365 ---with : ssl mysql lua memcache
1366 +Available rpmbuild rebuild options:
1367 +--with: ssl mysql lua memcache
1381 mkdir -p %{buildroot}%{_sysconfdir}/{init.d,sysconfig}
1382 -if test -f /etc/redhat-release -o -f /etc/fedora-release; then
1383 - install -m 755 doc/rc.lighttpd.redhat %{buildroot}%{_sysconfdir}/init.d/lighttpd
1384 +if [ -f /etc/redhat-release -o -f /etc/fedora-release ]; then
1385 + install -m 755 doc/rc.lighttpd.redhat %{buildroot}%{_sysconfdir}/init.d/lighttpd
1387 - install -m 755 doc/rc.lighttpd %{buildroot}%{_sysconfdir}/init.d/lighttpd
1388 + install -m 755 doc/rc.lighttpd %{buildroot}%{_sysconfdir}/init.d/lighttpd
1390 install -m 644 doc/sysconfig.lighttpd %{buildroot}%{_sysconfdir}/sysconfig/lighttpd
1395 ## read http://www.fedora.us/docs/spec.html next time :)
1396 -if test "$1" = "1"; then
1397 - # real install, not upgrade
1398 - /sbin/chkconfig --add lighttpd
1399 +if [ "$1" = "1" ]; then
1400 + # real install, not upgrade
1401 + /sbin/chkconfig --add lighttpd
1405 -if test "$1" = "0"; then
1406 - # real uninstall, not upgrade
1407 - %{_sysconfdir}/init.d/lighttpd stop
1408 - /sbin/chkconfig --del lighttpd
1409 +if [ "$1" = "0"]; then
1410 + # real uninstall, not upgrade
1411 + %{_sysconfdir}/init.d/lighttpd stop
1412 + /sbin/chkconfig --del lighttpd