diff options
author | Thierry Vignaud <tvignaud@mandriva.org> | 2004-01-22 20:24:49 +0000 |
---|---|---|
committer | Thierry Vignaud <tvignaud@mandriva.org> | 2004-01-22 20:24:49 +0000 |
commit | c39ce7aa14f2424c874cc58b5ce5249a05fabe66 (patch) | |
tree | 8893b894f4ac7fc7b2fe4dc116654b3830e88668 /samba_wizard | |
parent | 568cc7c168e09ca61e6a6652ad0ab597fa5b6421 (diff) | |
download | drakwizard-c39ce7aa14f2424c874cc58b5ce5249a05fabe66.tar drakwizard-c39ce7aa14f2424c874cc58b5ce5249a05fabe66.tar.gz drakwizard-c39ce7aa14f2424c874cc58b5ce5249a05fabe66.tar.bz2 drakwizard-c39ce7aa14f2424c874cc58b5ce5249a05fabe66.tar.xz drakwizard-c39ce7aa14f2424c874cc58b5ce5249a05fabe66.zip |
perl_checker fixes
Diffstat (limited to 'samba_wizard')
-rwxr-xr-x | samba_wizard/Samba.pm | 63 |
1 files changed, 32 insertions, 31 deletions
diff --git a/samba_wizard/Samba.pm b/samba_wizard/Samba.pm index 68d4144a..566a8994 100755 --- a/samba_wizard/Samba.pm +++ b/samba_wizard/Samba.pm @@ -232,7 +232,7 @@ configure Samba.") . "\n\n" . N("To accept these values, and configure your serv }; sub new { - my ($class, $conf) = @_; + my ($class) = @_; bless { o => $o, }, $class; @@ -262,7 +262,9 @@ sub read_conf { my ($file) = @_; my ($menu, @tab, %conf); + local *FH; open(FH, $file) or die "$! ($file)"; + local $_; while (<FH>) { if (/^(\s*;?\s*)\[(.*)\]/) { $menu = $2; @@ -287,6 +289,7 @@ sub write_conf { my ($self, $file) = @_; my $menu; + local *FH; open(FH, "> $file") or die "$!"; foreach (@{$self->{tab}}) { if (/^\s*;?\s*\[(.*)\]/) { @@ -310,13 +313,13 @@ sub add_printer { $self->comment_menu($printer, " "); } else { - $self->{conf}->{$printer}{printable}{comment} = " "; - $self->{conf}->{$printer}{printer}{comment} = " "; + $self->{conf}{$printer}{printable}{comment} = " "; + $self->{conf}{$printer}{printer}{comment} = " "; push @{$self->{tab}}, "[$printer]\n"; push @{$self->{tab}}, "printer = $printer\n"; push @{$self->{tab}}, "printable = yes\n"; - $self->{conf}->{$printer}{printer}{value} = $printer; - $self->{conf}->{$printer}{printable}{value} = "yes"; + $self->{conf}{$printer}{printer}{value} = $printer; + $self->{conf}{$printer}{printable}{value} = "yes"; } } @@ -325,7 +328,7 @@ sub list_printers { return @list if @list; @list = sort grep { /^(?!#).+/ } map { - my ($printer) = split(':', $_); + split(':', $_)->[0]; } cat_("/etc/printcap"); if (@list) { @list @@ -342,26 +345,24 @@ sub check_users { sub comment_menu { my ($self, $menu, $str) = @_; - return if !$menu || !exists $self->{conf}->{$menu}; + return if !$menu || !exists $self->{conf}{$menu}; $self->{conf}{$menu}{__comment} = $str; - foreach (keys %{$self->{conf}->{$menu}}) { - ($_ eq "__comment") and next; + foreach (keys %{$self->{conf}{$menu}}) { + $_ eq "__comment" and next; $self->{conf}{$menu}{$_}{comment} = $str; } } sub comment_var { - my $self = shift; - my ($menu, $var, $str) = @_; + my ($self, $menu, $var, $str) = @_; - $self->{conf}->{$menu}{$var}{comment} = $str; + $self->{conf}{$menu}{$var}{comment} = $str; } sub chg_var { - my $self = shift; - my ($menu, $var, $str) = @_; + my ($self, $menu, $var, $str) = @_; - $self->{conf}->{$menu}{$var}{value} = $str; + $self->{conf}{$menu}{$var}{value} = $str; } # all or selected printers @@ -372,7 +373,7 @@ sub printer_sharing { $self->comment_menu('printers', " "); } else { $self->comment_menu("printers", ";"); - for(my $i; $i < @{$o->{var}{wiz_box_list}}; $i++) { + for (my $i = 0; $i < @{$o->{var}{wiz_box_list}}; $i++) { my $printer = $o->{var}{list_printers}[$i]; if ($o->{var}{wiz_box_list}[$i]) { $self->add_printer($printer); @@ -387,7 +388,7 @@ sub get_previous_printers { my ($list_printers) = @_; my $previous = []; foreach my $p (grep { defined $old->{conf}{$_}{printer} } keys %{$old->{conf}}) { - my $test = grep { /\Q$p/ } @$list_printers; + my $test = any { /\Q$p/ } @$list_printers; push @$previous, $test } $previous @@ -397,7 +398,7 @@ sub get_printers { if ($o->{var}{wiz_do_printer_sharing}) { my $string; $o->{var}{wiz_all_printers} and return "all printers"; - for (my $i; $i < @{$o->{var}{wiz_box_list}}; $i++) { + for (my $i = 0; $i < @{$o->{var}{wiz_box_list}}; $i++) { $string .= "$o->{var}{list_printers}[$i]\n" if $o->{var}{wiz_box_list}[$i] } $string; @@ -416,11 +417,11 @@ sub ask_acces { } sub get_write { - $old->{conf}->{public}{"write list"}{value}; + $old->{conf}{public}{"write list"}{value}; } sub get_read { - $old->{conf}->{public}{"read list"}{value}; + $old->{conf}{public}{"read list"}{value}; } sub check_banner { @@ -428,11 +429,11 @@ sub check_banner { } sub get_workgroup { - $old->{conf}->{global}{workgroup}{value} + $old->{conf}{global}{workgroup}{value} } sub get_banner { - $old->{conf}->{global}{"server string"}{value}; + $old->{conf}{global}{"server string"}{value}; } sub ask_dir { @@ -441,16 +442,16 @@ sub ask_dir { } sub get_dir { - $old->{conf}->{public}{path}{value}; + $old->{conf}{public}{path}{value}; } sub get_file_sharing { - return 0 if ($old->{conf}->{public}{__comment} =~ /;|#/); + return 0 if $old->{conf}{public}{__comment} =~ /;|#/; 1; } sub get_home_sharing { - return 0 if ($old->{conf}->{homes}{__comment} =~ /;|#/); + return 0 if $old->{conf}{homes}{__comment} =~ /;|#/; 1; } @@ -459,11 +460,11 @@ sub get_netmask { } sub get_allow_host { - $old->{conf}->{global}{"hosts allow"}{value}; + $old->{conf}{global}{"hosts allow"}{value}; } sub get_deny_host { - $old->{conf}->{global}{"hosts deny"}{value}; + $old->{conf}{global}{"hosts deny"}{value}; } # remember one variable cannot be commented and not in the same file. @@ -476,7 +477,7 @@ sub do_it { $conf->chg_var("global", "server string", $o->{var}{wiz_banner}); $conf->chg_var("public", "write list", $o->{var}{wiz_write_list}) if $o->{var}{wiz_do_file_sharing}; $conf->chg_var("public", "read list", $o->{var}{wiz_read_list}) if $o->{var}{wiz_do_file_sharing}; - my $ip = $wiz->{net}->itf_get("IPADDR"); + #my $ip = $wiz->{net}->itf_get("IPADDR"); if ($o->{var}{wiz_do_file_sharing}) { standalone->explanations("Enabling $o->{var}{wiz_dir} samba file sharing"); $conf->comment_menu("public", " "); @@ -501,11 +502,11 @@ sub do_it { if ($o->{var}{wiz_do_printer_sharing}) { standalone->explanations("Enabling printer sharing"); - $conf->printer_sharing(); + $conf->printer_sharing; } else { standalone->explanations("Disabling printer sharing"); - for(my $i; $i < @{$o->{var}{wiz_box_list}}; $i++) { - $conf->comment_menu("$o->{var}{list_printers}[$i]", ";"); + for (my $i = 0; $i < @{$o->{var}{wiz_box_list}}; $i++) { + $conf->comment_menu($o->{var}{list_printers}[$i], ";"); } $conf->comment_menu("printers", ";"); } |