| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#line 1 |
|
2
|
|
|
|
|
|
|
package Test::FTP::Server; |
|
3
|
2
|
|
|
2
|
|
1529
|
|
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
69
|
|
|
4
|
2
|
|
|
2
|
|
9
|
use strict; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
88
|
|
|
5
|
|
|
|
|
|
|
use warnings; |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.012'; |
|
8
|
2
|
|
|
2
|
|
10
|
|
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
172
|
|
|
9
|
|
|
|
|
|
|
use Carp; |
|
10
|
2
|
|
|
2
|
|
9
|
|
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
126
|
|
|
11
|
2
|
|
|
2
|
|
14
|
use File::Find; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
44
|
|
|
12
|
2
|
|
|
2
|
|
1598
|
use File::Spec; |
|
|
2
|
|
|
|
|
10595
|
|
|
|
2
|
|
|
|
|
152
|
|
|
13
|
2
|
|
|
2
|
|
4599
|
use File::Copy; |
|
|
2
|
|
|
|
|
46518
|
|
|
|
2
|
|
|
|
|
138
|
|
|
14
|
|
|
|
|
|
|
use File::Temp qw/ tempfile tempdir /; |
|
15
|
2
|
|
|
2
|
|
3168
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
use Test::FTP::Server::Server; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub new { |
|
19
|
|
|
|
|
|
|
my $class = shift; |
|
20
|
|
|
|
|
|
|
my (%opt) = @_; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my @args = (); |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
if (my $users = $opt{'users'}) { |
|
25
|
|
|
|
|
|
|
foreach my $u (@$users) { |
|
26
|
|
|
|
|
|
|
if (my $base = $u->{'sandbox'}) { |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
croak($base . ' is not directory.') unless -d $base; |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $dir = tempdir(CLEANUP => 1); |
|
31
|
|
|
|
|
|
|
File::Find::find({ |
|
32
|
|
|
|
|
|
|
'wanted' => sub { |
|
33
|
|
|
|
|
|
|
my $src = my $dst = $_; |
|
34
|
|
|
|
|
|
|
$dst =~ s/^$base//; |
|
35
|
|
|
|
|
|
|
$dst = File::Spec->catfile($dir, $dst); |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
if (-d $_) { |
|
38
|
|
|
|
|
|
|
mkdir($dst); |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
else { |
|
41
|
|
|
|
|
|
|
File::Copy::copy($src, $dst); |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
chmod((stat($src))[2], $dst); |
|
45
|
|
|
|
|
|
|
utime((stat($src))[8,9], $dst); |
|
46
|
|
|
|
|
|
|
}, |
|
47
|
|
|
|
|
|
|
'no_chdir' => 1, |
|
48
|
|
|
|
|
|
|
}, $base); |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
$u->{'root'} = $dir; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
croak( |
|
54
|
|
|
|
|
|
|
'It\'s necessary to specify parameter that is ' . |
|
55
|
|
|
|
|
|
|
'"root" or "sandbox" for each user.' |
|
56
|
|
|
|
|
|
|
) unless $u->{'root'}; |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
croak($u->{'root'} . ' is not directory.') unless -d $u->{'root'}; |
|
59
|
|
|
|
|
|
|
croak('"user" is required.') unless $u->{'user'}; |
|
60
|
|
|
|
|
|
|
croak('"pass" is required.') unless $u->{'pass'}; |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
$u->{'root'} =~ s{/+$}{}; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
push(@args, '_test_users', $users); |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
if ($opt{'ftpd_conf'}) { |
|
68
|
|
|
|
|
|
|
if (ref $opt{'ftpd_conf'}) { |
|
69
|
|
|
|
|
|
|
my ($fh, $filename) = tempfile(); |
|
70
|
|
|
|
|
|
|
while (my ($k, $v) = each %{ $opt{'ftpd_conf'} }) { |
|
71
|
|
|
|
|
|
|
print($fh "$k: $v\n"); |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
close($fh); |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
push(@args, '-C', $filename); |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
else { |
|
78
|
|
|
|
|
|
|
push(@args, '-C', $opt{'ftpd_conf'}); |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
my $self = bless({ 'args' => \@args }, $class); |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub run { |
|
86
|
|
|
|
|
|
|
my $self = shift; |
|
87
|
|
|
|
|
|
|
Test::FTP::Server::Server->run($self->{'args'}); |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |
|
91
|
|
|
|
|
|
|
__END__ |