Commit c4b33156 authored by Dietmar Maurer's avatar Dietmar Maurer

fix bug #408: reset ENV before starting shell

parent b52133c4
...@@ -641,22 +641,29 @@ __PACKAGE__->register_method ({ ...@@ -641,22 +641,29 @@ __PACKAGE__->register_method ({
my $timeout = 10; my $timeout = 10;
my @cmd = ('/usr/bin/vncterm', '-rfbport', $port, my $cmd = ['/usr/bin/vncterm', '-rfbport', $port,
'-timeout', $timeout, '-authpath', $authpath, '-timeout', $timeout, '-authpath', $authpath,
'-perm', 'Sys.Console', '-c', @$remcmd, @$shcmd); '-perm', 'Sys.Console', '-c', @$remcmd, @$shcmd];
my $realcmd = sub { my $realcmd = sub {
my $upid = shift; my $upid = shift;
syslog ('info', "starting vnc proxy $upid\n"); syslog ('info', "starting vnc proxy $upid\n");
my $cmdstr = join (' ', @cmd); my $cmdstr = join (' ', @$cmd);
syslog ('info', "launch command: $cmdstr"); syslog ('info', "launch command: $cmdstr");
if (system(@cmd) != 0) { eval {
my $msg = "vncterm failed - $?"; foreach my $k (keys %ENV) {
syslog ('err', $msg); next if $k eq 'PATH' || $k eq 'TERM' || $k eq 'USER' || $k eq 'HOME';
return; delete $ENV{$k};
}
$ENV{PWD} = '/';
PVE::Tools::run_command($cmd, errmsg => "vncterm failed");
};
if (my $err = $@) {
syslog ('err', $err);
} }
return; return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment