summaryrefslogtreecommitdiffstats
path: root/ftp_wizard
diff options
context:
space:
mode:
authorThierry Vignaud <tvignaud@mandriva.org>2004-01-22 20:00:06 +0000
committerThierry Vignaud <tvignaud@mandriva.org>2004-01-22 20:00:06 +0000
commit568cc7c168e09ca61e6a6652ad0ab597fa5b6421 (patch)
tree7ae6b93d322db1543350608f9dba88007fa23f14 /ftp_wizard
parent1d8f4f1511ffe1a3e499e089b126397f1d9d0af4 (diff)
downloaddrakwizard-568cc7c168e09ca61e6a6652ad0ab597fa5b6421.tar
drakwizard-568cc7c168e09ca61e6a6652ad0ab597fa5b6421.tar.gz
drakwizard-568cc7c168e09ca61e6a6652ad0ab597fa5b6421.tar.bz2
drakwizard-568cc7c168e09ca61e6a6652ad0ab597fa5b6421.tar.xz
drakwizard-568cc7c168e09ca61e6a6652ad0ab597fa5b6421.zip
perl_checker fixes
Diffstat (limited to 'ftp_wizard')
-rwxr-xr-xftp_wizard/Proftpd.pm87
1 files changed, 46 insertions, 41 deletions
diff --git a/ftp_wizard/Proftpd.pm b/ftp_wizard/Proftpd.pm
index d50644ca..0bee21ce 100755
--- a/ftp_wizard/Proftpd.pm
+++ b/ftp_wizard/Proftpd.pm
@@ -28,7 +28,7 @@ use common;
use services;
require MDK::Wizard::Wizcommon;
-my $wiz = new MDK::Wizard::Wizcommon;
+my $wiz = MDK::Wizard::Wizcommon->new;
my $o = {
name => N("FTP wizard"),
@@ -50,14 +50,14 @@ my %opt = (
"SystemLog" => "/var/log/proftpd/proftpd.log",
"TransferLog" => "/var/log/proftpd/xferlog",
"Extendedlog" => "/var/log/proftpd/ftp.log",
- "LogFormat default" => "\"%h %l %u %t \"%r\" %s %b\"",
- "LogFormat auth" => "\"%v [%P] %h %t \"%r\" %s\"",
- "LogFormat write" => "\"%h %l %u %t \"%r\" %s %b\"",
+ "LogFormat default" => qq("%h %l %u %t "%r" %s %b"),
+ "LogFormat auth" => qq("%v [%P] %h %t "%r" %s"),
+ "LogFormat write" => qq("%h %l %u %t "%r" %s %b"),
"ServerIdent" => "off",
"DeferWelcome" => "on",
"DisplayConnect" => "/etc/banner-proftpd",
- "AccessDenyMsg" => "\" !-!! ACCESS DENY !!-! SEEMS YOU HAVE NO RIGHT THERE !!\"",
- "AccessGrantMsg" => "\" -- Guest access granted for %u --\"",
+ "AccessDenyMsg" => qq(" !-!! ACCESS DENY !!-! SEEMS YOU HAVE NO RIGHT THERE !!"),
+ "AccessGrantMsg" => qq(" -- Guest access granted for %u --"),
"IdentLookups" => "off",
"UseReverseDNS" => "off",
"TimesGMT" => "off",
@@ -145,14 +145,14 @@ needed to configure your FTP Server") . "\n\n" . N("To accept these values, and
};
sub new {
- my ($class, $conf) = @_;
+ my ($class) = @_;
bless {
o => $o,
}, $class;
}
sub true {
- my ($val) = @_;
+ my ($val) = @_;
return member($val, qw(1 '1' "1" true 'true' "true"));
}
@@ -163,12 +163,14 @@ sub check_dir {
sub get_dir {
my $file = "/etc/proftpd.conf";
- die "no ftp configuration file found ! warning." if (!-f $file);
+ die "no ftp configuration file found ! warning." if !-f $file;
+ local *NEW;
open(NEW, "< $file") or die "error while opening $file: $!";
+ local $_;
while (<NEW>) { # we need 3 elements to consider section as known
- if (m/^\s*<drakwizard>/s...m/^\s*<\/drakwizard>/s ) {
- if (m/^\s*<Anonymous\s*(.*)>/s ) {
+ if (m/^\s*<drakwizard>/s...m!^\s*</drakwizard>!s) {
+ if (m/^\s*<Anonymous\s*(.*)>/s) {
return $1;
}
}
@@ -178,14 +180,15 @@ sub get_dir {
sub check {
$> and return 'must_be_root';
- $wiz->{net}->is_dhcp() and return 'warning_dhcp';
+ $wiz->{net}->is_dhcp and return 'warning_dhcp';
''
}
-sub print_anonymous() {
+sub print_anonymous {
+ my ($arg) = @_;
print '
#<drakwizard>
-<Anonymous '.$_[0].'>
+<Anonymous '.$arg.'>
User ftp
Group ftp
UserAlias anonymous ftp
@@ -203,7 +206,7 @@ sub change_options {
my $file = "/etc/proftpd.conf";
my $status;
if ($var == 1) { $status = "on" } else { $status = "off" }
- if ( any { /^$var_in_conf/ } cat_($file)) {
+ if (any { /^$var_in_conf/ } cat_($file)) {
substInFile { s/$var_in_conf.*/$var_in_conf $status/ } $file;
} else {
append_to_file($file, "$var_in_conf $status\n")
@@ -213,7 +216,7 @@ sub change_options {
sub add_options {
my ($var, $value) = @_;
my $file = "/etc/proftpd.conf";
- if ( any { /^$var/ } cat_($file)) {
+ if (any { /^$var/ } cat_($file)) {
substInFile { s/$var.*/$var $value/ } $file;
} else {
append_to_file($file, "$var $value\n")
@@ -226,8 +229,9 @@ sub do_it {
my $wiz_ftp_internal = $o->{var}{wiz_ftp_external} ? 1 : true $o->{var}{wiz_ftp_internal};
my $wiz_ftp_external = true $o->{var}{wiz_ftp_external};
my $file = "/etc/proftpd.conf";
- die "no ftp configuration file found ! warning." if (!-f $file);
+ die "no ftp configuration file found ! warning." if !-f $file;
MDK::Common::cp_af($file, $file . ".orig");
+ local *NEW;
open(NEW, "< $file") or die "error while opening $file: $!";
my $allow = "all";
if ($wiz_ftp_internal && !$wiz_ftp_external) {
@@ -237,36 +241,37 @@ sub do_it {
elsif (!$wiz_ftp_external) {
$allow = "none";
}
- my $file = "/etc/proftpd.conf";
- open (NEW, "< $file");
+ $file = "/etc/proftpd.conf";
+ open(NEW, "< $file");
my $exist = 0;
+ local $_;
while (<NEW>) { # we need 3 elements to consider section as known
- if (m/^\s*<Global>/s...m/^\s*<\/Global>/s ) {
- if (m/^\s*<Limit LOGIN>/s...m/^\s*<\/Limit>/s ) {
- if (/^\s*(?!\#)\s*Order .*$/) {
+ if (m/^\s*<Global>/s...m!^\s*</Global>!s) {
+ if (m/^\s*<Limit LOGIN>/s...m!^\s*</Limit>!s) {
+ if (/^\s*(?!#)\s*Order /) {
$exist++;
}
- if (/^\s*(?!\#)\s*Allow .*$/) {
+ if (/^\s*(?!#)\s*Allow /) {
$exist++;
}
- if (/^\s*(?!\#)\s*Deny .*$/) {
+ if (/^\s*(?!#)\s*Deny /) {
$exist++;
}
}
}
}
- close (NEW);
+ close(NEW);
if ($exist < 3) { # Odd parameters are commented if exists to then add a known section
substInFile {
- if (m/^\s*<Global>/s...m/^\s*<\/Global>/s ) {
- if (m/^\s*<Limit LOGIN>/s...m/^\s*<\/Limit>/s ) {
- s/^\s*(?!\#)\s*Order .*$/\#$&\n/s;
- s/^\s*(?!\#)\s*Allow .*$/\#$&\n/s;
- s/^\s*(?!\#)\s*Deny .*$/\#$&\n/s;
+ if (m/^\s*<Global>/s...m!^\s*</Global>!s) {
+ if (m/^\s*<Limit LOGIN>/s...m!^\s*</Limit>!s) {
+ s/^\s*(?!#)\s*Order .*$/#$&\n/s;
+ s/^\s*(?!#)\s*Allow .*$/#$&\n/s;
+ s/^\s*(?!#)\s*Deny .*$/#$&\n/s;
}
}
} $file;
- open (NEW, ">> $file");
+ open(NEW, ">> $file");
print NEW '
#<drakwizard>
<Global>
@@ -280,23 +285,23 @@ sub do_it {
';
close NEW;
}
- else { # the known section (3 parameters ) is replaced with our needs
+ else { # the known section (3 parameters) is replaced with our needs
substInFile {
- if (m/^\s*<Global>/s...m/^\s*<\/Global>/s ) {
- if (m/^\s*<Limit LOGIN>/s...m/^\s*<\/Limit>/s ) {
- if (/^\s*(?!\#)\s*Order .*$/i) {
+ if (m/^\s*<Global>/s...m!^\s*</Global>!s) {
+ if (m/^\s*<Limit LOGIN>/s...m!^\s*</Limit>!s) {
+ if (/^\s*(?!#)\s*Order /i) {
if (!/\s*Order\s*allow,\s*deny\s*$/) {
- s//\#$&\n Order allow,deny\n/;
+ s//#$&\n Order allow,deny\n/;
}
}
- if (/^\s*(?!\#)\s*Allow .*$/i) {
+ if (/^\s*(?!#)\s*Allow /i) {
if (!/\s*Allow\s*from\s*$allow\s*$/) {
- s//\#$&\n Allow from $allow/;
+ s//#$&\n Allow from $allow/;
}
}
- if (/^\s*(?!\#)\s*Deny .*$/i) {
+ if (/^\s*(?!#)\s*Deny /i) {
if (!/\s*Deny\s*from\s*all\s*$/) {
- s//\#$&\n Deny from all\n/;
+ s//#$&\n Deny from all\n/;
}
}
}
@@ -326,7 +331,7 @@ sub do_it {
} else {
$data = ""
}
- if ( any { /^DefaultRoot/ } cat_($file)) {
+ if (any { /^DefaultRoot/ } cat_($file)) {
substInFile { s/DefaultRoot.*/$data/ } $file;
} else {
append_to_file($file, "$data\n");