mirror of
https://github.com/webmin/webmin.git
synced 2026-02-03 14:13:29 +00:00
Fix to place cleanup_miniserv to the lib file
This commit is contained in:
@@ -14,7 +14,7 @@ my @uinfo = getpwnam($user);
|
||||
my ($uid, $gid);
|
||||
if ($user ne "root" && !$<) {
|
||||
if (!@uinfo) {
|
||||
&cleanup_miniserv();
|
||||
&cleanup_miniserv($port);
|
||||
die "User $user does not exist!";
|
||||
}
|
||||
$uid = $uinfo[2];
|
||||
@@ -68,7 +68,7 @@ my ($shellfh, $pid) = &proc::pty_process_exec($shellexec, $uid, $gid, $shelllogi
|
||||
&reset_environment();
|
||||
my $shcmd = "'$shellexec".($shelllogin ? " $shelllogin" : "")."'";
|
||||
if (!$pid) {
|
||||
&cleanup_miniserv();
|
||||
&cleanup_miniserv($port);
|
||||
die "Failed to run shell with $shcmd\n";
|
||||
}
|
||||
else {
|
||||
@@ -83,7 +83,7 @@ untie(*STDIN);
|
||||
close(STDIN);
|
||||
|
||||
$SIG{'ALRM'} = sub {
|
||||
&cleanup_miniserv();
|
||||
&cleanup_miniserv($port);
|
||||
die "timeout waiting for connection";
|
||||
};
|
||||
alarm(60);
|
||||
@@ -133,13 +133,13 @@ Net::WebSocket::Server->new(
|
||||
}
|
||||
if (!syswrite($shellfh, $msg, length($msg))) {
|
||||
print STDERR "write to shell failed : $!\n";
|
||||
&cleanup_miniserv();
|
||||
&cleanup_miniserv($port);
|
||||
exit(1);
|
||||
}
|
||||
},
|
||||
disconnect => sub {
|
||||
print STDERR "websocket connection closed\n";
|
||||
&cleanup_miniserv();
|
||||
&cleanup_miniserv($port);
|
||||
kill('KILL', $pid) if ($pid);
|
||||
exit(0);
|
||||
}
|
||||
@@ -152,7 +152,7 @@ Net::WebSocket::Server->new(
|
||||
my $ok = sysread($shellfh, $buf, 1024);
|
||||
if ($ok <= 0) {
|
||||
print STDERR "end of output from shell\n";
|
||||
&cleanup_miniserv();
|
||||
&cleanup_miniserv($port);
|
||||
exit(0);
|
||||
}
|
||||
if ($wsconn) {
|
||||
@@ -165,20 +165,4 @@ Net::WebSocket::Server->new(
|
||||
],
|
||||
)->start;
|
||||
print STDERR "exited websockets server\n";
|
||||
&cleanup_miniserv();
|
||||
|
||||
sub cleanup_miniserv
|
||||
{
|
||||
my %miniserv;
|
||||
if ($port) {
|
||||
&lock_file(&get_miniserv_config_file());
|
||||
&get_miniserv_config(\%miniserv);
|
||||
my $wspath = "/$module_name/ws-".$port;
|
||||
if ($miniserv{'websockets_'.$wspath}) {
|
||||
delete($miniserv{'websockets_'.$wspath});
|
||||
&put_miniserv_config(\%miniserv);
|
||||
&reload_miniserv();
|
||||
}
|
||||
&unlock_file(&get_miniserv_config_file());
|
||||
}
|
||||
}
|
||||
&cleanup_miniserv($port);
|
||||
|
||||
@@ -5,9 +5,29 @@ use WebminCore;
|
||||
&init_config();
|
||||
our %access = &get_module_acl();
|
||||
|
||||
# cleanup_miniserv(port)
|
||||
# Remove websocket in miniserv.conf
|
||||
# that is no longer being used
|
||||
sub cleanup_miniserv
|
||||
{
|
||||
my ($port) = @_;
|
||||
my %miniserv;
|
||||
if ($port) {
|
||||
&lock_file(&get_miniserv_config_file());
|
||||
&get_miniserv_config(\%miniserv);
|
||||
my $wspath = "/$module_name/ws-".$port;
|
||||
if ($miniserv{'websockets_'.$wspath}) {
|
||||
delete($miniserv{'websockets_'.$wspath});
|
||||
&put_miniserv_config(\%miniserv);
|
||||
&reload_miniserv();
|
||||
}
|
||||
&unlock_file(&get_miniserv_config_file());
|
||||
}
|
||||
}
|
||||
|
||||
# cleanup_old_websockets([&skip-ports])
|
||||
# Called by scheduled status collection to remove any websockets in
|
||||
# miniserv.conf that are no longer used
|
||||
# Called by scheduled status collection to remove any
|
||||
# websockets in miniserv.conf that are no longer used
|
||||
sub cleanup_old_websockets
|
||||
{
|
||||
my ($skip) = @_;
|
||||
|
||||
Reference in New Issue
Block a user