Changeset 1871

Show
Ignore:
Timestamp:
06/15/2007 02:46:17 PM (15 months ago)
Author:
jan
Message:

check the URL twice, before and after path-info handling. (fixes #1230)

Location:
branches/lighttpd-1.4.x
Files:
1 added
4 modified

Legend:

Unmodified
Added
Removed
  • branches/lighttpd-1.4.x/src/mod_access.c

    r1371 r1871  
    112112#undef PATCH 
    113113 
     114/** 
     115 * URI handler 
     116 * 
     117 * we will get called twice: 
     118 * - after the clean up of the URL and  
     119 * - after the pathinfo checks are done 
     120 * 
     121 * this handles the issue of trailing slashes 
     122 */ 
    114123URIHANDLER_FUNC(mod_access_uri_handler) { 
    115124        plugin_data *p = p_d; 
     
    123132        s_len = con->uri.path->used - 1; 
    124133 
     134        if (con->conf.log_request_handling) { 
     135                log_error_write(srv, __FILE__, __LINE__, "s",  
     136                                "-- mod_access_uri_handler called"); 
     137        } 
     138 
    125139        for (k = 0; k < p->conf.access_deny->used; k++) { 
    126140                data_string *ds = (data_string *)p->conf.access_deny->data[k]; 
    127141                int ct_len = ds->value->used - 1; 
     142                int denied = 0; 
     143 
    128144 
    129145                if (ct_len > s_len) continue; 
    130  
    131146                if (ds->value->used == 0) continue; 
    132147 
     
    135150                if (con->conf.force_lowercase_filenames) { 
    136151                        if (0 == strncasecmp(con->uri.path->ptr + s_len - ct_len, ds->value->ptr, ct_len)) { 
    137                                 con->http_status = 403; 
    138  
    139                                 return HANDLER_FINISHED; 
     152                                denied = 1; 
    140153                        } 
    141154                } else { 
    142155                        if (0 == strncmp(con->uri.path->ptr + s_len - ct_len, ds->value->ptr, ct_len)) { 
    143                                 con->http_status = 403; 
     156                                denied = 1; 
     157                        } 
     158                } 
    144159 
    145                                 return HANDLER_FINISHED; 
     160                if (denied) { 
     161                        con->http_status = 403; 
     162 
     163                        if (con->conf.log_request_handling) { 
     164                                log_error_write(srv, __FILE__, __LINE__, "sb",  
     165                                        "url denied as we match:", ds->value); 
    146166                        } 
     167 
     168                        return HANDLER_FINISHED; 
    147169                } 
    148170        } 
     
    159181        p->init        = mod_access_init; 
    160182        p->set_defaults = mod_access_set_defaults; 
    161         p->handle_uri_clean  = mod_access_uri_handler; 
     183        p->handle_uri_clean = mod_access_uri_handler; 
     184        p->handle_subrequest_start  = mod_access_uri_handler; 
    162185        p->cleanup     = mod_access_free; 
    163186 
  • branches/lighttpd-1.4.x/tests/docroot/www/Makefile.am

    r1374 r1871  
    22           redirect.php cgi-pathinfo.pl get-env.php get-server-env.php \ 
    33           nph-status.pl prefix.fcgi get-header.pl ssi.shtml get-post-len.pl \ 
    4            exec-date.shtml 
     4           exec-date.shtml index.html~ 
    55SUBDIRS=go indexfile expire 
  • branches/lighttpd-1.4.x/tests/mod-access.t

    r1374 r1871  
    99use strict; 
    1010use IO::Socket; 
    11 use Test::More tests => 3; 
     11use Test::More tests => 4; 
    1212use LightyTest; 
    1313 
     
    2424ok($tf->handle_http($t) == 0, 'forbid access to ...~'); 
    2525 
     26$t->{REQUEST}  = ( <<EOF 
     27GET /index.html~/ HTTP/1.0 
     28EOF 
     29 ); 
     30$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 403 } ]; 
     31ok($tf->handle_http($t) == 0, '#1230 - forbid access to ...~ - trailing slash'); 
     32 
    2633ok($tf->stop_proc == 0, "Stopping lighttpd"); 
    2734 
  • branches/lighttpd-1.4.x/tests/prepare.sh

    r1374 r1871  
    2626cp $srcdir/docroot/www/*.html \ 
    2727   $srcdir/docroot/www/*.php \ 
     28   $srcdir/docroot/www/*.html~ \ 
    2829   $srcdir/docroot/www/*.pl \ 
    2930   $srcdir/docroot/www/*.fcgi \