| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# -*- perl -*- |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Net::FTPServer A Perl FTP Server |
|
4
|
|
|
|
|
|
|
# Copyright (C) 2000 Bibliotech Ltd., Unit 2-3, 50 Carnwath Road, |
|
5
|
|
|
|
|
|
|
# London, SW6 3EG, United Kingdom. |
|
6
|
|
|
|
|
|
|
# |
|
7
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify |
|
8
|
|
|
|
|
|
|
# it under the terms of the GNU General Public License as published by |
|
9
|
|
|
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or |
|
10
|
|
|
|
|
|
|
# (at your option) any later version. |
|
11
|
|
|
|
|
|
|
# |
|
12
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful, |
|
13
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15
|
|
|
|
|
|
|
# GNU General Public License for more details. |
|
16
|
|
|
|
|
|
|
# |
|
17
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License |
|
18
|
|
|
|
|
|
|
# along with this program; if not, write to the Free Software |
|
19
|
|
|
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=pod |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 NAME |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Net::FTPServer::RO::Server - The anonymous read-only FTP server personality |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
ro-ftpd.pl [-d] [-v] [-p port] [-s] [-S] [-V] [-C conf_file] |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
C is the anonymous read-only FTP server |
|
34
|
|
|
|
|
|
|
personality. This personality implements a complete |
|
35
|
|
|
|
|
|
|
FTP server with similar functionality to I, |
|
36
|
|
|
|
|
|
|
except that it is not possible to write and all logins |
|
37
|
|
|
|
|
|
|
must be anonymous. |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 METHODS |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=cut |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
package Net::FTPServer::RO::Server; |
|
44
|
|
|
|
|
|
|
|
|
45
|
1
|
|
|
1
|
|
624
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
25
|
|
|
46
|
|
|
|
|
|
|
|
|
47
|
1
|
|
|
1
|
|
4
|
use vars qw($VERSION); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
54
|
|
|
48
|
|
|
|
|
|
|
( $VERSION ) = '$Revision: 1.1 $ ' =~ /\$Revision:\s+([^\s]+)/; |
|
49
|
|
|
|
|
|
|
|
|
50
|
1
|
|
|
1
|
|
6
|
use Net::FTPServer; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
15
|
|
|
51
|
1
|
|
|
1
|
|
4
|
use Net::FTPServer::RO::FileHandle; |
|
|
1
|
|
|
|
|
6
|
|
|
|
1
|
|
|
|
|
14
|
|
|
52
|
1
|
|
|
1
|
|
4
|
use Net::FTPServer::RO::DirHandle; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
22
|
|
|
53
|
|
|
|
|
|
|
|
|
54
|
1
|
|
|
1
|
|
4
|
use vars qw(@ISA); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
257
|
|
|
55
|
|
|
|
|
|
|
@ISA = qw(Net::FTPServer); |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# This is called before configuration. |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub pre_configuration_hook |
|
60
|
|
|
|
|
|
|
{ |
|
61
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# Put the personality signature into the version string. |
|
64
|
0
|
|
|
|
|
|
$self->{version_string} .= " (RO)"; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=pod |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=over 4 |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=item $rv = $self->authentication_hook ($user, $pass, $user_is_anon) |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Perform login against C or the PAM database. |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=cut |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub authentication_hook |
|
78
|
|
|
|
|
|
|
{ |
|
79
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
80
|
0
|
|
|
|
|
|
my $user = shift; |
|
81
|
0
|
|
|
|
|
|
my $pass = shift; |
|
82
|
0
|
|
|
|
|
|
my $user_is_anon = shift; |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# Only allow anonymous users. |
|
85
|
0
|
0
|
|
|
|
|
return -1 unless $user_is_anon; |
|
86
|
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
return 0; |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=pod |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item $self->user_login_hook ($user, $user_is_anon) |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Hook: Called just after user C<$user> has successfully logged in. |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub user_login_hook |
|
99
|
|
|
|
|
|
|
{ |
|
100
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
101
|
0
|
|
|
|
|
|
my $user = shift; |
|
102
|
0
|
|
|
|
|
|
my $user_is_anon = shift; |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# For anonymous users, chroot to ftp directory. |
|
105
|
0
|
0
|
|
|
|
|
my ($login, $pass, $uid, $gid, $quota, $comment, $gecos, $homedir) |
|
106
|
|
|
|
|
|
|
= getpwnam "ftp" |
|
107
|
|
|
|
|
|
|
or die "no ftp user in password file"; |
|
108
|
|
|
|
|
|
|
|
|
109
|
0
|
0
|
|
|
|
|
chroot $homedir or die "cannot chroot: $homedir: $!"; |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
# We don't allow users to relogin, so completely change to |
|
112
|
|
|
|
|
|
|
# the user specified. |
|
113
|
0
|
|
|
|
|
|
$self->_drop_privs ($uid, $gid, $login); |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=pod |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=item $dirh = $self->root_directory_hook; |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Hook: Return an instance of Net::FTPServer::RO::DirHandle |
|
121
|
|
|
|
|
|
|
corresponding to the root directory. |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=cut |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub root_directory_hook |
|
126
|
|
|
|
|
|
|
{ |
|
127
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
128
|
|
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
|
return new Net::FTPServer::RO::DirHandle ($self); |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
1 # So that the require or use succeeds. |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
__END__ |