diff options
author | Thierry Vignaud <tv@mageia.org> | 2013-03-15 18:43:07 +0000 |
---|---|---|
committer | Thierry Vignaud <tv@mageia.org> | 2013-03-15 18:43:07 +0000 |
commit | e8ffe657d1b5bd6d1266c58f0b884c3f33f42951 (patch) | |
tree | 0f15f01c91568e33006bd4611e4b46051ee0b6e4 | |
parent | 5207acfd064563d08afafaea158e3ac3d75f7f1c (diff) | |
download | drakguard-e8ffe657d1b5bd6d1266c58f0b884c3f33f42951.tar drakguard-e8ffe657d1b5bd6d1266c58f0b884c3f33f42951.tar.gz drakguard-e8ffe657d1b5bd6d1266c58f0b884c3f33f42951.tar.bz2 drakguard-e8ffe657d1b5bd6d1266c58f0b884c3f33f42951.tar.xz drakguard-e8ffe657d1b5bd6d1266c58f0b884c3f33f42951.zip |
perl_checker: fix spacing
-rwxr-xr-x | bin/drakguard | 106 |
1 files changed, 53 insertions, 53 deletions
diff --git a/bin/drakguard b/bin/drakguard index dfa7c3c..64f34b4 100755 --- a/bin/drakguard +++ b/bin/drakguard @@ -180,19 +180,19 @@ gtkadd($w->{window}, gtknew('Label', text => N("Start:")), gtknew('HBox', spacing => 2, children_tight => [ gtknew('SpinButton', lower => 0, upper => 23, step_increment => 1, value => $time_start_h, - value_changed => sub { $time_start_h = $_[0]->get_value } ), + value_changed => sub { $time_start_h = $_[0]->get_value }), gtknew('Label', text => ':'), gtknew('SpinButton', lower => 0, upper => 59, step_increment => 1, value => $time_start_m, - value_changed => sub { $time_start_m = $_[0]->get_value } ), + value_changed => sub { $time_start_m = $_[0]->get_value }), ]), gtknew('Label'), gtknew('Label', text => N("End:")), gtknew('HBox', spacing => 2, children_tight => [ gtknew('SpinButton', lower => 0, upper => 23, step_increment => 1, value => $time_stop_h, - value_changed => sub { $time_stop_h = $_[0]->get_value } ), + value_changed => sub { $time_stop_h = $_[0]->get_value }), gtknew('Label', text => ':'), gtknew('SpinButton', lower => 0, upper => 59, step_increment => 1, value => $time_stop_m, - value_changed => sub { $time_stop_m = $_[0]->get_value } ), + value_changed => sub { $time_stop_m = $_[0]->get_value }), ]), ]), ]), @@ -200,8 +200,8 @@ gtkadd($w->{window}, my $url_list = $_; $url_list->{list} = Gtk2::SimpleList->new($url_list->{list_title} => 'text'); $url_list->{list}->get_selection->set_mode('multiple'); - if ($url_list->{tab_title} eq N("Block programs")){@{$url_list->{list}{data}} = read_program_list($url_list->{file}); } - else{@{$url_list->{list}{data}} = read_url_list($url_list->{file});} + if ($url_list->{tab_title} eq N("Block programs")) { @{$url_list->{list}{data}} = read_program_list($url_list->{file}) } + else { @{$url_list->{list}{data}} = read_url_list($url_list->{file}) } $allusers_program_list = Gtk2::SimpleList->new(N("Blocked users") => 'text'); $allusers_program_list->get_selection->set_mode('multiple'); @@ -209,7 +209,7 @@ gtkadd($w->{window}, $users_program_list = Gtk2::SimpleList->new(N("Allowed users") => 'text'); $users_program_list->get_selection->set_mode('multiple'); - @{$users_program_list->{data}} = sort (read_program_user_list($url_list->{file})); + @{$users_program_list->{data}} = sort(read_program_user_list($url_list->{file})); my $entry; my $original_entry; @@ -220,7 +220,7 @@ gtkadd($w->{window}, gtknew('VBox', if_($url_list->{tab_title} eq N("Whitelist"), sensitive_ref => \$net_control_state), if_($url_list->{tab_title} eq N("Blacklist"), sensitive_ref => \$not_net_control), spacing => 5, children => [ 0, gtknew('HBox', children_tight => [ - if_($url_list->{tab_title} eq N("Block programs"),gtknew('CheckButton', text => N("Block defined applications"), + if_($url_list->{tab_title} eq N("Block programs"), gtknew('CheckButton', text => N("Block defined applications"), sensitive_ref => \$acl_state, active_ref => \$program_control, toggled => \&update_program_state)), ]), 0, gtknew('HBox', if_($url_list->{tab_title} eq N("Block programs"), sensitive_ref => \$program_control_state), border_width => 5, spacing => 5, children_loose => [ @@ -237,18 +237,18 @@ gtkadd($w->{window}, $text =~ s,(\W?)$,,g; #- remove unknown caracters $original_entry = ""; $text = resolve_symlinks($text); - if ( (grep { $_ && m/^\[Desktop Entry\]\s*/g} chomp_(cat_($text))) || $text =~ m/\.desktop/g) {# make this only for application block - my @exec_line = grep { $_ && m/^Exec=(.*)\s*/g} chomp_(cat_($text)); + if ((grep { $_ && m/^\[Desktop Entry\]\s*/g } chomp_(cat_($text))) || $text =~ m/\.desktop/g) {# make this only for application block + my @exec_line = grep { $_ && m/^Exec=(.*)\s*/g } chomp_(cat_($text)); require lang; my $locale = lang::read(); $locale = lc($locale->{country}); - my @system_name = grep { $_ && m/^GenericName(\[$locale\])?=(.*)\s*/g} chomp_(cat_($text)); - foreach (@exec_line){ + my @system_name = grep { $_ && m/^GenericName(\[$locale\])?=(.*)\s*/g } chomp_(cat_($text)); + foreach (@exec_line) { ($exec, $text, $args) = /(^Exec=)(\w+)\s*(.*)/; - if ($text eq ""){ - ($exec, $text, $args) = /(^Exec=)(.*+)\s*(.*)/;} + if ($text eq "") { + ($exec, $text, $args) = /(^Exec=)(.*+)\s*(.*)/ } } - foreach my $b (@system_name){ + foreach my $b (@system_name) { $original_entry = $b; $original_entry =~ s/^GenericName(\[$locale\])?=//g; $original_entry = Encode::decode("utf8", $original_entry); @@ -257,12 +257,12 @@ gtkadd($w->{window}, $text = `which $text 2> /dev/null` if $text ne ""; $text =~ s/\n//g; } - if ( $text eq "" && $url_list->{tab_title} eq N("Block programs")) { $in->ask_warn(N("Error"), N("Invalid Binary Name")) and return; } + if ($text eq "" && $url_list->{tab_title} eq N("Block programs")) { $in->ask_warn(N("Error"), N("Invalid Binary Name")) and return } else { if ($url_list->{tab_title} eq N("Block programs")) { - list_add_entry_program($url_list->{list}, $text. " ( $original_entry )") if $original_entry ne ""; + list_add_entry_program($url_list->{list}, $text . " ( $original_entry )") if $original_entry ne ""; list_add_entry_program($url_list->{list}, $text) if $original_entry eq ""; } - else { list_add_entry($url_list->{list}, $text); } + else { list_add_entry($url_list->{list}, $text) } } $entry->set_text(""); }), @@ -296,15 +296,15 @@ gtkadd($w->{window}, ); $w->show; -if ( (grep {$_ && !/acl/} chomp_(cat_($fstab_file)) && grep {$_ && m/ext/} chomp_(cat_($fstab_file)))) { +if ((grep { $_ && !/acl/ } chomp_(cat_($fstab_file)) && grep { $_ && m/ext/ } chomp_(cat_($fstab_file)))) { $acl_active = 1; $in->ask_yesorno(N("Warning"), N("The support for Access Control Lists must be enabled in order to use the Block programs feature.\nDo you want to enable it now?", $acl_active = 1)) or $acl_active = 0; if ($acl_active) { - my @ext_lines = grep {$_ && m/ext/} chomp_(cat_($fstab_file)); - foreach my $line (@ext_lines){ - my ($id, $directory, $flag, $number) = $line=~ /^(.+)\s(.+)\s(ext(\w)\s(\w*))\s(.*)/ or next; + my @ext_lines = grep { $_ && m/ext/ } chomp_(cat_($fstab_file)); + foreach my $line (@ext_lines) { + my ($id, $directory, $flag, $number) = $line =~ /^(.+)\s(.+)\s(ext(\w)\s(\w*))\s(.*)/ or next; $line =~ s/ext(\w)\s(\w*)\s/$flag,acl /g; - subst_config_line($fstab_file,"$line\n"); #adds ,acl in the fstab file in the first run + subst_config_line($fstab_file, "$line\n"); #adds ,acl in the fstab file in the first run # remount filesystem with acl parameter } $acl_active = 0; @@ -313,10 +313,10 @@ if ( (grep {$_ && !/acl/} chomp_(cat_($fstab_file)) && grep {$_ && m/ext/} chomp } else { my @mount = `mount`; - if (grep (/,acl/, @mount)) { + if (grep { /,acl/ } @mount) { $acl_active = 1; } else { - $in->ask_warn(N("Warning"), N("The support for Access Control Lists, required by the Block programs feature, is enabled, but not yet activated.") . N("It is necessary to restart your computer to activate it."), $acl_active = 0);} + $in->ask_warn(N("Warning"), N("The support for Access Control Lists, required by the Block programs feature, is enabled, but not yet activated.") . N("It is necessary to restart your computer to activate it."), $acl_active = 0) } } update_time_change; Gtk2->main; @@ -336,9 +336,9 @@ sub list_add_entry_program { foreach my $a (@addr) { $b = $a; $a =~ s/\s(.*)//g; - my @abc = map {$_->[0]} @{$list->{data}}; + my @abc = map { $_->[0] } @{$list->{data}}; push @{$list->{data}}, $b - unless (any { $_->[0] eq $b } @{$list->{data}}) || (grep {$_ && m/$a(.*)/g} @abc); + unless (any { $_->[0] eq $b } @{$list->{data}}) || (grep { $_ && m/$a(.*)/g } @abc); } } @@ -438,7 +438,7 @@ sub save() { int($_->[0]/60), $_->[0]%60, int($_->[1]/60), $_->[1]%60, ); - } ($drop_stop >= $drop_start ? [ $drop_start, $drop_stop] : ([ 0, $drop_stop ], [ $drop_start, $day_time-1 ])); + } ($drop_stop >= $drop_start ? [ $drop_start, $drop_stop ] : ([ 0, $drop_stop ], [ $drop_start, $day_time-1 ])); #- if allowing start time is before allowing stop time, #- we have to use two intervals to cover the completary parts of the day } qw(net2fw fw2net)), @@ -515,25 +515,25 @@ sub set_permissions { my ($line, $line_info) = @_; #`protect $line --add`; chmod 0700, $line; - chown "root","root", $line; + chown "root", "root", $line; #remove msec lines #clean_config_line($msec_conf,"$line"); - subst_config_line($dansguardian_protected_program_list,"$line_info \n"); #adds the file to dansguardian_protected_program_list - subst_config_line($msec_conf,"$line\troot.root\t700\tforce\t\n"); #adds the file to msec + subst_config_line($dansguardian_protected_program_list, "$line_info \n"); #adds the file to dansguardian_protected_program_list + subst_config_line($msec_conf, "$line\troot.root\t700\tforce\t\n"); #adds the file to msec #`protect $line $_` foreach list_get_entries($users_program_list); #add msec line or lines... foreach my $user_msec (list_get_entries($users_program_list)) { - my @msec_line = grep { $_ && m/$line/g} chomp_(cat_($msec_conf)); - my @program_list_line = grep { $_ && m/^$line/g} chomp_(cat_($dansguardian_protected_program_list)); + my @msec_line = grep { $_ && m/$line/g } chomp_(cat_($msec_conf)); + my @program_list_line = grep { $_ && m/^$line/g } chomp_(cat_($dansguardian_protected_program_list)); `setfacl -m u:$user_msec:r-x $line`; - subst_config_line($dansguardian_protected_program_list,"$_$user_msec,\n") foreach @program_list_line; #adds the users to the programs blocked in msec - subst_config_line($msec_conf,"$_$user_msec:r-x,\n") foreach @msec_line; #adds the users to the programs blocked in msec + subst_config_line($dansguardian_protected_program_list, "$_$user_msec,\n") foreach @program_list_line; #adds the users to the programs blocked in msec + subst_config_line($msec_conf, "$_$user_msec:r-x,\n") foreach @msec_line; #adds the users to the programs blocked in msec } } sub restore_permissions { my ($line) = @_; - foreach ($line){ + foreach ($line) { my ($fich, $usrname, $grpname, $mode) = /^(.*)\t(\w+)\.(\w+)\t(\d+)\s*/ or next; $mode = sprintf "%04d", $mode;#make number with 4 digits my $guid = getgrnam($grpname); @@ -622,7 +622,7 @@ sub write_dansguardian() { sub include_guardian_file { my ($guardian_file, $external_file) = @_; my $to_add = ".Include<$external_file>\n"; - clean_config_line($guardian_file, "$to_add" ); + clean_config_line($guardian_file, "$to_add"); my @all = cat_($guardian_file); if ((($dansguardian_bannedsitelist eq $guardian_file) && !$net_control) || (($dansguardian_exceptionsitelist eq $guardian_file) && $net_control)) { if (!member($to_add, @all)) { @@ -644,8 +644,8 @@ sub read_program_list { sub read_program_user_list { my ($file) = @_; my @user_list = grep { $_ && s/(.*?)\s//g } chomp_(cat_($file)); - uniq(map{ my $user = $_; - $user =~ m/(\w+),/g;} @user_list); + uniq(map { my $user = $_; + $user =~ m/(\w+),/g } @user_list); } sub apply_blacklist { @@ -670,12 +670,12 @@ sub apply_block_program { if ($program_control) { my @original_list = read_program_list(@url_lists[2]->{file}); my @orig_list = read_program_list(@url_lists[2]->{file}); - for (@original_list){ + for (@original_list) { s/\s(.*)//; } my @actual_list = list_get_entries(@url_lists[2]->{list}); my @act_list = list_get_entries(@url_lists[2]->{list}); - for (@actual_list){ + for (@actual_list) { s/\s(.*)//; } #code to make diff bettween vectors @@ -698,7 +698,7 @@ sub apply_block_program { my @msec_program = grep { $_ && m/$diff/g } chomp_(cat_($msec_conf)); if (scalar(@progs_orig_file)) {#test if is to remove or to add acl #clean config file of the removed programs - foreach $element (@progs_orig_file){ + foreach $element (@progs_orig_file) { my $val = $element; substInFile { s|$element.*\n||; @@ -709,21 +709,21 @@ sub apply_block_program { #write back in the msec file and set original file permissions #`unprotect $diff --remove`; remove_acl($dansguardian_protected_program_list, $diff); - subst_config_line($msec_conf,"$element\n"); + subst_config_line($msec_conf, "$element\n"); restore_permissions($element); } else { #only make the permissions wright #`unprotect $diff --remove`; remove_acl($dansguardian_protected_program_list, $diff); - clean_config_line($msec_conf,"$diff"); + clean_config_line($msec_conf, "$diff"); restore_permissions($element); } } } else { - if (scalar(@msec_program)){ - output_p($perms_orig, @orig_file, "1\t".$_."\n") foreach @msec_program; + if (scalar(@msec_program)) { + output_p($perms_orig, @orig_file, "1\t" . $_ . "\n") foreach @msec_program; #add file to msec and set acls } else { @@ -738,20 +738,20 @@ sub apply_block_program { #keep the permissons safe make the way to do that output_p($perms_orig, @orig_file, $to_add); } - set_permissions($diff, grep {$_ && m/$diff/g} @act_list); + set_permissions($diff, grep { $_ && m/$diff/g } @act_list); } } } #this is just the case to reactivate the parental control #`unprotect $_ --remove` foreach @intersection; remove_acl($dansguardian_protected_program_list, $_) foreach @intersection; - foreach my $intersec (@intersection){ - set_permissions($intersec, grep {$_ && m/$intersec/g} @orig_list); + foreach my $intersec (@intersection) { + set_permissions($intersec, grep { $_ && m/$intersec/g } @orig_list); } } else { my @original_list = list_get_entries(@url_lists[2]->{list}); - for (@original_list){ + for (@original_list) { s/\s(.*)//; } #restore the original file permissions @@ -761,18 +761,18 @@ sub apply_block_program { #test if program is in msec if (scalar(@progs_orig_file)) { #clean config file of the removed programs - foreach my $element (@progs_orig_file){ + foreach my $element (@progs_orig_file) { my $val = $element; $val =~ s/\t(.*)\s*//; $element =~ s/^(\d+)\t//; if ($val) { #write back in the msec file and set original file permissions - subst_config_line($msec_conf,"$element\n"); + subst_config_line($msec_conf, "$element\n"); restore_permissions($element); } else { #only make the permissions wright - clean_config_line($msec_conf,"$list"); + clean_config_line($msec_conf, "$list"); restore_permissions($element); } } |