mirror of
https://github.com/webmin/webmin.git
synced 2026-02-04 22:52:14 +00:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3fe4bc337a | ||
|
|
320d63ba2a | ||
|
|
4d79a24158 | ||
|
|
a53b6d96ca | ||
|
|
b0c779923f | ||
|
|
f32aa17317 | ||
|
|
24cca0d258 | ||
|
|
52af4d489a | ||
|
|
262bbd3e03 |
2
README
2
README
@@ -1,4 +1,4 @@
|
||||
Webmin Version 1.800
|
||||
Webmin Version 1.801
|
||||
--------------------
|
||||
Webmin is a web-based interface for system administration for Unix.
|
||||
Using any browser that supports tables and forms, you can setup user
|
||||
|
||||
@@ -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'};
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
# Functions for getting and setting the timezone on Linux
|
||||
|
||||
$timezones_file = "/usr/share/zoneinfo/zone.tab";
|
||||
$currentzone_link = "/etc/localtime";
|
||||
$timezones_dir = "/usr/share/zoneinfo";
|
||||
use strict;
|
||||
use warnings;
|
||||
our $timezones_file = "/usr/share/zoneinfo/zone.tab";
|
||||
our $currentzone_link = "/etc/localtime";
|
||||
our $timezones_dir = "/usr/share/zoneinfo";
|
||||
|
||||
# list_timezones()
|
||||
sub list_timezones
|
||||
{
|
||||
local @rv;
|
||||
&open_readfile(ZONE, $timezones_file) || return ( );
|
||||
while(<ZONE>) {
|
||||
my @rv;
|
||||
my $fh = "ZONE";
|
||||
&open_readfile($fh, $timezones_file) || return ( );
|
||||
while(<$fh>) {
|
||||
s/\r|\n//g;
|
||||
s/^\s*#.*$//;
|
||||
if (/^(\S+)\s+(\S+)\s+(\S+)\s+(\S.*)/) {
|
||||
@@ -19,14 +22,14 @@ while(<ZONE>) {
|
||||
push(@rv, [ $3, undef ]);
|
||||
}
|
||||
}
|
||||
close(ZONE);
|
||||
close($fh);
|
||||
return sort { $a->[0] cmp $b->[0] } @rv;
|
||||
}
|
||||
|
||||
# get_current_timezone()
|
||||
sub get_current_timezone
|
||||
{
|
||||
local $lnk = readlink(&translate_filename($currentzone_link));
|
||||
my $lnk = readlink(&translate_filename($currentzone_link));
|
||||
if ($lnk) {
|
||||
# Easy - it a link
|
||||
$lnk =~ s/$timezones_dir\///;
|
||||
@@ -41,9 +44,10 @@ else {
|
||||
# set_current_timezone(zone)
|
||||
sub set_current_timezone
|
||||
{
|
||||
my ($zone) = @_;
|
||||
&lock_file($currentzone_link);
|
||||
unlink(&translate_filename($currentzone_link));
|
||||
symlink(&translate_filename("$timezones_dir/$_[0]"),
|
||||
symlink(&translate_filename("$timezones_dir/$zone"),
|
||||
&translate_filename($currentzone_link));
|
||||
&unlock_file($currentzone_link);
|
||||
}
|
||||
|
||||
@@ -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 ]));
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
# Functions for getting and setting the timezone on Linux
|
||||
|
||||
$timezones_file = "/usr/share/zoneinfo/zone.tab";
|
||||
$currentzone_link = "/etc/localtime";
|
||||
$currentzone_file = "/etc/timezone";
|
||||
$timezones_dir = "/usr/share/zoneinfo";
|
||||
$sysclock_file = "/etc/sysconfig/clock";
|
||||
use strict;
|
||||
use warnings;
|
||||
our $timezones_file = "/usr/share/zoneinfo/zone.tab";
|
||||
our $currentzone_link = "/etc/localtime";
|
||||
our $currentzone_file = "/etc/timezone";
|
||||
our $timezones_dir = "/usr/share/zoneinfo";
|
||||
our $sysclock_file = "/etc/sysconfig/clock";
|
||||
|
||||
# list_timezones()
|
||||
sub list_timezones
|
||||
{
|
||||
local @rv;
|
||||
local %done;
|
||||
&open_readfile(ZONE, $timezones_file) || return ( );
|
||||
while(<ZONE>) {
|
||||
my @rv;
|
||||
my %done;
|
||||
my $fh = "ZONE";
|
||||
&open_readfile($fh, $timezones_file) || return ( );
|
||||
while(<$fh>) {
|
||||
s/\r|\n//g;
|
||||
s/^\s*#.*$//;
|
||||
if (/^(\S+)\s+(\S+)\s+(\S+)\s+(\S.*)/) {
|
||||
@@ -24,7 +27,7 @@ while(<ZONE>) {
|
||||
$done{$3}++;
|
||||
}
|
||||
}
|
||||
close(ZONE);
|
||||
close($fh);
|
||||
push(@rv, [ "GMT", "GMT" ]) if (!$done{'GMT'});
|
||||
push(@rv, [ "UTC", "UTC" ]) if (!$done{'UTC'});
|
||||
return sort { $a->[0] cmp $b->[0] } @rv;
|
||||
@@ -33,7 +36,7 @@ return sort { $a->[0] cmp $b->[0] } @rv;
|
||||
# get_current_timezone()
|
||||
sub get_current_timezone
|
||||
{
|
||||
local $lnk = readlink(&translate_filename($currentzone_link));
|
||||
my $lnk = readlink(&translate_filename($currentzone_link));
|
||||
if ($lnk) {
|
||||
# Easy - it a link
|
||||
$lnk =~ s/^\.\.//;
|
||||
@@ -49,22 +52,24 @@ else {
|
||||
# set_current_timezone(zone)
|
||||
sub set_current_timezone
|
||||
{
|
||||
my ($zone) = @_;
|
||||
&lock_file($currentzone_link);
|
||||
unlink(&translate_filename($currentzone_link));
|
||||
symlink(&translate_filename("$timezones_dir/$_[0]"),
|
||||
symlink(&translate_filename("$timezones_dir/$zone"),
|
||||
&translate_filename($currentzone_link));
|
||||
&unlock_file($currentzone_link);
|
||||
|
||||
if (-r $currentzone_file) {
|
||||
# This file is used on Debian systems
|
||||
&open_lock_tempfile(FILE, ">$currentzone_file");
|
||||
&print_tempfile(FILE, $_[0],"\n");
|
||||
&close_tempfile(FILE);
|
||||
my $fh = "FILE";
|
||||
&open_lock_tempfile($fh, ">$currentzone_file");
|
||||
&print_tempfile($fh, $zone,"\n");
|
||||
&close_tempfile($fh);
|
||||
}
|
||||
|
||||
local %clock;
|
||||
my %clock;
|
||||
if (&read_env_file($sysclock_file, \%clock)) {
|
||||
$clock{'ZONE'} = $_[0];
|
||||
$clock{'ZONE'} = $zone;
|
||||
&lock_file($sysclock_file);
|
||||
&write_env_file($sysclock_file, \%clock);
|
||||
&unlock_file($sysclock_file);
|
||||
@@ -78,7 +83,7 @@ return -r $timezones_file;
|
||||
|
||||
sub timezone_files
|
||||
{
|
||||
local @rv = ( $currentzone_link );
|
||||
my @rv = ( $currentzone_link );
|
||||
push(@rv, $currentzone_file) if (-r $currentzone_file);
|
||||
push(@rv, $sysclock_file) if (-r $sysclock_file);
|
||||
return @rv;
|
||||
|
||||
@@ -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, ¶ms)
|
||||
# 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') {
|
||||
|
||||
@@ -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'});
|
||||
}
|
||||
|
||||
@@ -1,35 +1,39 @@
|
||||
# Functions for getting and setting the timezone on Linux
|
||||
|
||||
$timezone_file = "/etc/TIMEZONE";
|
||||
$timezones_dir = "/usr/share/lib/zoneinfo";
|
||||
$rtc_config = "/etc/rtc_config";
|
||||
use strict;
|
||||
use warnings;
|
||||
our $timezone_file = "/etc/TIMEZONE";
|
||||
our $timezones_dir = "/usr/share/lib/zoneinfo";
|
||||
our $rtc_config = "/etc/rtc_config";
|
||||
|
||||
# list_timezones()
|
||||
sub list_timezones
|
||||
{
|
||||
local @rv;
|
||||
local $file;
|
||||
&open_execute_command(FIND, "find $timezones_dir -type f", 1);
|
||||
while($file = <FIND>) {
|
||||
my @rv;
|
||||
my $file;
|
||||
my $fh = "FIND";
|
||||
&open_execute_command($fh, "find $timezones_dir -type f", 1);
|
||||
while($file = <$fh>) {
|
||||
chop($file);
|
||||
local $buf;
|
||||
&open_readfile(INFO, $file);
|
||||
read(INFO, $buf, 2);
|
||||
close(INFO);
|
||||
my $buf;
|
||||
my $fh2 = "INFO";
|
||||
&open_readfile($fh2, $file);
|
||||
read($fh2, $buf, 2);
|
||||
close($fh2);
|
||||
if ($buf eq "TZ") {
|
||||
# A timezone file we can use!
|
||||
$file =~ s/^$timezones_dir\///;
|
||||
push(@rv, [ $file, undef ]);
|
||||
}
|
||||
}
|
||||
close(FIND);
|
||||
close($fh);
|
||||
return sort { $a->[0] cmp $b->[0] } @rv;
|
||||
}
|
||||
|
||||
# get_current_timezone()
|
||||
sub get_current_timezone
|
||||
{
|
||||
local %tz;
|
||||
my %tz;
|
||||
&read_env_file($timezone_file, \%tz);
|
||||
$tz{'TZ'} =~ s/^://;
|
||||
return $tz{'TZ'};
|
||||
@@ -38,7 +42,7 @@ return $tz{'TZ'};
|
||||
# set_current_timezone(zone)
|
||||
sub set_current_timezone
|
||||
{
|
||||
local %tz;
|
||||
my %tz;
|
||||
&lock_file($timezone_file);
|
||||
&read_env_file($timezone_file, \%tz);
|
||||
$tz{'TZ'} = $_[0];
|
||||
@@ -48,7 +52,7 @@ $tz{'TZ'} = $_[0];
|
||||
if (-r $rtc_config) {
|
||||
# Update x86 RTC timezone too
|
||||
&lock_file($rtc_config);
|
||||
local %rtc;
|
||||
my %rtc;
|
||||
&read_env_file($rtc_config, \%rtc);
|
||||
$rtc{'zone_info'} = $_[0];
|
||||
&write_env_file($rtc_config, \%rtc);
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
#!/usr/local/bin/perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
BEGIN { push(@INC, ".."); };
|
||||
use WebminCore;
|
||||
&init_config();
|
||||
%access = &get_module_acl();
|
||||
$cron_cmd = "$module_config_directory/sync.pl";
|
||||
our %access = &get_module_acl();
|
||||
our ($module_config_directory, $module_name, %text, %config, %gconfig);
|
||||
our ($timezones_file, $currentzone_link, $currentzone_file, $timezones_dir,
|
||||
$sysclock_file);
|
||||
our ($get_hardware_time_error);
|
||||
our $cron_cmd = "$module_config_directory/sync.pl";
|
||||
if ($config{'zone_style'}) {
|
||||
do "$config{'zone_style'}-lib.pl";
|
||||
}
|
||||
@@ -13,8 +19,8 @@ if ($config{'zone_style'}) {
|
||||
sub find_cron_job
|
||||
{
|
||||
&foreign_require("cron", "cron-lib.pl");
|
||||
local @jobs = &cron::list_cron_jobs();
|
||||
local ($job) = grep { $_->{'command'} eq $cron_cmd &&
|
||||
my @jobs = &cron::list_cron_jobs();
|
||||
my ($job) = grep { $_->{'command'} eq $cron_cmd &&
|
||||
$_->{'user'} eq 'root' } @jobs;
|
||||
return $job;
|
||||
}
|
||||
@@ -29,9 +35,10 @@ return &webmincron::find_webmin_cron($module_name, 'sync_time_cron');
|
||||
# on success, or an error message on failure.
|
||||
sub sync_time
|
||||
{
|
||||
local @servs = split(/\s+/, $_[0]);
|
||||
local $servs = join(" ", map { quotemeta($_) } @servs);
|
||||
local $out;
|
||||
my ($server, $hwtoo) = @_;
|
||||
my @servs = split(/\s+/, $server);
|
||||
my $servs = join(" ", map { quotemeta($_) } @servs);
|
||||
my $out;
|
||||
if (&has_command("ntpdate")) {
|
||||
$out = &backquote_logged("ntpdate -u $servs 2>&1");
|
||||
}
|
||||
@@ -48,12 +55,14 @@ if ($? && $config{'ntp_only'}) {
|
||||
}
|
||||
elsif ($?) {
|
||||
# error using ntp. use timeservice
|
||||
local ($err, $serv);
|
||||
my ($err, $serv);
|
||||
my $rawtime;
|
||||
foreach $serv (@servs) {
|
||||
$err = undef;
|
||||
&open_socket($serv, 37, SOCK, \$err);
|
||||
read(SOCK, $rawtime, 4);
|
||||
close(SOCK);
|
||||
my $fh = "SOCK";
|
||||
&open_socket($serv, 37, $fh, \$err);
|
||||
read($fh, $rawtime, 4);
|
||||
close($fh);
|
||||
last if (!$err && $rawtime);
|
||||
}
|
||||
return $err if ($err);
|
||||
@@ -61,22 +70,19 @@ elsif ($?) {
|
||||
# Got a time .. set it
|
||||
$rawtime = unpack("N", $rawtime);
|
||||
$rawtime -= (17 * 366 + 53 * 365) * 24 * 60 * 60;
|
||||
local $diff = abs(time() - $rawtime);
|
||||
my $diff = abs(time() - $rawtime);
|
||||
if ($diff > 365*24*60*60) {
|
||||
# Too big!
|
||||
return &text('error_ediff', int($diff/(24*60*60)));
|
||||
}
|
||||
@tm = localtime($rawtime);
|
||||
my @tm = localtime($rawtime);
|
||||
&set_system_time(@tm);
|
||||
}
|
||||
else {
|
||||
$rawtime = time();
|
||||
}
|
||||
|
||||
if ($_[1]) {
|
||||
if ($hwtoo) {
|
||||
# Set hardware clock time to match system time (which is now correct)
|
||||
local $flags = &get_hwclock_flags();
|
||||
local $out = &backquote_logged("hwclock $flags --systohc");
|
||||
my $flags = &get_hwclock_flags();
|
||||
my $out = &backquote_logged("hwclock $flags --systohc");
|
||||
return $? ? $out : undef;
|
||||
}
|
||||
|
||||
@@ -98,7 +104,7 @@ if (defined(&os_has_timezones)) {
|
||||
return &os_has_timezones();
|
||||
}
|
||||
else {
|
||||
local @zones = &list_timezones();
|
||||
my @zones = &list_timezones();
|
||||
return @zones ? 1 : 0;
|
||||
}
|
||||
}
|
||||
@@ -107,13 +113,13 @@ else {
|
||||
# Finds an identical timezone file to the one specified
|
||||
sub find_same_zone
|
||||
{
|
||||
local @st = stat(&translate_filename($_[0]));
|
||||
local $z;
|
||||
my @st = stat(&translate_filename($_[0]));
|
||||
my $z;
|
||||
foreach $z (&list_timezones()) {
|
||||
local $zf = &translate_filename("$timezones_dir/$z->[0]");
|
||||
local @zst = stat($zf);
|
||||
my $zf = &translate_filename("$timezones_dir/$z->[0]");
|
||||
my @zst = stat($zf);
|
||||
if ($zst[7] == $st[7]) {
|
||||
local $ex = system("diff ".&translate_filename($currentzone_link)." $zf >/dev/null 2>&1");
|
||||
my $ex = system("diff ".&translate_filename($currentzone_link)." $zf >/dev/null 2>&1");
|
||||
if (!$ex) {
|
||||
return $z->[0];
|
||||
}
|
||||
@@ -127,7 +133,7 @@ return undef;
|
||||
sub get_hwclock_flags
|
||||
{
|
||||
if ($config{'hwclock_flags'} eq "sysconfig") {
|
||||
local %clock;
|
||||
my %clock;
|
||||
&read_env_file("/etc/sysconfig/clock", \%clock);
|
||||
return $clock{'CLOCKFLAGS'};
|
||||
}
|
||||
@@ -141,9 +147,9 @@ else {
|
||||
# an empty array, and sets the global $get_hardware_time_error
|
||||
sub get_hardware_time
|
||||
{
|
||||
local $flags = &get_hwclock_flags();
|
||||
my $flags = &get_hwclock_flags();
|
||||
$get_hardware_time_error = undef;
|
||||
local $out = `hwclock $flags`;
|
||||
my $out = `hwclock $flags`;
|
||||
if ($out =~ /^(\S+)\s+(\S+)\s+(\d+)\s+(\d+):(\d+):(\d+)\s+(\d+)\s+/) {
|
||||
return ($6, $5, $4, $3, &month_to_number($2), $7-1900, &weekday_to_number($1));
|
||||
}
|
||||
@@ -168,27 +174,27 @@ return localtime(time());
|
||||
# set_hardware_time(secs, mins, hours, day, month, year)
|
||||
sub set_hardware_time
|
||||
{
|
||||
local ($second, $minute, $hour, $date, $month, $year) = @_;
|
||||
my ($second, $minute, $hour, $date, $month, $year) = @_;
|
||||
$month++;
|
||||
$year += 1900;
|
||||
local $format = "--set --date=".
|
||||
my $format = "--set --date=".
|
||||
quotemeta("$month/$date/$year $hour:$minute:$second");
|
||||
local $flags = &get_hwclock_flags();
|
||||
local $out = &backquote_logged("hwclock $flags $format 2>&1");
|
||||
my $flags = &get_hwclock_flags();
|
||||
my $out = &backquote_logged("hwclock $flags $format 2>&1");
|
||||
return $? ? $out : undef;
|
||||
}
|
||||
|
||||
# set_system_time(secs, mins, hours, day, month, year)
|
||||
sub set_system_time
|
||||
{
|
||||
local ($second, $minute, $hour, $date, $month, $year) = @_;
|
||||
my ($second, $minute, $hour, $date, $month, $year) = @_;
|
||||
$second = &zeropad($second, 2);
|
||||
$minute = &zeropad($minute, 2);
|
||||
$hour = &zeropad($hour, 2);
|
||||
$date = &zeropad($date, 2);
|
||||
$month = &zeropad($month+1, 2);
|
||||
$year = &zeropad($year+1900, 4);
|
||||
local $format;
|
||||
my $format;
|
||||
if ($config{'seconds'} == 2) {
|
||||
$format = $year.$month.$date.$hour.$minute.".".$second;
|
||||
}
|
||||
@@ -198,7 +204,7 @@ elsif ($config{'seconds'} == 1) {
|
||||
else {
|
||||
$format = $month.$date.$hour.$minute.substr($year, -2);
|
||||
}
|
||||
local $out = &backquote_logged("echo yes | date ".quotemeta($format)." 2>&1");
|
||||
my $out = &backquote_logged("echo yes | date ".quotemeta($format)." 2>&1");
|
||||
if ($gconfig{'os_type'} eq 'freebsd' || $gconfig{'os_type'} eq 'netbsd') {
|
||||
return int($?/256) == 1 ? $out : undef;
|
||||
}
|
||||
@@ -209,20 +215,20 @@ else {
|
||||
|
||||
sub zeropad
|
||||
{
|
||||
local ($str, $len) = @_;
|
||||
my ($str, $len) = @_;
|
||||
while(length($str) < $len) {
|
||||
$str = "0".$str;
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
@weekday_names = ( "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" );
|
||||
our @weekday_names = ( "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" );
|
||||
|
||||
# weekday_to_number(day)
|
||||
# Converts a day like Mon to a number like 1
|
||||
sub weekday_to_number
|
||||
{
|
||||
for($i=0; $i<@weekday_names; $i++) {
|
||||
for(my $i=0; $i<@weekday_names; $i++) {
|
||||
return $i if (lc(substr($weekday_names[$i], 0, 3)) eq lc($_[0]));
|
||||
}
|
||||
return undef;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -4,15 +4,23 @@
|
||||
|
||||
require './user-lib.pl';
|
||||
&ReadParse();
|
||||
@glist = &list_groups();
|
||||
|
||||
# Get group and show page header
|
||||
$n = $in{'group'};
|
||||
if ($n eq "") {
|
||||
$access{'gcreate'} == 1 || &error($text{'gedit_ecreate'});
|
||||
&ui_print_header(undef, $text{'gedit_title2'}, "", "create_group");
|
||||
if ($in{'clone'} ne '') {
|
||||
($clone_hash) = grep { $_->{'group'} eq $in{'clone'} } @glist;
|
||||
$clone_hash || &error($text{'ugdit_egone'});
|
||||
%group = %$clone_hash;
|
||||
&can_edit_user(\%access, \%group) ||
|
||||
&error($text{'gedit_eedit'});
|
||||
$group{'group'} = '';
|
||||
}
|
||||
}
|
||||
else {
|
||||
@glist = &list_groups();
|
||||
($ginfo_hash) = grep { $_->{'group'} eq $n } @glist;
|
||||
$ginfo_hash || &error($text{'gedit_egone'});
|
||||
%group = %$ginfo_hash;
|
||||
@@ -165,7 +173,8 @@ else {
|
||||
if ($n ne "") {
|
||||
print &ui_form_end([
|
||||
[ undef, $text{'save'} ],
|
||||
$access{'gdelete'} ? ( [ 'delete', $text{'delete'} ] ) : ( ),
|
||||
$access{'gcreate'} ? ( [ 'clone', $text{'gedit_clone'} ] ) : (),
|
||||
$access{'gdelete'} ? ( [ 'delete', $text{'delete'} ] ) : (),
|
||||
]);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -7,13 +7,22 @@ use Time::Local;
|
||||
&ReadParse();
|
||||
|
||||
# Show header and get the user
|
||||
@ulist = &list_users();
|
||||
$n = $in{'user'};
|
||||
if ($n eq "") {
|
||||
if ($n eq '') {
|
||||
# Creating a new user
|
||||
$access{'ucreate'} || &error($text{'uedit_ecreate'});
|
||||
&ui_print_header(undef, $text{'uedit_title2'}, "", "create_user");
|
||||
if ($in{'clone'} ne '') {
|
||||
($clone_hash) = grep { $_->{'user'} eq $in{'clone'} } @ulist;
|
||||
$clone_hash || &error($text{'uedit_egone'});
|
||||
%uinfo = %$clone_hash;
|
||||
&can_edit_user(\%access, \%uinfo) || &error($text{'uedit_eedit'});
|
||||
$uinfo{'user'} = '';
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ulist = &list_users();
|
||||
# Editing an existing one
|
||||
($uinfo_hash) = grep { $_->{'user'} eq $n } @ulist;
|
||||
$uinfo_hash || &error($text{'uedit_egone'});
|
||||
%uinfo = %$uinfo_hash;
|
||||
@@ -597,6 +606,11 @@ if ($n ne "") {
|
||||
}
|
||||
}
|
||||
|
||||
# Clone user
|
||||
if ($access{'ucreate'}) {
|
||||
push(@buts, [ "clone", $text{'uedit_clone'} ]);
|
||||
}
|
||||
|
||||
# Delete user
|
||||
if ($access{'udelete'}) {
|
||||
push(@buts, [ "delete", $text{'delete'} ]);
|
||||
|
||||
@@ -134,6 +134,7 @@ uedit_uid_def=Automatic
|
||||
uedit_uid_calc=Calculated
|
||||
uedit_disabled=Login temporarily disabled
|
||||
uedit_sys=System default
|
||||
uedit_clone=Clone User
|
||||
|
||||
usave_err=Failed to save user
|
||||
usave_eedit=You cannot edit this user
|
||||
@@ -210,6 +211,7 @@ gedit_allu=All users
|
||||
gedit_selu=Users in group
|
||||
gedit_pri=Primary group members
|
||||
gedit_prinone=No users have this group as their primary
|
||||
gedit_clone=Clone Group
|
||||
|
||||
gsave_err=Failed to save group
|
||||
gsave_eedit=You cannot edit this group
|
||||
|
||||
@@ -25,6 +25,10 @@ elsif ($in{'delete'}) {
|
||||
&redirect("delete_user.cgi?user=".&urlize($in{'old'}));
|
||||
return;
|
||||
}
|
||||
elsif ($in{'clone'}) {
|
||||
&redirect("edit_user.cgi?clone=".&urlize($in{'old'}));
|
||||
return;
|
||||
}
|
||||
|
||||
# Build list of used UIDs and GIDs
|
||||
&build_user_used(\%used);
|
||||
|
||||
@@ -7347,7 +7347,9 @@ if ($ssl) {
|
||||
return $error if ($error);
|
||||
}
|
||||
Net::SSLeay::set_fd($rv->{'ssl_con'}, fileno($rv->{'fh'}));
|
||||
Net::SSLeay::set_tlsext_host_name($rv->{'ssl_con'}, $host);
|
||||
eval {
|
||||
Net::SSLeay::set_tlsext_host_name($rv->{'ssl_con'}, $host);
|
||||
};
|
||||
Net::SSLeay::connect($rv->{'ssl_con'}) ||
|
||||
return "SSL connect() failed";
|
||||
if ($certreqs) {
|
||||
|
||||
Reference in New Issue
Block a user