summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorThierry Vignaud <tv@mageia.org>2012-03-20 19:52:33 +0000
committerThierry Vignaud <tv@mageia.org>2012-03-20 19:52:33 +0000
commitb3111e7e9c262d8c71e23a6dc78d5d7a888dacc3 (patch)
treed42205550d30ec092f9743748bcec938017f985b /bin
parent683619174a6cd634655ac6a489b5a6efb1b5b3cc (diff)
downloaddrakx-net-b3111e7e9c262d8c71e23a6dc78d5d7a888dacc3.tar
drakx-net-b3111e7e9c262d8c71e23a6dc78d5d7a888dacc3.tar.gz
drakx-net-b3111e7e9c262d8c71e23a6dc78d5d7a888dacc3.tar.bz2
drakx-net-b3111e7e9c262d8c71e23a6dc78d5d7a888dacc3.tar.xz
drakx-net-b3111e7e9c262d8c71e23a6dc78d5d7a888dacc3.zip
perl_checker cleanups
Diffstat (limited to 'bin')
-rw-r--r--bin/drakhosts6
-rwxr-xr-xbin/draknetprofile10
-rwxr-xr-xbin/draknfs10
-rwxr-xr-xbin/draksambashare57
-rwxr-xr-xbin/net_applet10
-rwxr-xr-xbin/net_monitor20
6 files changed, 65 insertions, 48 deletions
diff --git a/bin/drakhosts b/bin/drakhosts
index 1b99c1b..1c2a49a 100644
--- a/bin/drakhosts
+++ b/bin/drakhosts
@@ -17,8 +17,6 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
-my $version = "0.1";
-
# i18n: IMPORTANT: to get correct namespace (drakhosts instead of libDrakX)
BEGIN { unshift @::textdomains, 'drakhosts' }
@@ -80,7 +78,7 @@ sub add_modify_entry {
my $model = $treeview->get_model;
my $selection = $treeview->get_selection;
my $iter;
- my ($i, $ip, $hostname, $alias, $oldip);
+ my ($i, $ip, $hostname, $alias);
undef $i;
undef $iter;
@@ -103,7 +101,6 @@ sub add_modify_entry {
$ip->set_text($listhosts[$i]{ip});
$hostname->set_text($listhosts[$i]{hostname});
$alias->set_text($listhosts[$i]{alias});
- $oldip = $listhosts[$i]{ip};
}
my $text;
@@ -178,7 +175,6 @@ sub create_model() {
# add colum to model
sub add_columns {
my $treeview = shift;
- my $model = $treeview->get_model;
each_index {
my $renderer = Gtk2::CellRendererText->new;
$renderer->set(editable => 0);
diff --git a/bin/draknetprofile b/bin/draknetprofile
index 7a43689..e8ca2fd 100755
--- a/bin/draknetprofile
+++ b/bin/draknetprofile
@@ -104,15 +104,15 @@ sub load_netprofile_modules() {
sub get_selected_profile() {
my ($index) = $profiles_list->get_selected_indices;
- if (not $index ) {
+ if (!$index) {
my $pc = @{$profiles_list->{data}};
my $index = 0;
for (my $i = 0; $i < $pc; $i++) {
- if ( $profiles_list->{data}[$i][0] == 1 ) {
+ if ($profiles_list->{data}[$i][0] == 1) {
$index = $i;
}
}
- };
+ }
defined $index && $profiles_list->{data}[$index][1];
}
@@ -148,7 +148,7 @@ sub set_profile {
}
sub clone_profile() {
- my $source_profile = get_selected_profile();
+ #my $source_profile = get_selected_profile();
my $dialog = _create_dialog(N("New profile..."));
my $entry_dialog = Gtk2::Entry->new;
gtkpack($dialog->vbox,
@@ -181,7 +181,7 @@ sub delete_selected_profile() {
my $profile = get_selected_profile();
if ($profile eq $default_profile) {
my $ret = warn_dialog(N("Warning"), N("Are you sure you want to delete the default profile?"));
- return if not $ret;
+ return if !$ret;
} elsif ($profile eq $net->{PROFILE}) {
err_dialog(N("Error"), N("You can not delete the current profile. Please switch to a different profile first."));
return;
diff --git a/bin/draknfs b/bin/draknfs
index aa0d8fb..3a0cf31 100755
--- a/bin/draknfs
+++ b/bin/draknfs
@@ -118,7 +118,7 @@ sub show_file_dialog {
}
$file_dlg->hide;
$file_dlg->destroy;
-};
+}
sub get_nfs_data() {
# /home/nis *(async,rw,no_root_squash)
@@ -269,7 +269,7 @@ sub add_modify_entry {
$lsubtree_check->set_popdown_strings(@yesno);
my $button = gtknew('Button', text => N("Directory"));
- $button->signal_connect(clicked => sub { show_file_dialog($dir); });
+ $button->signal_connect(clicked => sub { show_file_dialog($dir) });
# test if modify or add a nfs share
@@ -324,8 +324,8 @@ sub add_modify_entry {
else { $lsubtree_check->set_text("yes") }
} else { next }
}
- foreach ($lsecure, $lsync) { if ($_->get_text =~ //) { $_->set_text("yes") } };
- foreach ($lr, $lsubtree_check) { if ($_->get_text =~ //) { $_->set_text("no") } };
+ foreach ($lsecure, $lsync) { if ($_->get_text =~ //) { $_->set_text("yes") } }
+ foreach ($lr, $lsubtree_check) { if ($_->get_text =~ //) { $_->set_text("no") } }
}
$luserid->signal_connect(changed => sub {
@@ -370,7 +370,7 @@ sub add_modify_entry {
$w->{window}->set_modal(1);
$w->{window}->set_position('center');
- $expender->signal_connect(activate => sub { $w->shrink_topwindow; });
+ $expender->signal_connect(activate => sub { $w->shrink_topwindow });
gtkadd($w->{window},
gtknew('VBox', spacing => 0, children_loose => [
diff --git a/bin/draksambashare b/bin/draksambashare
index 6a2a26a..14d62c9 100755
--- a/bin/draksambashare
+++ b/bin/draksambashare
@@ -183,7 +183,7 @@ sub get_items() {
[ N("/_Help") . N("/_Samba Documentation"), undef, sub {
$in->do_pkgs->ensure_is_installed('samba-doc', '/usr/share/doc/samba-doc');
- system("/usr/bin/www-browser /usr/share/doc/samba-doc/htmldocs/index.html &")
+ system("/usr/bin/www-browser /usr/share/doc/samba-doc/htmldocs/index.html &");
},
1, '<Item>', ],
@@ -255,7 +255,7 @@ sub show_file_dialog {
}
$file_dlg->hide;
$file_dlg->destroy;
-};
+}
sub get_samba_share() {
undef @listshare;
@@ -368,7 +368,7 @@ sub add_entry() {
my ($addshare_name, $addshare_comment, $addshare_dir);
$_ = Gtk2::Entry->new foreach $addshare_name, $addshare_comment, $addshare_dir;
my $button = Gtk2::Button->new(N("Open"));
- $button->signal_connect(clicked => sub { show_file_dialog($addshare_dir); });
+ $button->signal_connect(clicked => sub { show_file_dialog($addshare_dir) });
my $dialog = _create_dialog(N("DrakSamba add entry"), { transient_for => $::main_window, modal => 1 });
local $::main_window = $dialog;
@@ -565,7 +565,7 @@ sub modify_printers_entry {
$use_client_driver->set_text($printer_list->{data}[$selected][14]);
my $button = Gtk2::Button->new(N("Open"));
- $button->signal_connect(clicked => sub { show_file_dialog($dir); });
+ $button->signal_connect(clicked => sub { show_file_dialog($dir) });
my $dialog = _create_dialog(N("DrakSamba Printers entry"), { transient_for => $::main_window, modal => 1 });
@@ -685,7 +685,7 @@ sub modify_entry {
$_->set_popdown_strings(@yesno) foreach $browseable, $public, $writable, $hide_dot_files, $preserve_case, $inherit_permissions;
my $button = Gtk2::Button->new(N("Open"));
- $button->signal_connect(clicked => sub { show_file_dialog($dir); });
+ $button->signal_connect(clicked => sub { show_file_dialog($dir) });
my $w = ugtk2->new(N("DrakSamba entry"));
$w->{window}->set_modal(1);
@@ -1151,7 +1151,7 @@ sub configure_samba {
next => 'ask_log',
},
ask_log => {
- name => N("Samba Log") . "\n" . N("Log file: use file.%m to use a separate log file for each machine that connects") . "\n" . N("Log level: set the log (verbosity) level (0 <= log level <= 10)") . "\n" . N("Max Log size: put a capping on the size of the log files (in Kb)."),
+ name => N("Samba Log") . "\n" . N("Log file: use %s to use a separate log file for each machine that connects", "file.%m") . "\n" . N("Log level: set the log (verbosity) level (0 <= log level <= 10)") . "\n" . N("Max Log size: put a capping on the size of the log files (in Kb)."),
pre => sub {
$o->{var}{wiz_log_file} ||= $samba->{global}{'log file'};
$o->{var}{wiz_log_level} ||= $samba->{global}{'log level'};
@@ -1180,11 +1180,15 @@ sub configure_samba {
{ text => N(" "), advanced => 1 },
{ label => N("Unix Charset:"), val => \$o->{var}{wiz_unixcharset}, help => "Unix Charset pecifies the charset the unix machine Samba runs on uses.", advanced => 1 },
{ label => N("Dos Charset:"), val => \$o->{var}{wiz_doscharset}, help => "Dos Charset specifies which charset Samba should talk to DOS clients.", advanced => 1 },
- { label => N("Display Charset:"), val => \$o->{var}{wiz_displaycharset}, help=> "Display Charset specifies the charset that samba will use to print messages to stdout and stderr. The default value is 'LOCALE', which means automatically set, depending on the current locale.", advanced => 1 },
+ { label => N("Display Charset:"), val => \$o->{var}{wiz_displaycharset}, help => "Display Charset specifies the charset that samba will use to print messages to stdout and stderr. The default value is 'LOCALE', which means automatically set, depending on the current locale.", advanced => 1 },
],
post => sub {
$samba->{global}{workgroup} = $o->{var}{wiz_workgroup};
- $o->{var}{wiz_netbios_name} ? $samba->{global}{"netbios name"} = $o->{var}{wiz_netbios_name} : delete $samba->{global}{"netbios name"};
+ if ($o->{var}{wiz_netbios_name}) {
+ $samba->{global}{"netbios name"} = $o->{var}{wiz_netbios_name};
+ } else {
+ delete $samba->{global}{"netbios name"};
+ }
$samba->{global}{'server string'} = $o->{var}{wiz_banner};
$o->{var}{wiz_log_file} and $samba->{global}{'log file'} = $o->{var}{wiz_log_file};
$o->{var}{wiz_log_level} and $samba->{global}{'log level'} = $o->{var}{wiz_log_level};
@@ -1207,14 +1211,34 @@ sub configure_samba {
sub global_special_options() {
# set charset
- $o->{var}{wiz_doscharset} ? $samba->{global}{'dos charset'} = $o->{var}{wiz_doscharset} : delete $samba->{global}{'dos charset'};
- $o->{var}{wiz_unixcharset} ? $samba->{global}{'unix charset'} = $o->{var}{wiz_unixcharset} : delete $samba->{global}{'unix charset'};
- $o->{var}{wiz_displaycharset} ? $samba->{global}{'display charset'} = $o->{var}{wiz_displaycharset} : delete $samba->{global}{'display charset'};
- $o->{var}{wiz_security} ? $samba->{global}{security} = $o->{var}{wiz_security} : delete $samba->{global}{security};
- $o->{var}{hosts_allow} ? $samba->{global}{'hosts allow'} = $o->{var}{hosts_allow} : delete $samba->{global}{'hosts allow'};
+ if ($o->{var}{wiz_doscharset}) {
+ $samba->{global}{'dos charset'} = $o->{var}{wiz_doscharset};
+ } else {
+ delete $samba->{global}{'dos charset'};
+ }
+ if ($o->{var}{wiz_unixcharset}) {
+ $samba->{global}{'unix charset'} = $o->{var}{wiz_unixcharset};
+ } else {
+ delete $samba->{global}{'unix charset'};
+ }
+ if ($o->{var}{wiz_displaycharset}) {
+ $samba->{global}{'display charset'} = $o->{var}{wiz_displaycharset};
+ } else {
+ delete $samba->{global}{'display charset'};
+ }
+ if ($o->{var}{wiz_security}) {
+ $samba->{global}{security} = $o->{var}{wiz_security};
+ } else {
+ delete $samba->{global}{security};
+ }
+ if ($o->{var}{hosts_allow}) {
+ $samba->{global}{'hosts allow'} = $o->{var}{hosts_allow};
+ } else {
+ delete $samba->{global}{'hosts allow'};
+ }
# $samba->{global}{security} = $o->{var}{wiz_security};
# detect Samba type 3 is standalone
- if ($o->{var}{wiz_type} == "3") {
+ if ($o->{var}{wiz_type} eq "3") {
exists $samba->{global}{domain_master} and delete $samba->{global}{domain_master};
exists $samba->{global}{'domain logons'} and delete $samba->{global}{'domain logons'};
exists $samba->{global}{'wins support'} and delete $samba->{global}{'wins support'};
@@ -1237,10 +1261,7 @@ sub global_special_options() {
}
my $conf = "/etc/group";
- my @groups;
- foreach (cat_($conf)) {
- push @groups, $1 if m/^([^#:]+):[^:]+:([^:]+):/ and $2 > 499;
- }
+ my @groups = map { if_(m/^([^#:]+):[^:]+:([^:]+):/ and $2 > 499, $1) } cat_($conf);
foreach (@groups) {
system("net groupmap add unixgroup=$_ ntgroup=$_");
}
diff --git a/bin/net_applet b/bin/net_applet
index 2873679..43c692c 100755
--- a/bin/net_applet
+++ b/bin/net_applet
@@ -151,7 +151,7 @@ my %actions = (
},
'drakvpn' => {
name => N("Manage VPN connections"),
- launch => sub { run_program::raw({ detach => 1 }, '/usr/sbin/drakvpn'); },
+ launch => sub { run_program::raw({ detach => 1 }, '/usr/sbin/drakvpn') },
},
'confNetwork' => {
name => N("Configure Network"),
@@ -162,7 +162,7 @@ my %actions = (
choices => sub { N("Auto-detect"), sort keys %{$net->{ifcfg}} },
choice_selected => sub {
$watched_interface ? $_[0] eq $watched_interface :
- $_[0] eq N("Auto-detect")
+ $_[0] eq N("Auto-detect");
},
launch => sub {
$watched_interface = $_[0] eq N("Auto-detect") ? undef : $_[0];
@@ -203,14 +203,14 @@ my %actions = (
name => N("VPN connection"),
header => "drakvpn",
choices => sub {
- map { $_->get_configured_connections } network::vpn::list_types
+ map { $_->get_configured_connections } network::vpn::list_types;
},
allow_single_choice => 1,
format_choice => \&network::vpn::get_label,
choice_selected => sub { $_[0]->is_started },
launch => sub {
require interactive; $_[0]->is_started ?
- $_[0]->stop : $_[0]->start(interactive->vnew)
+ $_[0]->stop : $_[0]->start(interactive->vnew);
},
},
'help' => {
@@ -275,7 +275,7 @@ $SIG{HUP} = sub {
};
$SIG{USR1} = sub {
# clear all ifw notifications
- my @packets = eval { $network::net_applet::ifw->get_reports };
+ eval { $network::net_applet::ifw->get_reports };
};
# do not create zombies (#20552)
diff --git a/bin/net_monitor b/bin/net_monitor
index 5c27f85..eb9a37a 100755
--- a/bin/net_monitor
+++ b/bin/net_monitor
@@ -183,17 +183,17 @@ sub main_quit() {
ugtk2->exit(0);
}
-sub getcurrentintf {
+sub getcurrentintf() {
my $currp = $notebook->get_current_page;
foreach (@interfaces) {
my $intf = $_;
- return $intf if ($monitor->{$intf}{page} == $currp)
+ return $intf if $monitor->{$intf}{page} == $currp;
}
}
-sub intf_reset {
+sub intf_reset() {
# resets counters for currently selected tab
- my $intf = getcurrentintf;
+ my $intf = getcurrentintf();
if (defined $intf) {
$monitor->{$intf}{totalt} = 0;
$monitor->{$intf}{totalr} = 0;
@@ -276,7 +276,7 @@ sub connection() {
gtkflush();
- print ("Action on " . getcurrentintf() . "\n");
+ print "Action on " . getcurrentintf() . "\n";
$tool_pid =
$wasconnected == 1
@@ -300,17 +300,17 @@ sub rescan() {
# prevent for case 32 bits or 64 bits unsigned value of /proc (if rotate to zero)
if ($diffr < 0) {
if ($refr < 2**32) { # transition (2^32 - 1) to 0
- $diffr += 2**32
+ $diffr += 2**32;
} else { $diffr += 2**64 } # transition (2^64 - 1) to 0
# { $diffr = 0; $monitor->{$intf}{totalr} = 0 } # Alternatively, if bug for very big number in perl
- };
+ }
# prevent for case 32 bits or 64 bits unsigned value of /proc (if rotate to zero)
if ($difft < 0) {
if ($reft < 2**32) { # transition (2^32 - 1) to 0
- $difft += 2**32
+ $difft += 2**32;
} else { $difft += 2**64 } # transition (2^64 - 1) to 0
# { $difft = 0; $monitor->{$intf}{totalt} = 0 } # Alternatively, if bug for very big number in perl
- };
+ }
$monitor->{$intf}{totalr} += $diffr;
$monitor->{$intf}{totalt} += $difft;
@@ -448,7 +448,7 @@ sub update() {
gtknew('HBox', spacing => 5, border_width => 5, children_tight => [
color_button($gca, $colora),
N("average") ]),
- gtknew('Button', text => N("Reset counters"), sensitive => 1, clicked => sub { intf_reset })
+ gtknew('Button', text => N("Reset counters"), sensitive => 1, clicked => sub { intf_reset() })
]),
0, gtknew('VBox', border_width => 5, children_tight => [
gtknew('Frame', text => N("Local measure"), shadow_type => 'etched_out', child =>