From 568cc7c168e09ca61e6a6652ad0ab597fa5b6421 Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Thu, 22 Jan 2004 20:00:06 +0000 Subject: perl_checker fixes --- ftp_wizard/Proftpd.pm | 87 +++++++++++++++++++++++++++------------------------ 1 file changed, 46 insertions(+), 41 deletions(-) (limited to 'ftp_wizard/Proftpd.pm') 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 () { # we need 3 elements to consider section as known - if (m/^\s*/s...m/^\s*<\/drakwizard>/s ) { - if (m/^\s*/s ) { + if (m/^\s*/s...m!^\s*!s) { + if (m/^\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 ' # - + 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 () { # we need 3 elements to consider section as known - if (m/^\s*/s...m/^\s*<\/Global>/s ) { - if (m/^\s*/s...m/^\s*<\/Limit>/s ) { - if (/^\s*(?!\#)\s*Order .*$/) { + if (m/^\s*/s...m!^\s*!s) { + if (m/^\s*/s...m!^\s*!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*/s...m/^\s*<\/Global>/s ) { - if (m/^\s*/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*/s...m!^\s*!s) { + if (m/^\s*/s...m!^\s*!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 ' # @@ -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*/s...m/^\s*<\/Global>/s ) { - if (m/^\s*/s...m/^\s*<\/Limit>/s ) { - if (/^\s*(?!\#)\s*Order .*$/i) { + if (m/^\s*/s...m!^\s*!s) { + if (m/^\s*/s...m!^\s*!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"); -- cgit v1.2.1