From 407ce7ea10735e9f2947ba7985c3bd68d5067798 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Fri, 29 Apr 2011 19:50:36 -0700 Subject: [PATCH] Make all code strict and warnings compliant --- change-user/acl_security.pl | 3 +++ change-user/change-user-lib.pl | 9 ++++++--- change-user/change.cgi | 16 ++++++++++------ change-user/index.cgi | 27 ++++++++++++++++----------- 4 files changed, 35 insertions(+), 20 deletions(-) diff --git a/change-user/acl_security.pl b/change-user/acl_security.pl index 8e653bc7d..da3efadef 100755 --- a/change-user/acl_security.pl +++ b/change-user/acl_security.pl @@ -1,5 +1,8 @@ +use strict; +use warnings; do 'change-user-lib.pl'; +our (%text, %in); # acl_security_form(&options) # Output HTML for editing security options for the acl module diff --git a/change-user/change-user-lib.pl b/change-user/change-user-lib.pl index 8650c1fc8..ba219b9ee 100755 --- a/change-user/change-user-lib.pl +++ b/change-user/change-user-lib.pl @@ -6,11 +6,13 @@ say here. =cut BEGIN { push(@INC, ".."); }; +use strict; +use warnings; use WebminCore; &init_config(); &foreign_require("acl", "acl-lib.pl"); &foreign_require("webmin", "webmin-lib.pl"); -%access = &get_module_acl(); +my %access = &get_module_acl(); =head2 can_change_pass(&user) @@ -19,7 +21,8 @@ Returns 1 if some user's password can be changed. =cut sub can_change_pass { -return $_[0]->{'pass'} ne 'x' && $_[0]->{'pass'} ne 'e' && !$_[0]{'sync'} && - $_[0]->{'pass'} ne "*LK*"; +my ($user) = @_; +return $user->{'pass'} ne 'x' && $user->{'pass'} ne 'e' && !$user->{'sync'} && + $user->{'pass'} ne "*LK*"; } diff --git a/change-user/change.cgi b/change-user/change.cgi index 8b4d487c1..bfe917fd3 100755 --- a/change-user/change.cgi +++ b/change-user/change.cgi @@ -2,13 +2,16 @@ # change.cgi # Make all the changes, and re-direct to / in case the theme has changed +use strict; +use warnings; require './change-user-lib.pl'; +our (%text, %in, %gconfig, $base_remote_user, %access); &ReadParse(); -@users = &acl::list_users(); -($user) = grep { $_->{'name'} eq $base_remote_user } @users; -$oldtheme = $user->{'theme'}; -$oldoverlay = $user->{'overlay'}; +my @users = &acl::list_users(); +my ($user) = grep { $_->{'name'} eq $base_remote_user } @users; +my $oldtheme = $user->{'theme'}; +my $oldoverlay = $user->{'overlay'}; if (!defined($oldtheme)) { ($oldtheme, $oldoverlay) = split(/\s+/, $gconfig{'theme'}); } @@ -18,7 +21,7 @@ if ($access{'pass'} && &can_change_pass($user) && !$in{'pass_def'}) { $in{'pass'} =~ /:/ && &error($text{'change_ecolon'}); $in{'pass'} eq $in{'pass2'} || &error($text{'change_epass2'}); - $perr = &acl::check_password_restrictions( + my $perr = &acl::check_password_restrictions( $user->{'name'}, $in{'pass'}); &error(&text('change_epass', $perr)) if ($perr); } @@ -34,6 +37,7 @@ if ($access{'lang'}) { } # Parse custom theme and possibly overlay +my ($newoverlay, $newtheme); if ($access{'theme'}) { if ($in{'theme_def'}) { $user->{'theme'} = undef; @@ -54,7 +58,7 @@ if ($access{'theme'}) { else { $newoverlay = $in{'overlay'}; $user->{'theme'} || &error($text{'change_eoverlay'}); - %oinfo = &get_theme_info($in{'overlay'}); + my %oinfo = &get_theme_info($in{'overlay'}); if ($oinfo{'overlays'} && &indexof($user->{'theme'}, split(/\s+/, $oinfo{'overlays'})) < 0) { diff --git a/change-user/index.cgi b/change-user/index.cgi index 36e324b9f..ee429c38e 100755 --- a/change-user/index.cgi +++ b/change-user/index.cgi @@ -2,16 +2,20 @@ # index.cgi # Display the user's current language, theme and password +use strict; +use warnings; require './change-user-lib.pl'; +our (%text, %access, $base_remote_user, $default_lang, %gconfig); &ui_print_header(undef, $text{'index_title'}, "", undef, 0, 1); -@users = &acl::list_users(); -($user) = grep { $_->{'name'} eq $base_remote_user } @users; +my @users = &acl::list_users(); +my ($user) = grep { $_->{'name'} eq $base_remote_user } @users; +my @can; push(@can, 'lang') if ($access{'lang'}); push(@can, 'theme') if ($access{'theme'}); push(@can, 'pass') if ($access{'pass'} && &can_change_pass($user)); -$can = &text('index_d'.scalar(@can), map { $text{'index_d'.$_} } @can); +my $can = &text('index_d'.scalar(@can), map { $text{'index_d'.$_} } @can); print &text('index_desc2', $can),"

\n"; print &ui_form_start("change.cgi", "post"); @@ -19,9 +23,9 @@ print &ui_table_start(undef, undef, 2); if ($access{'lang'}) { # Show personal language - @langs = &list_languages(); - $glang = $gconfig{"lang"} || $default_lang; - ($linfo) = grep { $_->{'lang'} eq $glang } @langs; + my @langs = &list_languages(); + my $glang = $gconfig{"lang"} || $default_lang; + my ($linfo) = grep { $_->{'lang'} eq $glang } @langs; print &ui_table_row($text{'index_lang'}, &ui_radio("lang_def", $user->{'lang'} ? 0 : 1, [ [ 1, &text('index_langglobal', @@ -35,17 +39,18 @@ if ($access{'lang'}) { if ($access{'theme'}) { # Show personal theme + my $tname; if ($gconfig{'theme'}) { - ($gtheme, $goverlay) = split(/\s+/, $gconfig{'theme'}); - %tinfo = &webmin::get_theme_info($gtheme); + my ($gtheme, $goverlay) = split(/\s+/, $gconfig{'theme'}); + my %tinfo = &webmin::get_theme_info($gtheme); $tname = $tinfo{'desc'}; } else { $tname = $text{'index_themedef'}; } - @all = &webmin::list_themes(); - @themes = grep { !$_->{'overlay'} } @all; - @overlays = grep { $_->{'overlay'} } @all; + my @all = &webmin::list_themes(); + my @themes = grep { !$_->{'overlay'} } @all; + my @overlays = grep { $_->{'overlay'} } @all; # Main theme print &ui_table_row($text{'index_theme'},