More perl strict enforcement

This commit is contained in:
Jamie Cameron
2016-05-26 00:02:59 +02:00
parent 24cca0d258
commit f32aa17317
6 changed files with 66 additions and 50 deletions

View File

@@ -1,28 +1,27 @@
use strict;
use warnings;
require 'time-lib.pl';
our (%text);
sub acl_security_form
{
print(
"<tr>",
"<td><b>", $text{ 'acl_sys' }, "</b></td>",
"<td><input type=radio name=sysdate value=0 ", $_[0] -> { 'sysdate' } == 0 ? "checked" : "", ">", $text{ 'acl_yes' }, " <input type=radio name=sysdate value=1 ", $_[0] -> { 'sysdate' } == 1 ? "checked" : "", ">", $text{ 'acl_no' },
"</tr><tr>",
"<td><b>", $text{ 'acl_hw' }, "</b></td>",
"<td><input type=radio name=hwdate value=0 ", $_[0] -> { 'hwdate' } == 0 ? "checked" : "", ">", $text{ 'acl_yes' }, " <input type=radio name=hwdate value=1 ", $_[0] -> { 'hwdate' } == 1 ? "checked" : "", ">", $text{ 'acl_no' },
"</tr><tr>",
"<td><b>", $text{ 'acl_timezone' }, "</b></td>",
"<td><input type=radio name=timezone value=1 ", $_[0] -> { 'timezone' } == 1 ? "checked" : "", ">", $text{ 'acl_yes' }, " <input type=radio name=timezone value=0 ", $_[0] -> { 'timezone' } == 0 ? "checked" : "", ">", $text{ 'acl_no' },
"</tr><tr>",
"<td><b>", $text{ 'acl_ntp' }, "</b></td>",
"<td><input type=radio name=ntp value=1 ", $_[0] -> { 'ntp' } == 1 ? "checked" : "", ">", $text{ 'acl_yes' }, " <input type=radio name=ntp value=0 ", $_[0] -> { 'ntp' } == 0 ? "checked" : "", ">", $text{ 'acl_no' },
"</tr>\n");
my ($o) = @_;
print &ui_table_row(text{'acl_sys'},
&ui_yesno_radio("sysdate", $o->{'sysdate'}, 0, 1));
print &ui_table_row(text{'acl_hw'},
&ui_yesno_radio("hwdate", $o->{'hwdate'}, 0, 1));
print &ui_table_row(text{'acl_timezone'},
&ui_yesno_radio("timezone", $o->{'timezone'}));
print &ui_table_row(text{'acl_ntp'},
&ui_yesno_radio("ntp", $o->{'ntp'}));
}
sub acl_security_save
{
$_[0] -> { 'sysdate' } = $in{ 'sysdate' };
$_[0] -> { 'hwdate' } = $in{ 'hwdate' };
$_[0] -> { 'timezone' } = $in{ 'timezone' };
$_[0] -> { 'ntp' } = $in{ 'ntp' };
my ($o, $in) = @_;
$o->{'sysdate'} = $in->{'sysdate'};
$o->{'hwdate'} = $in->{'hwdate'};
$o->{'timezone'} = $in->{'timezone'};
$o->{'ntp'} = $in->{'ntp'};
}

View File

@@ -1,11 +1,14 @@
use strict;
use warnings;
do 'time-lib.pl';
our ($module_config_file);
# backup_config_files()
# Returns files and directories that can be backed up
sub backup_config_files
{
local @rv;
my @rv;
if (defined(&timezone_files)) {
push(@rv, &timezone_files());
}

View File

@@ -1,13 +1,17 @@
#!/usr/local/bin/perl
require "./time-lib.pl";
use strict;
use warnings;
require './time-lib.pl';
our (%in, %text, %config, %access, $base_remote_user, $get_hardware_time_error);
local ($rawdate, $rawhwdate, %system_date, $rawtime, %hw_date, $txt);
my ($rawdate, $rawhwdate, %system_date, $rawtime, %hw_date, $txt);
$txt = "";
&ReadParse();
&error( $text{ 'acl_error' } ) if( $access{ 'sysdate' } && $access{ 'hwdate' } );
&error($text{'acl_error'}) if ($access{'sysdate'} && $access{'hwdate'});
my $arr;
if (!$access{'sysdate'} && !$access{'hwdate'} && &support_hwtime()) {
$arr = "0,1";
}
@@ -26,7 +30,7 @@ if (!$access{'sysdate'} && !&has_command("date")) {
}
# Show tabs for times, timezones and syncing
@tabs = ( );
my @tabs = ( );
push(@tabs, [ "time", $text{'index_tabtime'}, "index.cgi?mode=time" ]);
if ($access{'timezone'} && &has_timezone()) {
push(@tabs, [ "zone", $text{'index_tabzone'}, "index.cgi?mode=zone" ]);
@@ -37,7 +41,7 @@ if ($access{'ntp'}) {
print &ui_tabs_start(\@tabs, "mode", $in{'mode'} || $tabs[0]->[0], 1);
# Get the system time
@tm = &get_system_time();
my @tm = &get_system_time();
$system_date{ 'second' } = $tm[0];
$system_date{ 'minute' } = $tm[1];
$system_date{ 'hour' } = $tm[2];
@@ -68,7 +72,7 @@ else
# Get the hardware time
if (&support_hwtime()) {
local @tm = &get_hardware_time();
my @tm = &get_hardware_time();
if (@tm) {
$hw_date{'second'} = $tm[0];
$hw_date{'minute'} = $tm[1];
@@ -114,11 +118,13 @@ if ($access{'timezone'} && &has_timezone()) {
print &ui_form_start("save_timezone.cgi");
print &ui_table_start($text{'index_tzheader'}, "width=100%", 2);
@zones = &list_timezones();
$cz = &get_current_timezone();
$found = 0;
@opts = ( );
foreach $z (@zones) {
my @zones = &list_timezones();
my $cz = &get_current_timezone();
my $found = 0;
my @opts = ( );
my $lastpfx;
foreach my $z (@zones) {
my $pfx;
if ($z->[0] =~ /^(.*)\/(.*)$/) {
$pfx = $1;
}
@@ -162,7 +168,7 @@ if ( ( !$access{ 'sysdate' } && &has_command( "date" ) || !$access{ 'hwdate' } &
}
# Show boot-time checkbox
$job = &find_webmin_cron_job();
my $job = &find_webmin_cron_job();
print &ui_table_row($text{'index_boot'},
&ui_yesno_radio("boot", $job && $job->{'boot'}));
@@ -192,11 +198,11 @@ print &ui_tabs_end(1);
# Output a table for setting the date and time
sub tabletime
{
my ( $label, $ro, %src ) = @_,
%assoc_day = ( "Mon", $text{ 'day_1' }, "Tue", $text{ 'day_2' }, "Wed", $text{ 'day_3' }, "Thu", $text{ 'day_4' }, "Fri", $text{ 'day_5' }, "Sat", $text{ 'day_6' }, "Sun", $text{ 'day_0' } ),
%assoc_month = ( "Jan", $text{ 'month_1' }, "Feb", $text{ 'month_2' }, "Mar", $text{ 'month_3' }, "Apr", $text{ 'month_4' }, "May", $text{ 'month_5' }, "Jun", $text{ 'month_6' }, "Jul", $text{ 'month_7' }, "Aug", $text{ 'month_8' }, "Sep", $text{ 'month_9' }, "Oct", $text{ 'month_10' }, "Nov", $text{ 'month_11' }, "Dec", $text{ 'month_12' } );
my ( $label, $ro, %src ) = @_,
my %assoc_day = ( "Mon", $text{ 'day_1' }, "Tue", $text{ 'day_2' }, "Wed", $text{ 'day_3' }, "Thu", $text{ 'day_4' }, "Fri", $text{ 'day_5' }, "Sat", $text{ 'day_6' }, "Sun", $text{ 'day_0' } ),
my %assoc_month = ( "Jan", $text{ 'month_1' }, "Feb", $text{ 'month_2' }, "Mar", $text{ 'month_3' }, "Apr", $text{ 'month_4' }, "May", $text{ 'month_5' }, "Jun", $text{ 'month_6' }, "Jul", $text{ 'month_7' }, "Aug", $text{ 'month_8' }, "Sep", $text{ 'month_9' }, "Oct", $text{ 'month_10' }, "Nov", $text{ 'month_11' }, "Dec", $text{ 'month_12' } );
$rv = &ui_table_start($label, "width=100%", 6);
my $rv = &ui_table_start($label, "width=100%", 6);
if (!$ro) {
$rv .= &ui_table_row($text{'date'},
&ui_select("date", $src{'date'}, [ 1 .. 31 ]));

View File

@@ -1,20 +1,23 @@
# log_parser.pl
# Functions for parsing this module's logs
use strict;
use warnings;
do 'time-lib.pl';
our (%text);
# parse_webmin_log(user, script, action, type, object, &params)
# Converts logged information from this module into human-readable form
sub parse_webmin_log
{
local ($user, $script, $action, $type, $object, $p, $long) = @_;
my ($user, $script, $action, $type, $object, $p, $long) = @_;
if ($action eq 'remote') {
local $tm = localtime($object);
my $tm = localtime($object);
return &text($long ? "log_remote_${type}_l" : "log_remote_${type}",
"<i>$tm</i>", "<tt>".&html_escape($p->{'timeserver'})."</tt>");
}
elsif ($action eq 'set') {
local $tm = localtime($object);
my $tm = localtime($object);
return &text("log_set_${type}", "<i>$tm</i>");
}
elsif ($action eq 'sync') {

View File

@@ -1,21 +1,24 @@
use strict;
use warnings;
require 'time-lib.pl';
our ($module_name);
# Convert existing cron job to webmin cron
sub module_install
{
if (&foreign_check("cron")) {
&foreign_require("cron", "cron-lib.pl");
local $job = &find_cron_job();
&foreign_require("cron");
my $job = &find_cron_job();
if ($job) {
$wcron = { 'module' => $module_name,
'func' => 'sync_time_cron',
'special' => $job->{'special'},
'mins' => $job->{'mins'},
'hours' => $job->{'hours'},
'days' => $job->{'days'},
'months' => $job->{'months'},
'weekdays' => $job->{'weekdays'},
my $wcron = { 'module' => $module_name,
'func' => 'sync_time_cron',
'special' => $job->{'special'},
'mins' => $job->{'mins'},
'hours' => $job->{'hours'},
'days' => $job->{'days'},
'months' => $job->{'months'},
'weekdays' => $job->{'weekdays'},
};
&webmincron::create_webmin_cron($wcron, $job->{'command'});
}

View File

@@ -1,13 +1,15 @@
# uninstall.pl
# Called when webmin is uninstalled
use strict;
use warnings;
require 'time-lib.pl';
sub module_uninstall
{
# Remove the cron job for scheduled checking
&foreign_require("cron", "cron-lib.pl");
$job = &find_cron_job();
&foreign_require("cron");
my $job = &find_cron_job();
if ($job) {
&cron::delete_cron_job($job);
}