Net-FTPServer
view release on metacpan or search on metacpan
lib/Net/FTPServer.pm view on Meta::CPAN
}
else
{
die "Refusing to create weird looking pidfile: $pidfile";
}
}
}
# Set a resource limit, by using the BSD::Resource module, if available.
sub _set_rlimit
{
my $self = shift;
my $name = shift;
my $value = shift;
# The BSD::Resource module is optional, and may not be available.
if (exists $INC{"BSD/Resource.pm"} &&
exists get_rlimits()->{$name})
{
setrlimit (&{$ {BSD::Resource::}{$name}}, $value, $value)
or die "setrlimit: $!";
}
elsif (not $ENV{NET_FTPSERVER_NO_BSD_RESOURCE_WARNING})
{
warn
"Resource limit $name cannot be set. This may be because ",
"the BSD::Resource module is not available on your ",
"system, or it may be because your operating system ",
"does not support $name. Without resource limits, the ",
"FTP server may be open to denial of service (DoS) ",
"attacks. The real error was: $@";
}
}
# Check for an external program (eg. "gzip"). This test is not
# bulletproof: In particular, it requires $PATH to be set correctly
# at the top of this file or in the config file.
sub _find_prog
{
my $self = shift;
my $prog = shift;
my @paths = split /:/, $ENV{PATH};
foreach (@paths)
{
return 1 if -x "$_/$prog";
}
return 0;
}
# This subroutine loads the command line options and configuration file
# and resolves conflicts. Command line options have priority over
# certain things in the configuration file.
sub _get_configuration
{
my $self = shift;
my $args = shift;
local @ARGV = @$args;
my ($debug, $help, $port, $s_option, $S_option,
$pidfile, $show_version, @overrides);
Getopt::Long::Configure ("no_ignore_case");
Getopt::Long::Configure ("pass_through");
GetOptions (
"C=s" => \$self->{_config_file},
"d+" => \$debug,
"help|?" => \$help,
"o=s" => \@overrides,
"p=i" => \$port,
"P=s" => \$pidfile,
"s" => \$s_option,
"S" => \$S_option,
"test" => \$self->{_test_mode},
"v+" => \$debug,
"V" => \$show_version,
);
# Show version and exit?
if ($show_version)
{
print $self->{version_string}, "\n";
exit 0;
}
# Show help and exit?
if ($help)
{
my $name = $0;
$name =~ s,.*/,,;
print <<EOT;
$name: $self->{version_string}
Usage:
$name [-options]
Options:
-?, --help Print this help text and exit.
-d, -v Debug mode on.
-p port Specify listening port (defaults to FTP port, 21).
-s Run in daemon mode (default: run from inetd).
-S Run in background and in daemon mode.
-V Show version information and exit.
-C config_file Specify configuration file (default: /etc/ftpd.conf).
-P pidfile Save process ID into pidfile.
-o option=value Override configuration file options.
Normal standalone usage:
$name -S
Normal usage from inetd:
ftp stream tcp nowait root /usr/sbin/tcpd $name
For further information, please read the full documentation in the
( run in 0.480 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )