| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Test::FTP::Server::Server; |
|
2
|
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
21
|
use strict; |
|
|
4
|
|
|
|
|
11
|
|
|
|
4
|
|
|
|
|
129
|
|
|
4
|
4
|
|
|
4
|
|
21
|
use warnings; |
|
|
4
|
|
|
|
|
10
|
|
|
|
4
|
|
|
|
|
176
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.011'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
4
|
|
|
4
|
|
20
|
use Carp; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
228
|
|
|
9
|
4
|
|
|
4
|
|
19
|
use File::Temp qw/ tempfile tempdir /; |
|
|
4
|
|
|
|
|
23
|
|
|
|
4
|
|
|
|
|
171
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
4
|
|
|
4
|
|
5600
|
use Net::FTPServer; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use Net::FTPServer::Full::Server; |
|
13
|
|
|
|
|
|
|
use Test::FTP::Server::DirHandle; |
|
14
|
|
|
|
|
|
|
use base qw/ Net::FTPServer::Full::Server /; |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub test_users { |
|
17
|
|
|
|
|
|
|
my $self = shift; |
|
18
|
|
|
|
|
|
|
$self->{'_test_users'} = shift if @_; |
|
19
|
|
|
|
|
|
|
$self->{'_test_users'} || undef; |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub options_hook { |
|
23
|
|
|
|
|
|
|
my $self = shift; |
|
24
|
|
|
|
|
|
|
my ($args) = @_; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
for (my $i = 0; $i < scalar(@$args); $i++) { |
|
27
|
|
|
|
|
|
|
if (! ref($args->[$i]) && $args->[$i] =~ m/^_test_/) { |
|
28
|
|
|
|
|
|
|
$self->{$args->[$i]} = $args->[$i+1]; |
|
29
|
|
|
|
|
|
|
splice(@$args, $i, 2); |
|
30
|
|
|
|
|
|
|
$i--; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
return if grep($_ eq '-C', @$args); |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
if (-e $self->{_config_file}) { |
|
37
|
|
|
|
|
|
|
my ($fh, $filename) = tempfile(); |
|
38
|
|
|
|
|
|
|
close($fh); |
|
39
|
|
|
|
|
|
|
push(@$args, '-C', $filename); |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub authentication_hook { |
|
44
|
|
|
|
|
|
|
my $self = shift; |
|
45
|
|
|
|
|
|
|
my ($user, $pass, $user_is_anon) = @_; |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
if (defined(my $users = $self->test_users)) { |
|
48
|
|
|
|
|
|
|
return scalar(grep({ |
|
49
|
|
|
|
|
|
|
$_->{'user'} eq $user && $_->{'pass'} eq $pass |
|
50
|
|
|
|
|
|
|
} @$users)) ? 0 : -1; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
$self->SUPER::authentication_hook(@_); |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub user_login_hook { |
|
57
|
|
|
|
|
|
|
my $self = shift; |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
if (defined(my $users = $self->test_users)) { |
|
60
|
|
|
|
|
|
|
my ($u) = grep({ |
|
61
|
|
|
|
|
|
|
$_->{'user'} eq $self->{'user'} |
|
62
|
|
|
|
|
|
|
} @$users); |
|
63
|
|
|
|
|
|
|
if ($u && $u->{'root'}) { |
|
64
|
|
|
|
|
|
|
$self->{'_test_root'} = $u->{'root'}; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
return; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
$self->SUPER::user_login_hook(@_); |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub root_directory_hook { |
|
73
|
|
|
|
|
|
|
my $self = shift; |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
if ($self->{'_test_root'}) { |
|
76
|
|
|
|
|
|
|
new Test::FTP::Server::DirHandle($self); |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
else { |
|
79
|
|
|
|
|
|
|
$self->SUPER::root_directory_hook(@_); |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |
|
84
|
|
|
|
|
|
|
__END__ |