]> git.pld-linux.org Git - packages/lighttpd.git/blob - lighttpd-branch.diff
- update to @2061
[packages/lighttpd.git] / lighttpd-branch.diff
1 Index: configure.in
2 ===================================================================
3 Index: src/configfile-glue.c
4 ===================================================================
5 --- src/configfile-glue.c       (.../tags/lighttpd-1.4.18)      (revision 2061)
6 +++ src/configfile-glue.c       (.../branches/lighttpd-1.4.x)   (revision 2061)
7 @@ -341,6 +341,10 @@
8                 }
9                 break;
10         }
11 +       case COMP_HTTP_SCHEME:
12 +               l = con->uri.scheme;
13 +               break;
14 +
15         case COMP_HTTP_URL:
16                 l = con->uri.path;
17                 break;
18 Index: src/base.h
19 ===================================================================
20 --- src/base.h  (.../tags/lighttpd-1.4.18)      (revision 2061)
21 +++ src/base.h  (.../branches/lighttpd-1.4.x)   (revision 2061)
22 @@ -515,6 +515,7 @@
23  #ifdef USE_OPENSSL
24         SSL_CTX *ssl_ctx;
25  #endif
26 +       unsigned short is_proxy_ssl;
27  } server_socket;
28  
29  typedef struct {
30 Index: src/array.h
31 ===================================================================
32 --- src/array.h (.../tags/lighttpd-1.4.18)      (revision 2061)
33 +++ src/array.h (.../branches/lighttpd-1.4.x)   (revision 2061)
34 @@ -90,6 +90,7 @@
35         COMP_HTTP_COOKIE,
36         COMP_HTTP_REMOTEIP,
37         COMP_HTTP_QUERYSTRING,
38 +       COMP_HTTP_SCHEME,
39  
40         COMP_LAST_ELEMENT
41  } comp_key_t;
42 Index: src/mod_staticfile.c
43 ===================================================================
44 --- src/mod_staticfile.c        (.../tags/lighttpd-1.4.18)      (revision 2061)
45 +++ src/mod_staticfile.c        (.../branches/lighttpd-1.4.x)   (revision 2061)
46 @@ -483,8 +483,24 @@
47                         /* if the value is the same as our ETag, we do a Range-request,
48                          * otherwise a full 200 */
49  
50 -                       if (!buffer_is_equal(ds->value, con->physical.etag)) {
51 +                       if (ds->value->ptr[0] == '"') {
52 +                               /**
53 +                                * client wants a ETag
54 +                                */
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;
59 +                               }
60 +                       } else if (!mtime) {
61 +                               /**
62 +                                * we don't have a Last-Modified and can match the If-Range: 
63 +                                *
64 +                                * sending all
65 +                                */
66                                 do_range_request = 0;
67 +                       } else if (!buffer_is_equal(ds->value, mtime)) {
68 +                               do_range_request = 0;
69                         }
70                 }
71  
72 Index: src/mod_scgi.c
73 ===================================================================
74 --- src/mod_scgi.c      (.../tags/lighttpd-1.4.18)      (revision 2061)
75 +++ src/mod_scgi.c      (.../branches/lighttpd-1.4.x)   (revision 2061)
76 @@ -2694,8 +2694,9 @@
77                 if (s_len < ct_len) continue;
78  
79                 /* check extension in the form "/scgi_pattern" */
80 -               if (*(extension->key->ptr) == '/' && strncmp(fn->ptr, extension->key->ptr, ct_len) == 0) {
81 -                       break;
82 +               if (*(extension->key->ptr) == '/') {
83 +                       if (strncmp(fn->ptr, extension->key->ptr, ct_len) == 0)
84 +                               break;
85                 } else if (0 == strncmp(fn->ptr + s_len - ct_len, extension->key->ptr, ct_len)) {
86                         /* check extension in the form ".fcg" */
87                         break;
88 Index: src/response.c
89 ===================================================================
90 --- src/response.c      (.../tags/lighttpd-1.4.18)      (revision 2061)
91 +++ src/response.c      (.../branches/lighttpd-1.4.x)   (revision 2061)
92 @@ -59,7 +59,8 @@
93                 ds = (data_string *)con->response.headers->data[i];
94  
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;
101  
102 @@ -180,6 +181,7 @@
103                 buffer_copy_string_buffer(con->uri.authority, con->request.http_host);
104                 buffer_to_lower(con->uri.authority);
105  
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 2061)
113 +++ src/mod_userdir.c   (.../branches/lighttpd-1.4.x)   (revision 2061)
114 @@ -21,6 +21,7 @@
115         array *include_user;
116         buffer *path;
117         buffer *basepath;
118 +       unsigned short letterhomes;
119  } plugin_config;
120  
121  typedef struct {
122 @@ -87,6 +88,7 @@
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 }
128         };
129  
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;
135  
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);
141  
142                 p->config_storage[i] = s;
143  
144 @@ -128,6 +132,7 @@
145         PATCH(exclude_user);
146         PATCH(include_user);
147         PATCH(basepath);
148 +       PATCH(letterhomes);
149  
150         /* skip the first, the global context */
151         for (i = 1; i < srv->config_context->used; i++) {
152 @@ -149,6 +154,8 @@
153                                 PATCH(include_user);
154                         } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("userdir.basepath"))) {
155                                 PATCH(basepath);
156 +                       } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("userdir.letterhomes"))) {
157 +                               PATCH(letterhomes);
158                         }
159                 }
160         }
161 @@ -253,6 +260,10 @@
162  
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);
168 +               }
169                 buffer_append_string_buffer(p->temp_path, p->username);
170         }
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 2061)
175 +++ src/mod_proxy.c     (.../branches/lighttpd-1.4.x)   (revision 2061)
176 @@ -1093,15 +1093,17 @@
177                 if (s_len < ct_len) continue;
178  
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) {
182 -                               char *pi_offset;
183 +               if (*(extension->key->ptr) == '/') {
184 +                       if (strncmp(fn->ptr, extension->key->ptr, ct_len) == 0) {
185 +                               if (s_len > ct_len + 1) {
186 +                                       char *pi_offset;
187  
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;
192 +                                       }
193                                 }
194 +                               break;
195                         }
196 -                       break;
197                 } else if (0 == strncmp(fn->ptr + s_len - ct_len, extension->key->ptr, ct_len)) {
198                         /* check extension in the form ".fcg" */
199                         break;
200 Index: src/mod_extforward.c
201 ===================================================================
202 --- src/mod_extforward.c        (.../tags/lighttpd-1.4.18)      (revision 2061)
203 +++ src/mod_extforward.c        (.../branches/lighttpd-1.4.x)   (revision 2061)
204 @@ -20,6 +20,7 @@
205  /**
206   * mod_extforward.c for lighttpd, by comman.kang <at> gmail <dot> com
207   *                  extended, modified by Lionel Elie Mamane (LEM), lionel <at> mamane <dot> lu
208 + *                  support chained proxies by glen@delfi.ee, #1528
209   *
210   * Config example:
211   *
212 @@ -33,6 +34,10 @@
213   *       Note that "all" has precedence over specific entries,
214   *       so "all except" setups will not work.
215   *
216 + *       In case you have chained proxies, you can add all their IP's to the
217 + *       config. However "all" has effect only on connecting IP, as the
218 + *       X-Forwarded-For header can not be trusted.
219 + *
220   * Note: The effect of this module is variable on $HTTP["remotip"] directives and
221   *       other module's remote ip dependent actions.
222   *  Things done by modules before we change the remoteip or after we reset it will match on the proxy's IP.
223 @@ -225,18 +230,16 @@
224                 char *base, *curr;
225                 /* state variable, 0 means not in string, 1 means in string */
226                 int in_str = 0;
227 -               for (base = pbuffer->ptr, curr = pbuffer->ptr; *curr; curr++)
228 -               {
229 +               for (base = pbuffer->ptr, curr = pbuffer->ptr; *curr; curr++) {
230                         if (in_str) {
231 -                               if ( (*curr > '9' || *curr < '0') && *curr != '.' && *curr != ':' ) {
232 +                               if ((*curr > '9' || *curr < '0') && *curr != '.' && *curr != ':') {
233                                         /* found an separator , insert value into result array */
234 -                                       put_string_into_array_len(result, base, curr-base);
235 +                                       put_string_into_array_len(result, base, curr - base);
236                                         /* change state to not in string */
237                                         in_str = 0;
238                                 }
239                         } else {
240 -                               if (*curr >= '0' && *curr <= '9')
241 -                               {
242 +                               if (*curr >= '0' && *curr <= '9') {
243                                         /* found leading char of an IP address, move base pointer and change state */
244                                         base = curr;
245                                         in_str = 1;
246 @@ -244,9 +247,8 @@
247                         }
248                 }
249                 /* if breaking out while in str, we got to the end of string, so add it */
250 -               if (in_str)
251 -               {
252 -                       put_string_into_array_len(result, base, curr-base);
253 +               if (in_str) {
254 +                       put_string_into_array_len(result, base, curr - base);
255                 }
256         }
257         return result;
258 @@ -255,20 +257,42 @@
259  #define IP_TRUSTED 1
260  #define IP_UNTRUSTED 0
261  /*
262 -   check whether ip is trusted, return 1 for trusted , 0 for untrusted
263 -*/
264 + * check whether ip is trusted, return 1 for trusted , 0 for untrusted
265 + */
266  static int is_proxy_trusted(const char *ipstr, plugin_data *p)
267  {
268 -       data_string* allds = (data_string *) array_get_element(p->conf.forwarder,"all");
269 +       data_string* allds = (data_string *)array_get_element(p->conf.forwarder, "all");
270 +
271         if (allds) {
272 -               if (strcasecmp(allds->value->ptr,"trust") == 0)
273 +               if (strcasecmp(allds->value->ptr, "trust") == 0) {
274                         return IP_TRUSTED;
275 -               else
276 +               } else {
277                         return IP_UNTRUSTED;
278 +               }
279         }
280 -       return (data_string *)array_get_element(p->conf.forwarder,ipstr) ? IP_TRUSTED : IP_UNTRUSTED ;
281 +
282 +       return (data_string *)array_get_element(p->conf.forwarder, ipstr) ? IP_TRUSTED : IP_UNTRUSTED;
283  }
284  
285 +/*
286 + * Return char *ip of last address of proxy that is not trusted.
287 + * Do not accept "all" keyword here.
288 + */
289 +static const char *last_not_in_array(array *a, plugin_data *p)
290 +{
291 +       array *forwarder = p->conf.forwarder;
292 +
293 +       for (int i = a->used - 1; i >= 0; i--) {
294 +               data_string *ds = (data_string *)a->data[i];
295 +               const char *ip = ds->value->ptr;
296 +
297 +               if (!array_get_element(forwarder, ip)) {
298 +                       return ip;
299 +               }
300 +       }
301 +       return NULL;
302 +}
303 +
304  struct addrinfo *ipstr_to_sockaddr(const char *host)
305  {
306     struct addrinfo hints, *res0;
307 @@ -316,9 +340,8 @@
308         struct addrinfo *addrlist = NULL;
309  #endif
310         const char *dst_addr_str = NULL;
311 -       int i;
312         array *forward_array = NULL;
313 -       char *real_remote_addr = NULL;
314 +       const char *real_remote_addr = NULL;
315  #ifdef HAVE_IPV6
316  #endif
317  
318 @@ -342,7 +365,6 @@
319                 return HANDLER_GO_ON;
320         }
321  
322 -       /* if the remote ip itself is not trusted , then do nothing */
323  #ifdef HAVE_IPV6
324         dst_addr_str = inet_ntop(con->dst_addr.plain.sa_family,
325                       con->dst_addr.plain.sa_family == AF_INET6 ?
326 @@ -353,7 +375,9 @@
327  #else
328         dst_addr_str = inet_ntoa(con->dst_addr.ipv4.sin_addr);
329  #endif
330 -       if (IP_UNTRUSTED == is_proxy_trusted (dst_addr_str, p) ) {
331 +
332 +       /* if the remote ip itself is not trusted, then do nothing */
333 +       if (IP_UNTRUSTED == is_proxy_trusted(dst_addr_str, p)) {
334                 if (con->conf.log_request_handling) {
335                         log_error_write(srv, __FILE__, __LINE__, "s",
336                                         "remote address is NOT a trusted proxy, skipping");
337 @@ -362,40 +386,34 @@
338                 return HANDLER_GO_ON;
339         }
340  
341 +       /* build forward_array from forwarded data_string */
342         forward_array = extract_forward_array(forwarded->value);
343 +       real_remote_addr = last_not_in_array(forward_array, p);
344  
345 -       /* Testing shows that multiple headers and multiple values in one header
346 -          come in _reverse_ order. So the first one we get is the last one in the request. */
347 -       for (i = forward_array->used - 1; i >= 0; i--) {
348 -               data_string *ds = (data_string *) forward_array->data[i];
349 -               if (ds) {
350 -                       real_remote_addr = ds->value->ptr;
351 -                       break;
352 -               } else {
353 -                       /* bug ?  bailing out here */
354 -                       break;
355 -               }
356 -       }
357 -
358         if (real_remote_addr != NULL) { /* parsed */
359                 sock_addr sock;
360 -
361                 struct addrinfo *addrs_left;
362 +               server_socket *srv_sock = con->srv_socket;
363 +               data_string *forwarded_proto = (data_string *)array_get_element(con->request.headers, "X-Forwarded-Proto");
364  
365 +               if (forwarded_proto && !strcmp(forwarded_proto->value->ptr, "https")) {
366 +                       srv_sock->is_proxy_ssl = 1;
367 +               } else {
368 +                       srv_sock->is_proxy_ssl = 0;
369 +               }
370 +
371                 if (con->conf.log_request_handling) {
372 -                       log_error_write(srv, __FILE__, __LINE__, "ss",
373 -                                       "using address:", real_remote_addr);
374 +                       log_error_write(srv, __FILE__, __LINE__, "ss", "using address:", real_remote_addr);
375                 }
376  #ifdef HAVE_IPV6
377                 addrlist = ipstr_to_sockaddr(real_remote_addr);
378                 sock.plain.sa_family = AF_UNSPEC;
379 -               for (addrs_left = addrlist; addrs_left != NULL;
380 -                    addrs_left = addrs_left -> ai_next) {
381 +               for (addrs_left = addrlist; addrs_left != NULL; addrs_left = addrs_left -> ai_next) {
382                         sock.plain.sa_family = addrs_left->ai_family;
383 -                       if ( sock.plain.sa_family == AF_INET ) {
384 +                       if (sock.plain.sa_family == AF_INET) {
385                                 sock.ipv4.sin_addr = ((struct sockaddr_in*)addrs_left->ai_addr)->sin_addr;
386                                 break;
387 -                       } else if ( sock.plain.sa_family == AF_INET6 ) {
388 +                       } else if (sock.plain.sa_family == AF_INET6) {
389                                 sock.ipv6.sin6_addr = ((struct sockaddr_in6*)addrs_left->ai_addr)->sin6_addr;
390                                 break;
391                         }
392 @@ -430,7 +448,7 @@
393                 if (addrlist != NULL ) freeaddrinfo(addrlist);
394  #endif
395         }
396 -       array_free(forward_array);
397 +       array_free(forward_array);
398  
399         /* not found */
400         return HANDLER_GO_ON;
401 Index: src/Makefile.am
402 ===================================================================
403 --- src/Makefile.am     (.../tags/lighttpd-1.4.18)      (revision 2061)
404 +++ src/Makefile.am     (.../branches/lighttpd-1.4.x)   (revision 2061)
405 @@ -281,4 +281,4 @@
406  #ajp_SOURCES = ajp.c
407  
408  noinst_HEADERS   = $(hdr)
409 -EXTRA_DIST = mod_skeleton.c configparser.y mod_ssi_exprparser.y lempar.c
410 +EXTRA_DIST = mod_skeleton.c configparser.y mod_ssi_exprparser.y lempar.c SConscript
411 Index: src/configparser.y
412 ===================================================================
413 --- src/configparser.y  (.../tags/lighttpd-1.4.18)      (revision 2061)
414 +++ src/configparser.y  (.../branches/lighttpd-1.4.x)   (revision 2061)
415 @@ -422,6 +422,7 @@
416        { COMP_HTTP_COOKIE,        CONST_STR_LEN("HTTP[\"cookie\"]"     ) },
417        { COMP_HTTP_REMOTEIP,      CONST_STR_LEN("HTTP[\"remoteip\"]"   ) },
418        { COMP_HTTP_QUERYSTRING,   CONST_STR_LEN("HTTP[\"querystring\"]") },
419 +      { COMP_HTTP_SCHEME,        CONST_STR_LEN("HTTP[\"scheme\"]"     ) },
420        { COMP_UNSET, NULL, 0 },
421      };
422      size_t i;
423 Index: src/mod_status.c
424 ===================================================================
425 --- src/mod_status.c    (.../tags/lighttpd-1.4.18)      (revision 2061)
426 +++ src/mod_status.c    (.../branches/lighttpd-1.4.x)   (revision 2061)
427 @@ -560,6 +560,8 @@
428         double avg;
429         time_t ts;
430         char buf[32];
431 +       unsigned int k;
432 +       unsigned int l;
433  
434         b = chunkqueue_get_append_buffer(con->write_queue);
435  
436 @@ -588,6 +590,22 @@
437         buffer_append_long(b, srv->conns->used);
438         BUFFER_APPEND_STRING_CONST(b, "\n");
439  
440 +       BUFFER_APPEND_STRING_CONST(b, "IdleServers: ");
441 +       buffer_append_long(b, srv->conns->size - srv->conns->used);
442 +       BUFFER_APPEND_STRING_CONST(b, "\n");
443 +
444 +       /* output scoreboard */
445 +       BUFFER_APPEND_STRING_CONST(b, "Scoreboard: ");
446 +       for (k = 0; k < srv->conns->used; k++) {
447 +               connection *c = srv->conns->ptr[k];
448 +               const char *state = connection_get_short_state(c->state);
449 +               buffer_append_string_len(b, state, 1);
450 +       }
451 +       for (l = 0; l < srv->conns->size - srv->conns->used; l++) {
452 +               BUFFER_APPEND_STRING_CONST(b, "_");
453 +       }
454 +       BUFFER_APPEND_STRING_CONST(b, "\n");
455 +
456         /* set text/plain output */
457  
458         response_header_overwrite(srv, con, CONST_STR_LEN("Content-Type"), CONST_STR_LEN("text/plain"));
459 Index: src/mod_ssi.c
460 ===================================================================
461 --- src/mod_ssi.c       (.../tags/lighttpd-1.4.18)      (revision 2061)
462 +++ src/mod_ssi.c       (.../branches/lighttpd-1.4.x)   (revision 2061)
463 @@ -36,6 +36,11 @@
464  #include <sys/filio.h>
465  #endif
466  
467 +#include "etag.h"
468 +
469 +/* The newest modified time of included files for include statement */
470 +static volatile time_t include_file_last_mtime = 0;
471 +
472  /* init the plugin data */
473  INIT_FUNC(mod_ssi_init) {
474         plugin_data *p;
475 @@ -575,6 +580,11 @@
476                                 break;
477                         case SSI_INCLUDE:
478                                 chunkqueue_append_file(con->write_queue, p->stat_fn, 0, st.st_size);
479 +
480 +                               /* Keep the newest mtime of included files */
481 +                               if (st.st_mtime > include_file_last_mtime)
482 +                                 include_file_last_mtime = st.st_mtime;
483 +
484                                 break;
485                         }
486                 } else {
487 @@ -912,6 +922,9 @@
488         build_ssi_cgi_vars(srv, con, p);
489         p->if_is_false = 0;
490  
491 +       /* Reset the modified time of included files */
492 +       include_file_last_mtime = 0;
493 +
494         if (-1 == stream_open(&s, con->physical.path)) {
495                 log_error_write(srv, __FILE__, __LINE__, "sb",
496                                 "stream-open: ", con->physical.path);
497 @@ -1010,6 +1023,30 @@
498  
499         response_header_overwrite(srv, con, CONST_STR_LEN("Content-Type"), CONST_STR_LEN("text/html"));
500  
501 +       {
502 +       /* Generate "ETag" & "Last-Modified" headers */
503 +
504 +               stat_cache_entry *sce = NULL;
505 +               time_t lm_time = 0;
506 +               buffer *mtime = NULL;
507 +
508 +               stat_cache_get_entry(srv, con, con->physical.path, &sce);
509 +
510 +               etag_mutate(con->physical.etag, sce->etag);
511 +               response_header_overwrite(srv, con, CONST_STR_LEN("ETag"), CONST_BUF_LEN(con->physical.etag));
512 +
513 +               if (sce->st.st_mtime > include_file_last_mtime)
514 +                       lm_time = sce->st.st_mtime;
515 +               else
516 +                       lm_time = include_file_last_mtime;
517 +
518 +               mtime = strftime_cache_get(srv, lm_time);
519 +               response_header_overwrite(srv, con, CONST_STR_LEN("Last-Modified"), CONST_BUF_LEN(mtime));
520 +       }
521 +
522 +       /* Reset the modified time of included files */
523 +       include_file_last_mtime = 0;
524 +
525         /* reset physical.path */
526         buffer_reset(con->physical.path);
527  
528 Index: src/spawn-fcgi.c
529 ===================================================================
530 --- src/spawn-fcgi.c    (.../tags/lighttpd-1.4.18)      (revision 2061)
531 +++ src/spawn-fcgi.c    (.../branches/lighttpd-1.4.x)   (revision 2061)
532 @@ -37,7 +37,7 @@
533  #endif
534  
535  #ifdef HAVE_SYS_UN_H
536 -int fcgi_spawn_connection(char *appPath, char *addr, unsigned short port, const char *unixsocket, int child_count, int pid_fd, int nofork) {
537 +int fcgi_spawn_connection(char *appPath, char **appArgv, char *addr, unsigned short port, const char *unixsocket, int child_count, int pid_fd, int nofork) {
538         int fcgi_fd;
539         int socket_type, status;
540         struct timeval tv = { 0, 100 * 1000 };
541 @@ -137,11 +137,10 @@
542                 switch (child) {
543                 case 0: {
544                         char cgi_childs[64];
545 -                       char *b;
546  
547                         int i = 0;
548  
549 -                       /* is save as we limit to 256 childs */
550 +                       /* is safe as we limit to 256 childs */
551                         sprintf(cgi_childs, "PHP_FCGI_CHILDREN=%d", child_count);
552  
553                         if(fcgi_fd != FCGI_LISTENSOCK_FILENO) {
554 @@ -160,13 +159,18 @@
555                         putenv(cgi_childs);
556  
557                         /* fork and replace shell */
558 -                       b = malloc(strlen("exec ") + strlen(appPath) + 1);
559 -                       strcpy(b, "exec ");
560 -                       strcat(b, appPath);
561 +                       if (appArgv) {
562 +                               execv(appArgv[0], appArgv);
563  
564 -                       /* exec the cgi */
565 -                       execl("/bin/sh", "sh", "-c", b, (char *)NULL);
566 +                       } else {
567 +                               char *b = malloc(strlen("exec ") + strlen(appPath) + 1);
568 +                               strcpy(b, "exec ");
569 +                               strcat(b, appPath);
570  
571 +                               /* exec the cgi */
572 +                               execl("/bin/sh", "sh", "-c", b, (char *)NULL);
573 +                       }
574 +
575                         exit(errno);
576  
577                         break;
578 @@ -239,9 +243,12 @@
579  }
580  
581  void show_help () {
582 -       char *b = "spawn-fcgi" "-" PACKAGE_VERSION \
583 -" - spawns fastcgi processes\n" \
584 -"usage:\n" \
585 +       char *b = \
586 +"Usage: spawn-fcgi [options] -- <fcgiapp> [fcgi app arguments]\n" \
587 +"\n" \
588 +"spawn-fcgi v" PACKAGE_VERSION " - spawns fastcgi processes\n" \
589 +"\n" \
590 +"Options:\n" \
591  " -f <fcgiapp> filename of the fcgi-application\n" \
592  " -a <addr>    bind to ip address\n" \
593  " -p <port>    bind to tcp-port\n" \
594 @@ -264,6 +271,7 @@
595         char *fcgi_app = NULL, *changeroot = NULL, *username = NULL,
596                 *groupname = NULL, *unixsocket = NULL, *pid_file = NULL,
597                  *addr = NULL;
598 +       char **fcgi_app_argv = { NULL };
599         unsigned short port = 0;
600         int child_count = 5;
601         int i_am_root, o;
602 @@ -274,7 +282,7 @@
603  
604         i_am_root = (getuid() == 0);
605  
606 -       while(-1 != (o = getopt(argc, argv, "c:f:g:hna:p:u:vC:s:P:"))) {
607 +       while(-1 != (o = getopt(argc, argv, "c:f:g:hna:p:u:vC:s:P:"))) {
608                 switch(o) {
609                 case 'f': fcgi_app = optarg; break;
610                 case 'a': addr = optarg;/* ip addr */ break;
611 @@ -294,7 +302,11 @@
612                 }
613         }
614  
615 -       if (fcgi_app == NULL || (port == 0 && unixsocket == NULL)) {
616 +       if (optind < argc) {
617 +               fcgi_app_argv = &argv[optind];
618 +       }
619 +
620 +       if ((fcgi_app == NULL && fcgi_app_argv == NULL) || (port == 0 && unixsocket == NULL)) {
621                 show_help();
622                 return -1;
623         }
624 @@ -404,6 +416,18 @@
625                         }
626                 }
627  
628 +               /*
629 +                * Change group before chroot, when we have access
630 +                * to /etc/group
631 +                */
632 +               if (groupname) {
633 +                       setgid(grp->gr_gid);
634 +                       setgroups(0, NULL);
635 +                       if (username) {
636 +                               initgroups(username, grp->gr_gid);
637 +                       }
638 +               }
639 +
640                 if (changeroot) {
641                         if (-1 == chroot(changeroot)) {
642                                 fprintf(stderr, "%s.%d: %s %s\n",
643 @@ -420,18 +444,12 @@
644                 }
645  
646                 /* drop root privs */
647 -               if (groupname) {
648 -                       setgid(grp->gr_gid);
649 -               }
650                 if (username) {
651 -                       if (groupname) {
652 -                               initgroups(username, grp->gr_gid);
653 -                       }
654                         setuid(pwd->pw_uid);
655                 }
656         }
657  
658 -       return fcgi_spawn_connection(fcgi_app, addr, port, unixsocket, child_count, pid_fd, nofork);
659 +       return fcgi_spawn_connection(fcgi_app, fcgi_app_argv, addr, port, unixsocket, child_count, pid_fd, nofork);
660  }
661  #else
662  int main() {
663 Index: src/mod_auth.c
664 ===================================================================
665 --- src/mod_auth.c      (.../tags/lighttpd-1.4.18)      (revision 2061)
666 +++ src/mod_auth.c      (.../branches/lighttpd-1.4.x)   (revision 2061)
667 @@ -238,13 +238,13 @@
668                         int auth_type_len = auth_realm - http_authorization;
669  
670                         if ((auth_type_len == 5) &&
671 -                           (0 == strncmp(http_authorization, "Basic", auth_type_len))) {
672 +                           (0 == strncasecmp(http_authorization, "Basic", auth_type_len))) {
673  
674                                 if (0 == strcmp(method->value->ptr, "basic")) {
675                                         auth_satisfied = http_auth_basic_check(srv, con, p, req, con->uri.path, auth_realm+1);
676                                 }
677                         } else if ((auth_type_len == 6) &&
678 -                                  (0 == strncmp(http_authorization, "Digest", auth_type_len))) {
679 +                                  (0 == strncasecmp(http_authorization, "Digest", auth_type_len))) {
680                                 if (0 == strcmp(method->value->ptr, "digest")) {
681                                         if (-1 == (auth_satisfied = http_auth_digest_check(srv, con, p, req, con->uri.path, auth_realm+1))) {
682                                                 con->http_status = 400;
683 Index: src/mod_fastcgi.c
684 ===================================================================
685 --- src/mod_fastcgi.c   (.../tags/lighttpd-1.4.18)      (revision 2061)
686 +++ src/mod_fastcgi.c   (.../branches/lighttpd-1.4.x)   (revision 2061)
687 @@ -162,8 +162,8 @@
688          * if host is one of the local IP adresses the
689          * whole connection is local
690          *
691 -        * if tcp/ip should be used host AND port have
692 -        * to be specified
693 +        * if port is not 0, and host is not specified,
694 +        * "localhost" (INADDR_LOOPBACK) is assumed.
695          *
696          */
697         buffer *host;
698 @@ -823,12 +823,12 @@
699                 fcgi_addr_in.sin_family = AF_INET;
700  
701                 if (buffer_is_empty(host->host)) {
702 -                       fcgi_addr_in.sin_addr.s_addr = htonl(INADDR_ANY);
703 +                       fcgi_addr_in.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
704                 } else {
705                         struct hostent *he;
706  
707                         /* set a useful default */
708 -                       fcgi_addr_in.sin_addr.s_addr = htonl(INADDR_ANY);
709 +                       fcgi_addr_in.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
710  
711  
712                         if (NULL == (he = gethostbyname(host->host->ptr))) {
713 @@ -858,7 +858,11 @@
714                 fcgi_addr = (struct sockaddr *) &fcgi_addr_in;
715  
716                 buffer_copy_string(proc->connection_name, "tcp:");
717 -               buffer_append_string_buffer(proc->connection_name, host->host);
718 +               if (!buffer_is_empty(host->host)) {
719 +                       buffer_append_string_buffer(proc->connection_name, host->host);
720 +               } else {
721 +                       buffer_append_string(proc->connection_name, "localhost");
722 +               }
723                 buffer_append_string(proc->connection_name, ":");
724                 buffer_append_long(proc->connection_name, proc->port);
725         }
726 @@ -1687,12 +1691,16 @@
727  #endif
728         } else {
729                 fcgi_addr_in.sin_family = AF_INET;
730 -               if (0 == inet_aton(host->host->ptr, &(fcgi_addr_in.sin_addr))) {
731 -                       log_error_write(srv, __FILE__, __LINE__, "sbs",
732 -                                       "converting IP address failed for", host->host,
733 -                                       "\nBe sure to specify an IP address here");
734 -
735 -                       return -1;
736 +               if (!buffer_is_empty(host->host)) {
737 +                       if (0 == inet_aton(host->host->ptr, &(fcgi_addr_in.sin_addr))) {
738 +                               log_error_write(srv, __FILE__, __LINE__, "sbs",
739 +                                               "converting IP address failed for", host->host,
740 +                                               "\nBe sure to specify an IP address here");
741 +       
742 +                               return -1;
743 +                       }
744 +               } else {
745 +                       fcgi_addr_in.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
746                 }
747                 fcgi_addr_in.sin_port = htons(proc->port);
748                 servlen = sizeof(fcgi_addr_in);
749 @@ -1702,7 +1710,11 @@
750                 if (buffer_is_empty(proc->connection_name)) {
751                         /* on remote spawing we have to set the connection-name now */
752                         buffer_copy_string(proc->connection_name, "tcp:");
753 -                       buffer_append_string_buffer(proc->connection_name, host->host);
754 +                       if (!buffer_is_empty(host->host)) {
755 +                               buffer_append_string_buffer(proc->connection_name, host->host);
756 +                       } else {
757 +                               buffer_append_string(proc->connection_name, "localhost");
758 +                       }
759                         buffer_append_string(proc->connection_name, ":");
760                         buffer_append_long(proc->connection_name, proc->port);
761                 }
762 @@ -2045,13 +2057,10 @@
763         s = get_http_version_name(con->request.http_version);
764         FCGI_ENV_ADD_CHECK(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("SERVER_PROTOCOL"), s, strlen(s)),con)
765  
766 -#ifdef USE_OPENSSL
767 -       if (srv_sock->is_ssl) {
768 +    if (srv_sock->is_ssl || srv_sock->is_proxy_ssl) {
769                 FCGI_ENV_ADD_CHECK(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("HTTPS"), CONST_STR_LEN("on")),con)
770         }
771 -#endif
772  
773 -
774         FCGI_ENV_ADD_CHECK(fcgi_env_add_request_headers(srv, con, p), con);
775  
776         fcgi_header(&(header), FCGI_PARAMS, request_id, p->fcgi_env->used, 0);
777 @@ -2530,15 +2539,28 @@
778                                 }
779  
780                                 if (host->allow_xsendfile &&
781 -                                   NULL != (ds = (data_string *) array_get_element(con->response.headers, "X-LIGHTTPD-send-file"))) {
782 +                                   (NULL != (ds = (data_string *) array_get_element(con->response.headers, "X-LIGHTTPD-send-file"))
783 +                                         || NULL != (ds = (data_string *) array_get_element(con->response.headers, "X-Sendfile")))) {
784                                         stat_cache_entry *sce;
785  
786                                         if (HANDLER_ERROR != stat_cache_get_entry(srv, con, ds->value, &sce)) {
787 +                                               data_string *dcls = data_string_init();
788                                                 /* found */
789 -
790                                                 http_chunk_append_file(srv, con, ds->value, 0, sce->st.st_size);
791                                                 hctx->send_content_body = 0; /* ignore the content */
792                                                 joblist_append(srv, con);
793 +
794 +                                               buffer_copy_string_len(dcls->key, "Content-Length", sizeof("Content-Length")-1);
795 +                                               buffer_copy_long(dcls->value, sce->st.st_size);
796 +                                               dcls = (data_string*) array_replace(con->response.headers, (data_unset *)dcls);
797 +                                               if (dcls) dcls->free((data_unset*)dcls);
798 +
799 +                                               con->parsed_response |= HTTP_CONTENT_LENGTH;
800 +                                               con->response.content_length = sce->st.st_size;
801 +                                       } else {
802 +                                               log_error_write(srv, __FILE__, __LINE__, "sb",
803 +                                                       "send-file error: couldn't get stat_cache entry for:",
804 +                                                       ds->value);
805                                         }
806                                 }
807  
808 @@ -2719,9 +2741,14 @@
809  
810         int ret;
811  
812 -       /* sanity check */
813 +       /* sanity check:
814 +        *  - host != NULL
815 +        *  - either:
816 +        *     - tcp socket (do not check host->host->uses, as it may be not set which means INADDR_LOOPBACK)
817 +        *     - unix socket
818 +        */
819         if (!host ||
820 -           ((!host->host->used || !host->port) && !host->unixsocket->used)) {
821 +           (!host->port && !host->unixsocket->used)) {
822                 log_error_write(srv, __FILE__, __LINE__, "sxddd",
823                                 "write-req: error",
824                                 host,
825 @@ -3456,8 +3483,9 @@
826                         if (s_len < ct_len) continue;
827  
828                         /* check extension in the form "/fcgi_pattern" */
829 -                       if (*(extension->key->ptr) == '/' && strncmp(fn->ptr, extension->key->ptr, ct_len) == 0) {
830 -                               break;
831 +                       if (*(extension->key->ptr) == '/') {
832 +                               if (strncmp(fn->ptr, extension->key->ptr, ct_len) == 0)
833 +                                       break;
834                         } else if (0 == strncmp(fn->ptr + s_len - ct_len, extension->key->ptr, ct_len)) {
835                                 /* check extension in the form ".fcg" */
836                                 break;
837 @@ -3473,7 +3501,7 @@
838         for (k = 0; k < extension->used; k++) {
839                 host = extension->hosts[k];
840  
841 -               /* we should have at least one proc that can do somthing */
842 +               /* we should have at least one proc that can do something */
843                 if (host->active_procs == 0) {
844                         host = NULL;
845  
846 Index: src/server.c
847 ===================================================================
848 --- src/server.c        (.../tags/lighttpd-1.4.18)      (revision 2061)
849 +++ src/server.c        (.../branches/lighttpd-1.4.x)   (revision 2061)
850 @@ -759,6 +759,19 @@
851  
852                         return -1;
853                 }
854 +#ifdef HAVE_PWD_H
855 +               /* 
856 +                * Change group before chroot, when we have access
857 +                * to /etc/group
858 +                * */
859 +               if (srv->srvconf.groupname->used) {
860 +                       setgid(grp->gr_gid);
861 +                       setgroups(0, NULL);
862 +                       if (srv->srvconf.username->used) {
863 +                               initgroups(srv->srvconf.username->ptr, grp->gr_gid);
864 +                       }
865 +               }
866 +#endif
867  #ifdef HAVE_CHROOT
868                 if (srv->srvconf.changeroot->used) {
869                         tzset();
870 @@ -775,15 +788,7 @@
871  #endif
872  #ifdef HAVE_PWD_H
873                 /* drop root privs */
874 -               if (srv->srvconf.groupname->used) {
875 -                       setgid(grp->gr_gid);
876 -                       setgroups(0, NULL);
877 -               }
878 -
879                 if (srv->srvconf.username->used) {
880 -                       if (srv->srvconf.groupname->used) {
881 -                               initgroups(srv->srvconf.username->ptr, grp->gr_gid);
882 -                       }
883                         setuid(pwd->pw_uid);
884                 }
885  #endif
886 @@ -891,6 +896,17 @@
887                 pid_fd = -1;
888         }
889  
890 +       // Close stderr ASAP in the child process to make sure that nothing
891 +       // is being written to that fd which may not be valid anymore.
892 +       if (-1 == log_error_open(srv)) {
893 +               log_error_write(srv, __FILE__, __LINE__, "s", "Opening errorlog failed. Going down.");
894 +
895 +               plugins_free(srv);
896 +               network_close(srv);
897 +               server_free(srv);
898 +               return -1;
899 +       }
900 +
901         if (HANDLER_GO_ON != plugins_call_set_defaults(srv)) {
902                 log_error_write(srv, __FILE__, __LINE__, "s", "Configuration of plugins failed. Going down.");
903  
904 @@ -941,15 +957,7 @@
905                 return -1;
906         }
907  
908 -       if (-1 == log_error_open(srv)) {
909 -               log_error_write(srv, __FILE__, __LINE__, "s",
910 -                               "opening errorlog failed, dying");
911  
912 -               plugins_free(srv);
913 -               network_close(srv);
914 -               server_free(srv);
915 -               return -1;
916 -       }
917  
918  
919  #ifdef HAVE_SIGACTION
920 Index: tests/mod-access.t
921 ===================================================================
922 --- tests/mod-access.t  (.../tags/lighttpd-1.4.18)      (revision 2061)
923 +++ tests/mod-access.t  (.../branches/lighttpd-1.4.x)   (revision 2061)
924 @@ -1,9 +1,9 @@
925  #!/usr/bin/env perl
926  BEGIN {
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;
931 +       # add current source dir to the include-path
932 +       # we need this for make distcheck
933 +       (my $srcdir = $0) =~ s,/[^/]+$,/,;
934 +       unshift @INC, $srcdir;
935  }
936  
937  use strict;
938 Index: tests/mod-auth.t
939 ===================================================================
940 --- tests/mod-auth.t    (.../tags/lighttpd-1.4.18)      (revision 2061)
941 +++ tests/mod-auth.t    (.../branches/lighttpd-1.4.x)   (revision 2061)
942 @@ -1,14 +1,14 @@
943  #!/usr/bin/env perl
944  BEGIN {
945 -    # add current source dir to the include-path
946 -    # we need this for make distcheck
947 -   (my $srcdir = $0) =~ s#/[^/]+$#/#;
948 -   unshift @INC, $srcdir;
949 +       # add current source dir to the include-path
950 +       # we need this for make distcheck
951 +       (my $srcdir = $0) =~ s,/[^/]+$,/,;
952 +       unshift @INC, $srcdir;
953  }
954  
955  use strict;
956  use IO::Socket;
957 -use Test::More tests => 13;
958 +use Test::More tests => 14;
959  use LightyTest;
960  
961  my $tf = LightyTest->new();
962 @@ -48,6 +48,16 @@
963  $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
964  ok($tf->handle_http($t) == 0, 'Basic-Auth: Valid Auth-token - htpasswd (des)');
965  
966 +$t->{REQUEST}  = ( <<EOF
967 +GET /server-config HTTP/1.0
968 +Host: auth-htpasswd.example.org
969 +Authorization: basic ZGVzOmRlcw==
970 +EOF
971 + );
972 +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
973 +ok($tf->handle_http($t) == 0, 'Basic-Auth: Valid Auth-token - htpasswd (des) (lowercase)');
974 +
975 +
976  SKIP: {
977         skip "no md5 for crypt under cygwin", 1 if $^O eq 'cygwin';
978  $t->{REQUEST}  = ( <<EOF
979 Index: tests/mod-secdownload.t
980 ===================================================================
981 Index: tests/core-response.t
982 ===================================================================
983 --- tests/core-response.t       (.../tags/lighttpd-1.4.18)      (revision 2061)
984 +++ tests/core-response.t       (.../branches/lighttpd-1.4.x)   (revision 2061)
985 @@ -1,10 +1,9 @@
986  #!/usr/bin/env perl
987 -
988  BEGIN {
989 -    # add current source dir to the include-path
990 -    # we need this for make distcheck
991 -   (my $srcdir = $0) =~ s#/[^/]+$#/#;
992 -   unshift @INC, $srcdir;
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  }
998  
999  use strict;
1000 Index: tests/mod-extforward.conf
1001 ===================================================================
1002 --- tests/mod-extforward.conf   (.../tags/lighttpd-1.4.18)      (revision 0)
1003 +++ tests/mod-extforward.conf   (.../branches/lighttpd-1.4.x)   (revision 2061)
1004 @@ -0,0 +1,31 @@
1005 +debug.log-request-handling   = "enable"
1006 +debug.log-response-header   = "disable"
1007 +debug.log-request-header   = "disable"
1008 +
1009 +server.document-root         = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/"
1010 +server.pid-file              = env.SRCDIR + "/tmp/lighttpd/lighttpd.pid"
1011 +
1012 +## bind to port (default: 80)
1013 +server.port                 = 2048
1014 +
1015 +## bind to localhost (default: all interfaces)
1016 +server.bind                = "localhost"
1017 +server.errorlog            = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log"
1018 +server.name                = "www.example.org"
1019 +server.tag                 = "Apache 1.3.29"
1020 +
1021 +server.modules = (
1022 +       "mod_cgi",
1023 +       "mod_extforward"
1024 +)
1025 +
1026 +######################## MODULE CONFIG ############################
1027 +
1028 +mimetype.assign             = ( ".html" => "text/html" )
1029 +
1030 +cgi.assign = (".pl" => "/usr/bin/perl" )
1031 +
1032 +extforward.forwarder = (
1033 +       "127.0.0.1" => "trust",
1034 +       "127.0.30.1" => "trust",
1035 +)
1036 Index: tests/symlink.t
1037 ===================================================================
1038 Index: tests/request.t
1039 ===================================================================
1040 --- tests/request.t     (.../tags/lighttpd-1.4.18)      (revision 2061)
1041 +++ tests/request.t     (.../branches/lighttpd-1.4.x)   (revision 2061)
1042 @@ -1,9 +1,9 @@
1043  #!/usr/bin/env perl
1044  BEGIN {
1045 -    # add current source dir to the include-path
1046 -    # we need this for make distcheck
1047 -   (my $srcdir = $0) =~ s#/[^/]+$#/#;
1048 -   unshift @INC, $srcdir;
1049 +       # add current source dir to the include-path
1050 +       # we need this for make distcheck
1051 +       (my $srcdir = $0) =~ s,/[^/]+$,/,;
1052 +       unshift @INC, $srcdir;
1053  }
1054  
1055  use strict;
1056 Index: tests/mod-userdir.t
1057 ===================================================================
1058 --- tests/mod-userdir.t (.../tags/lighttpd-1.4.18)      (revision 2061)
1059 +++ tests/mod-userdir.t (.../branches/lighttpd-1.4.x)   (revision 2061)
1060 @@ -1,9 +1,9 @@
1061  #!/usr/bin/env perl
1062  BEGIN {
1063 -    # add current source dir to the include-path
1064 -    # we need this for make distcheck
1065 -   (my $srcdir = $0) =~ s#/[^/]+$#/#;
1066 -   unshift @INC, $srcdir;
1067 +       # add current source dir to the include-path
1068 +       # we need this for make distcheck
1069 +       (my $srcdir = $0) =~ s,/[^/]+$,/,;
1070 +       unshift @INC, $srcdir;
1071  }
1072  
1073  use strict;
1074 Index: tests/core-keepalive.t
1075 ===================================================================
1076 --- tests/core-keepalive.t      (.../tags/lighttpd-1.4.18)      (revision 2061)
1077 +++ tests/core-keepalive.t      (.../branches/lighttpd-1.4.x)   (revision 2061)
1078 @@ -1,10 +1,9 @@
1079  #!/usr/bin/env perl
1080 -
1081  BEGIN {
1082 -    # add current source dir to the include-path
1083 -    # we need this for make distcheck
1084 -   (my $srcdir = $0) =~ s#/[^/]+$#/#;
1085 -   unshift @INC, $srcdir;
1086 +       # add current source dir to the include-path
1087 +       # we need this for make distcheck
1088 +       (my $srcdir = $0) =~ s,/[^/]+$,/,;
1089 +       unshift @INC, $srcdir;
1090  }
1091  
1092  use strict;
1093 Index: tests/mod-proxy.t
1094 ===================================================================
1095 Index: tests/env-variables.t
1096 ===================================================================
1097 Index: tests/core-var-include.t
1098 ===================================================================
1099 --- tests/core-var-include.t    (.../tags/lighttpd-1.4.18)      (revision 2061)
1100 +++ tests/core-var-include.t    (.../branches/lighttpd-1.4.x)   (revision 2061)
1101 @@ -1,9 +1,9 @@
1102  #!/usr/bin/env perl
1103  BEGIN {
1104 -    # add current source dir to the include-path
1105 -    # we need this for make distcheck
1106 -   (my $srcdir = $0) =~ s#/[^/]+$#/#;
1107 -   unshift @INC, $srcdir;
1108 +       # add current source dir to the include-path
1109 +       # we need this for make distcheck
1110 +       (my $srcdir = $0) =~ s,/[^/]+$,/,;
1111 +       unshift @INC, $srcdir;
1112  }
1113  
1114  use strict;
1115 Index: tests/mod-extforward.t
1116 ===================================================================
1117 --- tests/mod-extforward.t      (.../tags/lighttpd-1.4.18)      (revision 0)
1118 +++ tests/mod-extforward.t      (.../branches/lighttpd-1.4.x)   (revision 2061)
1119 @@ -0,0 +1,48 @@
1120 +#!/usr/bin/env perl
1121 +BEGIN {
1122 +       # add current source dir to the include-path
1123 +       # we need this for make distcheck
1124 +       (my $srcdir = $0) =~ s,/[^/]+$,/,;
1125 +       unshift @INC, $srcdir;
1126 +}
1127 +
1128 +use strict;
1129 +use IO::Socket;
1130 +use Test::More tests => 5;
1131 +use LightyTest;
1132 +
1133 +my $tf = LightyTest->new();
1134 +my $t;
1135 +
1136 +$tf->{CONFIGFILE} = 'mod-extforward.conf';
1137 +
1138 +ok($tf->start_proc == 0, "Starting lighttpd") or die();
1139 +
1140 +$t->{REQUEST} = ( <<EOF
1141 +GET /ip.pl HTTP/1.0
1142 +Host: www.example.org
1143 +X-Forwarded-For: 127.0.10.1
1144 +EOF
1145 +);
1146 +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '127.0.10.1' } ];
1147 +ok($tf->handle_http($t) == 0, 'expect 127.0.10.1, from single ip');
1148 +
1149 +$t->{REQUEST} = ( <<EOF
1150 +GET /ip.pl HTTP/1.0
1151 +Host: www.example.org
1152 +X-Forwarded-For: 127.0.10.1, 127.0.20.1
1153 +EOF
1154 +);
1155 +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '127.0.20.1' } ];
1156 +ok($tf->handle_http($t) == 0, 'expect 127.0.20.1, from two ips');
1157 +
1158 +$t->{REQUEST} = ( <<EOF
1159 +GET /ip.pl HTTP/1.0
1160 +Host: www.example.org
1161 +X-Forwarded-For: 127.0.10.1, 127.0.20.1, 127.0.30.1
1162 +EOF
1163 +);
1164 +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '127.0.20.1' } ];
1165 +ok($tf->handle_http($t) == 0, 'expect 127.0.20.1, from chained proxies');
1166 +
1167 +ok($tf->stop_proc == 0, "Stopping lighttpd");
1168
1169 Property changes on: tests/mod-extforward.t
1170 ___________________________________________________________________
1171 Name: svn:executable
1172    + *
1173
1174 Index: tests/core-request.t
1175 ===================================================================
1176 --- tests/core-request.t        (.../tags/lighttpd-1.4.18)      (revision 2061)
1177 +++ tests/core-request.t        (.../branches/lighttpd-1.4.x)   (revision 2061)
1178 @@ -1,9 +1,9 @@
1179  #!/usr/bin/env perl
1180  BEGIN {
1181 -    # add current source dir to the include-path
1182 -    # we need this for make distcheck
1183 -   (my $srcdir = $0) =~ s#/[^/]+$#/#;
1184 -   unshift @INC, $srcdir;
1185 +       # add current source dir to the include-path
1186 +       # we need this for make distcheck
1187 +       (my $srcdir = $0) =~ s,/[^/]+$,/,;
1188 +       unshift @INC, $srcdir;
1189  }
1190  
1191  use strict;
1192 Index: tests/mod-redirect.t
1193 ===================================================================
1194 --- tests/mod-redirect.t        (.../tags/lighttpd-1.4.18)      (revision 2061)
1195 +++ tests/mod-redirect.t        (.../branches/lighttpd-1.4.x)   (revision 2061)
1196 @@ -1,9 +1,9 @@
1197  #!/usr/bin/env perl
1198  BEGIN {
1199 -    # add current source dir to the include-path
1200 -    # we need this for make distcheck
1201 -   (my $srcdir = $0) =~ s#/[^/]+$#/#;
1202 -   unshift @INC, $srcdir;
1203 +       # add current source dir to the include-path
1204 +       # we need this for make distcheck
1205 +       (my $srcdir = $0) =~ s,/[^/]+$,/,;
1206 +       unshift @INC, $srcdir;
1207  }
1208  
1209  use strict;
1210 Index: tests/mod-cgi.t
1211 ===================================================================
1212 --- tests/mod-cgi.t     (.../tags/lighttpd-1.4.18)      (revision 2061)
1213 +++ tests/mod-cgi.t     (.../branches/lighttpd-1.4.x)   (revision 2061)
1214 @@ -1,9 +1,9 @@
1215  #!/usr/bin/env perl
1216  BEGIN {
1217 -    # add current source dir to the include-path
1218 -    # we need this for make distcheck
1219 -   (my $srcdir = $0) =~ s#/[^/]+$#/#;
1220 -   unshift @INC, $srcdir;
1221 +       # add current source dir to the include-path
1222 +       # we need this for make distcheck
1223 +       (my $srcdir = $0) =~ s,/[^/]+$,/,;
1224 +       unshift @INC, $srcdir;
1225  }
1226  
1227  use strict;
1228 Index: tests/mod-setenv.t
1229 ===================================================================
1230 --- tests/mod-setenv.t  (.../tags/lighttpd-1.4.18)      (revision 2061)
1231 +++ tests/mod-setenv.t  (.../branches/lighttpd-1.4.x)   (revision 2061)
1232 @@ -1,10 +1,9 @@
1233  #!/usr/bin/env perl
1234 -
1235  BEGIN {
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;
1240 +       # add current source dir to the include-path
1241 +       # we need this for make distcheck
1242 +       (my $srcdir = $0) =~ s,/[^/]+$,/,;
1243 +       unshift @INC, $srcdir;
1244  }
1245  
1246  use strict;
1247 Index: tests/cachable.t
1248 ===================================================================
1249 --- tests/cachable.t    (.../tags/lighttpd-1.4.18)      (revision 2061)
1250 +++ tests/cachable.t    (.../branches/lighttpd-1.4.x)   (revision 2061)
1251 @@ -1,9 +1,9 @@
1252  #!/usr/bin/env perl
1253  BEGIN {
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;
1258 +       # add current source dir to the include-path
1259 +       # we need this for make distcheck
1260 +       (my $srcdir = $0) =~ s,/[^/]+$,/,;
1261 +       unshift @INC, $srcdir;
1262  }
1263  
1264  use strict;
1265 Index: tests/lowercase.t
1266 ===================================================================
1267 --- tests/lowercase.t   (.../tags/lighttpd-1.4.18)      (revision 2061)
1268 +++ tests/lowercase.t   (.../branches/lighttpd-1.4.x)   (revision 2061)
1269 @@ -1,9 +1,9 @@
1270  #!/usr/bin/env perl
1271  BEGIN {
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;
1276 +       # add current source dir to the include-path
1277 +       # we need this for make distcheck
1278 +       (my $srcdir = $0) =~ s,/[^/]+$,/,;
1279 +       unshift @INC, $srcdir;
1280  }
1281  
1282  use strict;
1283 Index: tests/core.t
1284 ===================================================================
1285 --- tests/core.t        (.../tags/lighttpd-1.4.18)      (revision 2061)
1286 +++ tests/core.t        (.../branches/lighttpd-1.4.x)   (revision 2061)
1287 @@ -1,10 +1,9 @@
1288  #!/usr/bin/env perl
1289 -
1290  BEGIN {
1291 -    # add current source dir to the include-path
1292 -    # we need this for make distcheck
1293 -   (my $srcdir = $0) =~ s#/[^/]+$#/#;
1294 -   unshift @INC, $srcdir;
1295 +       # add current source dir to the include-path
1296 +       # we need this for make distcheck
1297 +       (my $srcdir = $0) =~ s,/[^/]+$,/,;
1298 +       unshift @INC, $srcdir;
1299  }
1300  
1301  use strict;
1302 Index: tests/mod-fastcgi.t
1303 ===================================================================
1304 --- tests/mod-fastcgi.t (.../tags/lighttpd-1.4.18)      (revision 2061)
1305 +++ tests/mod-fastcgi.t (.../branches/lighttpd-1.4.x)   (revision 2061)
1306 @@ -1,9 +1,9 @@
1307  #!/usr/bin/env perl
1308  BEGIN {
1309 -    # add current source dir to the include-path
1310 -    # we need this for make distcheck
1311 -   (my $srcdir = $0) =~ s#/[^/]+$#/#;
1312 -   unshift @INC, $srcdir;
1313 +       # add current source dir to the include-path
1314 +       # we need this for make distcheck
1315 +       (my $srcdir = $0) =~ s,/[^/]+$,/,;
1316 +       unshift @INC, $srcdir;
1317  }
1318  
1319  use strict;
1320 Index: tests/mod-rewrite.t
1321 ===================================================================
1322 --- tests/mod-rewrite.t (.../tags/lighttpd-1.4.18)      (revision 2061)
1323 +++ tests/mod-rewrite.t (.../branches/lighttpd-1.4.x)   (revision 2061)
1324 @@ -1,9 +1,9 @@
1325  #!/usr/bin/env perl
1326  BEGIN {
1327 -    # add current source dir to the include-path
1328 -    # we need this for make distcheck
1329 -   (my $srcdir = $0) =~ s#/[^/]+$#/#;
1330 -   unshift @INC, $srcdir;
1331 +       # add current source dir to the include-path
1332 +       # we need this for make distcheck
1333 +       (my $srcdir = $0) =~ s,/[^/]+$,/,;
1334 +       unshift @INC, $srcdir;
1335  }
1336  
1337  use strict;
1338 Index: tests/docroot/www/ip.pl
1339 ===================================================================
1340 --- tests/docroot/www/ip.pl     (.../tags/lighttpd-1.4.18)      (revision 0)
1341 +++ tests/docroot/www/ip.pl     (.../branches/lighttpd-1.4.x)   (revision 2061)
1342 @@ -0,0 +1,13 @@
1343 +#!/usr/bin/perl
1344 +print "Content-Type: text/html\r\n\r\n";
1345 +print $ENV{'REMOTE_ADDR'};
1346 +
1347 +if ($ENV{'QUERY_STRING'} eq 'info') {
1348 +       print "\nF:",$ENV{'HTTP_X_FORWARDED_FOR'},"\n";
1349 +
1350 +       while (my($key, $value) = each %ENV) {
1351 +               printf "%s => %s\n", $key, $value;
1352 +       }
1353 +}
1354 +
1355 +0;
1356
1357 Property changes on: tests/docroot/www/ip.pl
1358 ___________________________________________________________________
1359 Name: svn:executable
1360    + *
1361
1362 Index: tests/Makefile.am
1363 ===================================================================
1364 --- tests/Makefile.am   (.../tags/lighttpd-1.4.18)      (revision 2061)
1365 +++ tests/Makefile.am   (.../branches/lighttpd-1.4.x)   (revision 2061)
1366 @@ -31,14 +31,20 @@
1367        core-response.t \
1368        core-keepalive.t \
1369        core.t \
1370 +         mod-proxy.t \
1371 +         proxy.conf \
1372 +         mod-secdownload.t \
1373        mod-access.t \
1374        mod-auth.t \
1375        mod-cgi.t \
1376        mod-compress.t \
1377        mod-fastcgi.t \
1378        mod-redirect.t \
1379 +      mod-rewrite.t \
1380        mod-userdir.t \
1381 -      mod-rewrite.t \
1382 +         env-variables.t \
1383 +         env-variables.conf \
1384 +         symlink.t \
1385        request.t \
1386        mod-ssi.t \
1387        LightyTest.pm \
1388 @@ -49,12 +55,12 @@
1389        core-404-handler.t \
1390        404-handler.conf
1391  
1392 -
1393  TESTS_ENVIRONMENT=$(srcdir)/wrapper.sh $(srcdir) $(top_builddir)
1394  
1395  EXTRA_DIST=wrapper.sh lighttpd.conf \
1396         lighttpd.user \
1397         lighttpd.htpasswd \
1398 +       SConscript \
1399         $(CONFS) \
1400         $(TESTS)
1401  
1402 Index: tests/core-404-handler.t
1403 ===================================================================
1404 --- tests/core-404-handler.t    (.../tags/lighttpd-1.4.18)      (revision 2061)
1405 +++ tests/core-404-handler.t    (.../branches/lighttpd-1.4.x)   (revision 2061)
1406 @@ -10,10 +10,10 @@
1407  #   returning no status -> 200
1408  #
1409  BEGIN {
1410 -    # add current source dir to the include-path
1411 -    # we need this for make distcheck
1412 -   (my $srcdir = $0) =~ s#/[^/]+$#/#;
1413 -   unshift @INC, $srcdir;
1414 +       # add current source dir to the include-path
1415 +       # we need this for make distcheck
1416 +       (my $srcdir = $0) =~ s,/[^/]+$,/,;
1417 +       unshift @INC, $srcdir;
1418  }
1419  
1420  use strict;
1421 Index: tests/mod-compress.t
1422 ===================================================================
1423 --- tests/mod-compress.t        (.../tags/lighttpd-1.4.18)      (revision 2061)
1424 +++ tests/mod-compress.t        (.../branches/lighttpd-1.4.x)   (revision 2061)
1425 @@ -1,9 +1,9 @@
1426  #!/usr/bin/env perl
1427  BEGIN {
1428 -    # add current source dir to the include-path
1429 -    # we need this for make distcheck
1430 -   (my $srcdir = $0) =~ s#/[^/]+$#/#;
1431 -   unshift @INC, $srcdir;
1432 +       # add current source dir to the include-path
1433 +       # we need this for make distcheck
1434 +       (my $srcdir = $0) =~ s,/[^/]+$,/,;
1435 +       unshift @INC, $srcdir;
1436  }
1437  
1438  use strict;
1439 Index: tests/mod-ssi.t
1440 ===================================================================
1441 --- tests/mod-ssi.t     (.../tags/lighttpd-1.4.18)      (revision 2061)
1442 +++ tests/mod-ssi.t     (.../branches/lighttpd-1.4.x)   (revision 2061)
1443 @@ -1,9 +1,9 @@
1444  #!/usr/bin/env perl
1445  BEGIN {
1446 -    # add current source dir to the include-path
1447 -    # we need this for make distcheck
1448 -   (my $srcdir = $0) =~ s#/[^/]+$#/#;
1449 -   unshift @INC, $srcdir;
1450 +       # add current source dir to the include-path
1451 +       # we need this for make distcheck
1452 +       (my $srcdir = $0) =~ s,/[^/]+$,/,;
1453 +       unshift @INC, $srcdir;
1454  }
1455  
1456  use strict;
1457 Index: tests/core-condition.t
1458 ===================================================================
1459 --- tests/core-condition.t      (.../tags/lighttpd-1.4.18)      (revision 2061)
1460 +++ tests/core-condition.t      (.../branches/lighttpd-1.4.x)   (revision 2061)
1461 @@ -1,9 +1,9 @@
1462  #!/usr/bin/env perl
1463  BEGIN {
1464 -    # add current source dir to the include-path
1465 -    # we need this for make distcheck
1466 -   (my $srcdir = $0) =~ s#/[^/]+$#/#;
1467 -   unshift @INC, $srcdir;
1468 +       # add current source dir to the include-path
1469 +       # we need this for make distcheck
1470 +       (my $srcdir = $0) =~ s,/[^/]+$,/,;
1471 +       unshift @INC, $srcdir;
1472  }
1473  
1474  use strict;
1475 Index: doc/configuration.txt
1476 ===================================================================
1477 --- doc/configuration.txt       (.../tags/lighttpd-1.4.18)      (revision 2061)
1478 +++ doc/configuration.txt       (.../branches/lighttpd-1.4.x)   (revision 2061)
1479 @@ -85,6 +85,8 @@
1480  
1481  $HTTP["cookie"]
1482    match on cookie
1483 +$HTTP["scheme"]
1484 +  match on scheme
1485  $HTTP["host"]
1486    match on host
1487  $HTTP["useragent"]
1488 Index: doc/lighttpd.conf
1489 ===================================================================
1490 --- doc/lighttpd.conf   (.../tags/lighttpd-1.4.18)      (revision 2061)
1491 +++ doc/lighttpd.conf   (.../branches/lighttpd-1.4.x)   (revision 2061)
1492 @@ -72,6 +72,7 @@
1493    ".ogg"          =>      "application/ogg",
1494    ".wav"          =>      "audio/x-wav",
1495    ".gif"          =>      "image/gif",
1496 +  ".jar"          =>      "application/x-java-archive",
1497    ".jpg"          =>      "image/jpeg",
1498    ".jpeg"         =>      "image/jpeg",
1499    ".png"          =>      "image/png",
1500 Index: SConstruct
1501 ===================================================================
1502 Index: Makefile.am
1503 ===================================================================
1504 --- Makefile.am (.../tags/lighttpd-1.4.18)      (revision 2061)
1505 +++ Makefile.am (.../branches/lighttpd-1.4.x)   (revision 2061)
1506 @@ -1,3 +1,3 @@
1507  SUBDIRS=src doc tests cygwin openwrt
1508  
1509 -EXTRA_DIST=lighttpd.spec
1510 +EXTRA_DIST=lighttpd.spec autogen.sh SConstruct
1511 Index: NEWS
1512 ===================================================================
1513 --- NEWS        (.../tags/lighttpd-1.4.18)      (revision 2061)
1514 +++ NEWS        (.../branches/lighttpd-1.4.x)   (revision 2061)
1515 @@ -3,6 +3,25 @@
1516  NEWS
1517  ====
1518  
1519 +- 1.4.19 -
1520 +
1521 +  * added support for If-Range: <date> (#1346)
1522 +  * added support for matching $HTTP["scheme"] in configs
1523 +  * fixed initgroups() called after chroot (#1384)
1524 +  * fixed case-sensitive check for Auth-Method (#1456)
1525 +  * execute fcgi app without /bin/sh if used as argument to spawn-fcgi (#1428)
1526 +  * fixed a bug that made /-prefixed extensions being handled also when
1527 +    matching the end of the uri in fcgi,scgi and proxy modules (#1489)
1528 +  * print error if X-LIGHTTPD-send-file cannot be done; reset header
1529 +    Content-Length for send-file. Patches by Stefan Buhler
1530 +  * prevent crash in certain php-fcgi configurations (#841)
1531 +  * add IdleServers and Scoreboard directives in ?auto mode for mod_status (#1507)
1532 +  * open log immediately after daemonizing, fixes SIGPIPEs on startup  (#165)
1533 +  * HTTPS env var should be "on" when using mod_extforward and the X-Forwarded-Proto header is set. (#1499)
1534 +  * generate ETag and Last-Modified headers for mod_ssi based on newest modified include (#1491)
1535 +  * support letterhomes in mod_userdir (#1473)
1536 +  * support chained proxies in mod_extforward (#1528)
1537 +
1538  - 1.4.18 - 2007-09-09
1539  
1540    * fixed compile error on IRIX 6.5.x on prctl() (#1333)
1541 Index: lighttpd.spec.in
1542 ===================================================================
1543 --- lighttpd.spec.in    (.../tags/lighttpd-1.4.18)      (revision 2061)
1544 +++ lighttpd.spec.in    (.../branches/lighttpd-1.4.x)   (revision 2061)
1545 @@ -6,21 +6,19 @@
1546  Packager: Jan Kneschke <jan@kneschke.de>
1547  License: BSD
1548  Group: Networking/Daemons
1549 -URL: http://jan.kneschke.de/projects/lighttpd/
1550 +URL: http://www.lighttpd.net/
1551  Requires: pcre >= 3.1 zlib
1552 -BuildPrereq: libtool zlib-devel
1553 +BuildRequires: libtool zlib-devel
1554  BuildRoot: %{_tmppath}/%{name}-root
1555  
1556 -
1557  %description
1558  lighttpd is intented to be a frontend for ad-servers which have to deliver
1559  small files concurrently to many connections.
1560  
1561 -Available rpmbuild rebuild options :
1562 ---with : ssl mysql lua memcache
1563 +Available rpmbuild rebuild options:
1564 +--with: ssl mysql lua memcache
1565  
1566  %prep
1567 -
1568  %setup -q
1569  
1570  %build
1571 @@ -33,14 +31,13 @@
1572  make
1573  
1574  %install
1575 -
1576  %makeinstall
1577  
1578  mkdir -p %{buildroot}%{_sysconfdir}/{init.d,sysconfig}
1579 -if test -f /etc/redhat-release -o -f /etc/fedora-release; then
1580 -  install -m 755 doc/rc.lighttpd.redhat %{buildroot}%{_sysconfdir}/init.d/lighttpd
1581 +if [ -f /etc/redhat-release -o -f /etc/fedora-release ]; then
1582 +       install -m 755 doc/rc.lighttpd.redhat %{buildroot}%{_sysconfdir}/init.d/lighttpd
1583  else
1584 -  install -m 755 doc/rc.lighttpd %{buildroot}%{_sysconfdir}/init.d/lighttpd
1585 +       install -m 755 doc/rc.lighttpd %{buildroot}%{_sysconfdir}/init.d/lighttpd
1586  fi
1587  install -m 644 doc/sysconfig.lighttpd %{buildroot}%{_sysconfdir}/sysconfig/lighttpd
1588  
1589 @@ -49,16 +46,16 @@
1590  
1591  %post
1592  ## read http://www.fedora.us/docs/spec.html next time :)
1593 -if test "$1" = "1"; then
1594 -  # real install, not upgrade
1595 -  /sbin/chkconfig --add lighttpd
1596 +if [ "$1" = "1" ]; then
1597 +       # real install, not upgrade
1598 +       /sbin/chkconfig --add lighttpd
1599  fi
1600  
1601  %preun
1602 -if test "$1" = "0"; then
1603 -  # real uninstall, not upgrade
1604 -  %{_sysconfdir}/init.d/lighttpd stop
1605 -  /sbin/chkconfig --del lighttpd
1606 +if [ "$1" = "0"]; then
1607 +       # real uninstall, not upgrade
1608 +       %{_sysconfdir}/init.d/lighttpd stop
1609 +       /sbin/chkconfig --del lighttpd
1610  fi
1611  
1612  %files
This page took 0.355745 seconds and 4 git commands to generate.