Fix change bind port redirects

This commit is contained in:
Ilia
2022-06-03 04:44:58 +03:00
parent 299b747738
commit 9f6a651a79
6 changed files with 36 additions and 9 deletions

View File

@ -632,7 +632,13 @@ else {
# Stop systemd
open(STOPD, ">$config_directory/stop");
print STOPD "$systemctlcmd stop webmin\n";
print STOPD "if [ \"\$1\" = \"--grace\" ]; then\n";
print STOPD " $systemctlcmd kill -s SIGHUP webmin\n";
print STOPD "elif [ \"\$1\" = \"--force\" ]; then\n";
print STOPD " $systemctlcmd kill -s SIGKILL webmin\n";
print STOPD "else\n";
print STOPD " $systemctlcmd stop webmin\n";
print STOPD "fi\n";
close(STOPD);
# Restart systemd

View File

@ -688,7 +688,13 @@ if [ -x "$systemctlcmd" ]; then
echo "$systemctlcmd start webmin" >>$config_dir/start
# Stop systemd
echo "#!/bin/sh" >>$config_dir/stop
echo "$systemctlcmd stop webmin" >>$config_dir/stop
echo "if [ \"\$1\" = \"--grace\" ]; then" >>$config_dir/stop
echo " $systemctlcmd kill -s SIGHUP webmin" >>$config_dir/stop
echo "elif [ \"\$1\" = \"--force\" ]; then" >>$config_dir/stop
echo " $systemctlcmd kill -s SIGKILL webmin" >>$config_dir/stop
echo "else" >>$config_dir/stop
echo " $systemctlcmd stop webmin" >>$config_dir/stop
echo "fi" >>$config_dir/stop
# Restart systemd
echo "#!/bin/sh" >>$config_dir/restart
echo "$systemctlcmd restart webmin" >>$config_dir/restart

View File

@ -7,7 +7,10 @@ ExecStart=/etc/webmin/.start-init
ExecStop=/etc/webmin/.stop-init
PIDFile=/var/webmin/miniserv.pid
Type=forking
KillMode=none
Restart=always
RestartSec=3s
StartLimitBurst=3
StartLimitIntervalSec=3
[Install]
WantedBy=multi-user.target

View File

@ -135,7 +135,7 @@ else {
# Attempt to re-start miniserv
$SIG{'TERM'} = 'ignore';
&system_logged("$config_directory/stop >/dev/null 2>&1 </dev/null");
&system_logged("$config_directory/stop --grace >/dev/null 2>&1 </dev/null");
$temp = &transname();
$rv = &system_logged("$config_directory/start >$temp 2>&1 </dev/null");
$out = &read_file_contents($temp);
@ -175,15 +175,19 @@ else { $url = $ENV{'SERVER_NAME'}; }
if ($ENV{'HTTPS'} eq "ON") { $url = "https://$url"; }
else { $url = "http://$url"; }
if ($tconfig{'inframe'}) {
# Theme uses frames, so we need to redirect the whole frameset
# Theme redirect if port changed
if ($miniserv{'port'} ne $oldminiserv{'port'}) {
$url .= ":$miniserv{'port'}";
&ui_print_header(undef, $text{'bind_title'}, "");
print $text{'bind_redirecting'},"<p>\n";
print "<script>\n";
print "top.location = '$url';\n";
print "setTimeout(function(){top.location = '$url';}, 3000)\n";
print "</script>\n";
&ui_print_footer("", $text{'index_return'});
# In case of systemd kill service to be auto-restarted by systemd
if (&has_command('systemctl')) {
&system_logged("$config_directory/stop --force >/dev/null 2>&1 </dev/null");
}
}
else {
$url .= ":$miniserv{'port'}/webmin/";

View File

@ -5,7 +5,7 @@
use strict;
use warnings;
require './webmin-lib.pl';
our (%in, %text, %gconfig, %config);
our (%in, %text, %gconfig, %config, $config_directory);
my $ver = &get_webmin_version();
my $rel = &get_webmin_version_release();
$ver .= "-".$rel if ($rel);
@ -114,3 +114,11 @@ if ($in{'refresh'} && defined(&theme_post_change_modules)) {
&ui_print_footer("/", $text{'index'});
if (&webmin_user_is_admin() &&
$ENV{'HTTP_REFERER'} =~ /\/edit_bind\.cgi/) {
# In case of systemd kill service to be auto-restarted
# by systemd if coming from Ports and Addresses page.
if (&has_command('systemctl')) {
&system_logged("$config_directory/stop --force >/dev/null 2>&1 </dev/null");
}
}

View File

@ -330,7 +330,7 @@ elsif ($in{'mode'} eq 'solaris-pkg' || $in{'mode'} eq 'sun-pkg') {
# a remote script that could be nohup'd and it would restart the server.
chdir("/");
&proc::safe_process_exec_logged(
"$config_directory/stop", 0, 0, STDOUT, undef, 1,1);
"$config_directory/stop --grace", 0, 0, STDOUT, undef, 1,1);
$in{'root'} = '/';
$in{'adminfile'} = '$module_root_directory/adminupgrade';