Merge branch 'master' of github.com:webmin/webmin

This commit is contained in:
Ilia Rostovtsev
2020-08-25 15:14:29 +03:00
11 changed files with 66 additions and 4 deletions

View File

@@ -17,6 +17,8 @@ else {
map { $access_types{$_}++ } @access_types;
$site_file = ($config{'webmin_apache'} || $module_config_directory)."/site";
$httpd_info_cache = $module_config_directory."/httpd-info";
$last_config_change_flag = $module_var_directory."/config-flag";
$last_restart_time_flag = $module_var_directory."/restart-flag";
# Check if a list of supported modules needs to be built. This is done
# if the Apache binary changes, when Webmin is upgraded, or once every five
@@ -606,6 +608,7 @@ for($i=0; $i<@old || $i<@{$_[1]}; $i++) {
$change = $old[$i];
}
}
&update_last_config_change();
return &unique(@files);
}
@@ -686,6 +689,7 @@ elsif (!$olddir && $newdir) {
$newdir->{'file'});
}
}
&update_last_config_change();
}
# recursive_set_lines_files(&directives, first-line, file)
@@ -1167,12 +1171,18 @@ print "<p>\n";
# Returns HTML for a link to put in the top-right corner of every page
sub restart_button
{
local $rv;
$args = "redir=".&urlize(&this_url());
local $args = "redir=".&urlize(&this_url());
local @rv;
if (&is_apache_running()) {
if ($access{'apply'}) {
push(@rv, &ui_link("restart.cgi?$args", $text{'apache_apply'}) );
my $n = &needs_config_restart();
if ($n) {
push(@rv, &ui_link("restart.cgi?$args&newconfig=1",
"<b>$text{'apache_apply'}</b>") );
}
else {
push(@rv, &ui_link("restart.cgi?$args", $text{'apache_apply'}) );
}
}
if ($access{'stop'}) {
push(@rv, &ui_link("stop.cgi?$args", $text{'apache_stop'}) );
@@ -1586,6 +1596,7 @@ else {
&kill_logged('HUP', $1) || return &text('restart_esig', $1);
&wait_for_graceful();
}
&restart_last_restart_time();
return undef;
}
@@ -2040,5 +2051,33 @@ local $d = &virtual_server::get_domain_by("dom", $n);
return $d;
}
# update_last_config_change()
# Updates the flag file indicating when the config was changed
sub update_last_config_change
{
&open_tempfile(FLAG, ">$last_config_change_flag", 0, 1);
&close_tempfile(FLAG);
}
# restart_last_restart_time()
# Updates the flag file indicating when the config was changed
sub restart_last_restart_time
{
&open_tempfile(FLAG, ">$last_restart_time_flag", 0, 1);
&close_tempfile(FLAG);
}
# needs_config_restart()
# Returns 1 if a restart is needed for sure after a config change
sub needs_config_restart
{
my @cst = stat($last_config_change_flag);
my @rst = stat($last_restart_time_flag);
if (@cst && @rst && $cst[9] > $rst[9]) {
return 1;
}
return 0;
}
1;

View File

@@ -41,6 +41,7 @@ else {
}
&flush_file_lines();
&unlock_file($d->{'file'});
&update_last_config_change();
&after_changing();
&webmin_log("dir", $in{'delete'} ? 'delete' : 'save',

View File

@@ -36,6 +36,7 @@ else {
}
&flush_file_lines();
&unlock_file($d->{'file'});
&update_last_config_change();
&after_changing();
&webmin_log("files", $in{'delete'} ? 'delete' : 'save',

View File

@@ -37,6 +37,7 @@ else {
# Add to file
&save_directive_struct(undef, $dir, $vconf, $conf);
&flush_file_lines();
&update_last_config_change();
&unlock_file($vconf->[0]->{'file'});
&after_changing();

View File

@@ -31,6 +31,7 @@ else {
# Add to file
&save_directive_struct(undef, $dir, $hconf, $hconf);
&flush_file_lines();
&update_last_config_change();
&unlock_file($in{'file'});
&after_changing();

View File

@@ -240,6 +240,7 @@ if ($in{'adddir'} && $in{'root'}) {
&save_directive_struct(undef, $virt, $conf, $conf);
&flush_file_lines();
&unlock_file($f);
&update_last_config_change();
&unlock_apache_files();
# Create a symlink from another dir, if requested (as in Debian)

View File

@@ -26,6 +26,7 @@ foreach $vconf (@virts) {
}
&flush_file_lines();
&unlock_all_files();
&update_last_config_change();
&after_changing();
&webmin_log("virts", "delete", scalar(@virts));
&redirect("");

View File

@@ -75,6 +75,7 @@ if ($config{'test_manual'}) {
}
unlink($temp);
&unlock_file($file);
&update_last_config_change();
&webmin_log($logtype, "manual", $logname, \%in);
foreach $h ('virt', 'idx', 'file') {

View File

@@ -18,6 +18,7 @@ if ($in{'delete'}) {
&delete_file_if_empty($vconf->{'file'});
&flush_file_lines();
&unlock_file($vconf->{'file'});
&update_last_config_change();
&after_changing();

View File

@@ -48,6 +48,13 @@ if (!-r $first_install_file || $miniserv{'login_script'} eq $record_login_cmd) {
&put_miniserv_config(\%miniserv);
&unlock_file("$config_directory/miniserv.conf");
# Create a link from /usr/sbin/webmin to bin/webmin under the root dir
my $bindir = "/usr/sbin";
my $lnk = $bindir."/webmin";
if (-d $bindir && !-e $lnk) {
&symlink_file($lnk, $root_directory."/bin/webmin");
}
# Record the version of Webmin at first install
if (!-r $first_install_file) {
my %first;

View File

@@ -5,8 +5,9 @@ require 'webmin-lib.pl';
sub module_uninstall
{
# Remove the update cron job, if enabled
if ($config{'update'}) {
&foreign_require("cron", "cron-lib.pl");
&foreign_require("cron");
$cron_cmd = "$module_config_directory/update.pl";
foreach $j (&cron::list_cron_jobs()) {
if ($j->{'user'} eq 'root' &&
@@ -15,6 +16,13 @@ if ($config{'update'}) {
}
}
}
# Remove the link from /usr/sbin/webmin
my $bindir = "/usr/sbin";
my $lnk = $bindir."/webmin";
if (-l $lnk) {
unlink($lnk);
}
}
1;