3 # add current source dir to the include-path
4 # we need this for make distcheck
5 (my $srcdir = $0) =~ s
,/[^/]+$,/,;
11 use Test
::More tests
=> 10;
14 my $tf = LightyTest
->new();
16 my $docroot = $tf->{'TESTDIR'}."/tmp/lighttpd/servers/www.example.org/pages";
19 return 0 unless eval { symlink("",""); 1 };
20 my $f = "$docroot/index.html";
21 my $l = "$docroot/index.xhtml";
24 return 0 unless symlink($f,$l);
26 $f = "$docroot/expire";
27 $l = "$docroot/symlinked";
30 return 0 unless symlink($f,$l);
36 skip
"perl does not support symlinking or setting up the symlinks failed.", 10 unless init_testbed
;
37 ok
($tf->start_proc == 0, "Starting lighttpd") or die();
41 $t->{REQUEST
} = ( <<EOF
42 GET /index.html HTTP/1.0
43 Host: symlink.example.org
46 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
47 ok
($tf->handle_http($t) == 0, 'allow: simple file');
50 $t->{REQUEST
} = ( <<EOF
51 GET /index.xhtml HTTP/1.0
52 Host: symlink.example.org
55 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
56 ok
($tf->handle_http($t) == 0, 'allow: symlinked file');
58 # directly symlinked dir
59 $t->{REQUEST
} = ( <<EOF
60 GET /symlinked/ HTTP/1.0
61 Host: symlink.example.org
64 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
65 ok
($tf->handle_http($t) == 0, 'allow: directly symlinked dir');
67 # symlinked dir in path
68 $t->{REQUEST
} = ( <<EOF
69 GET /symlinked/access.txt HTTP/1.0
70 Host: symlink.example.org
73 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
74 ok
($tf->handle_http($t) == 0, 'allow: symlinked dir in path');
78 $t->{REQUEST
} = ( <<EOF
79 GET /index.html HTTP/1.0
80 Host: nosymlink.example.org
83 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
84 ok
($tf->handle_http($t) == 0, 'deny: simple file');
87 $t->{REQUEST
} = ( <<EOF
88 GET /index.xhtml HTTP/1.0
89 Host: nosymlink.example.org
92 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 403 } ];
93 ok
($tf->handle_http($t) == 0, 'deny: symlinked file');
95 # directly symlinked dir
96 $t->{REQUEST
} = ( <<EOF
97 GET /symlinked/ HTTP/1.0
98 Host: nosymlink.example.org
101 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 403 } ];
102 ok
($tf->handle_http($t) == 0, 'deny: directly symlinked dir');
104 # symlinked dir in path
105 $t->{REQUEST
} = ( <<EOF
106 GET /symlinked/access.txt HTTP/1.0
107 Host: nosymlink.example.org
110 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 403 } ];
111 ok
($tf->handle_http($t) == 0, 'deny: symlinked dir in path');
114 ok
($tf->stop_proc == 0, "Stopping lighttpd");