mirror of
https://github.com/ovh/the-bastion.git
synced 2025-10-05 11:14:50 +08:00
fix: ttyrec cmdline: don't add --warn-before-* when no --idle-*-timeout is specified
This commit is contained in:
parent
291d897832
commit
3956dc587b
2 changed files with 23 additions and 16 deletions
|
@ -1069,15 +1069,11 @@ sub build_ttyrec_cmdline_part1of2 {
|
||||||
);
|
);
|
||||||
if ($fnret && $fnret->value =~ /yes/) {
|
if ($fnret && $fnret->value =~ /yes/) {
|
||||||
osh_debug("Account is immune to idle, not adding ttyrec commandline parameters");
|
osh_debug("Account is immune to idle, not adding ttyrec commandline parameters");
|
||||||
|
return R('OK', value => {saveFile => $saveFile, cmd => \@ttyrec, idleIgnore => 1});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
my $warnBeforeLockSeconds = OVH::Bastion::config('warnBeforeLockSeconds')->value;
|
return R('OK', value => {saveFile => $saveFile, cmd => \@ttyrec, idleIgnore => 0});
|
||||||
my $warnBeforeKillSeconds = OVH::Bastion::config('warnBeforeKillSeconds')->value;
|
|
||||||
push @ttyrec, '--warn-before-lock', $warnBeforeLockSeconds if $warnBeforeLockSeconds;
|
|
||||||
push @ttyrec, '--warn-before-kill', $warnBeforeKillSeconds if $warnBeforeKillSeconds;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return R('OK', value => {saveFile => $saveFile, cmd => \@ttyrec});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# call this after build_ttyrec_cmdline_part1of2, don't forget to
|
# call this after build_ttyrec_cmdline_part1of2, don't forget to
|
||||||
|
@ -1096,12 +1092,25 @@ sub build_ttyrec_cmdline_part2of2 {
|
||||||
|
|
||||||
my @cmd = @{$input->{'cmd'}};
|
my @cmd = @{$input->{'cmd'}};
|
||||||
|
|
||||||
|
# if account is immune to idle, don't add these params to ttyrec cmdline
|
||||||
|
if (!$input->{'idleIgnore'}) {
|
||||||
my $idleLockTimeout = $params{'idleLockTimeout'};
|
my $idleLockTimeout = $params{'idleLockTimeout'};
|
||||||
my $idleKillTimeout = $params{'idleKillTimeout'};
|
if ($idleLockTimeout) {
|
||||||
|
push @cmd, '-t', $idleLockTimeout;
|
||||||
|
push @cmd, '-s', "To unlock, use '--osh unlock' from another console";
|
||||||
|
|
||||||
push @cmd, '-k', $idleKillTimeout if $idleKillTimeout;
|
my $warnBeforeLockSeconds = OVH::Bastion::config('warnBeforeLockSeconds')->value;
|
||||||
push @cmd, '-t', $idleLockTimeout if $idleLockTimeout;
|
push @cmd, '--warn-before-lock', $warnBeforeLockSeconds if $warnBeforeLockSeconds;
|
||||||
push @cmd, '-s', "To unlock, use '--osh unlock' from another console" if $idleLockTimeout;
|
}
|
||||||
|
|
||||||
|
my $idleKillTimeout = $params{'idleKillTimeout'};
|
||||||
|
if ($idleKillTimeout) {
|
||||||
|
push @cmd, '-k', $idleKillTimeout;
|
||||||
|
|
||||||
|
my $warnBeforeKillSeconds = OVH::Bastion::config('warnBeforeKillSeconds')->value;
|
||||||
|
push @cmd, '--warn-before-kill', $warnBeforeKillSeconds if $warnBeforeKillSeconds;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
my $ttyrecAdditionalParameters = OVH::Bastion::config('ttyrecAdditionalParameters')->value;
|
my $ttyrecAdditionalParameters = OVH::Bastion::config('ttyrecAdditionalParameters')->value;
|
||||||
push @cmd, @$ttyrecAdditionalParameters if @$ttyrecAdditionalParameters;
|
push @cmd, @$ttyrecAdditionalParameters if @$ttyrecAdditionalParameters;
|
||||||
|
|
|
@ -89,8 +89,6 @@ cmp_deeply(
|
||||||
$fnret->value->{'saveFile'},
|
$fnret->value->{'saveFile'},
|
||||||
'-F',
|
'-F',
|
||||||
'/home/randomuser/ttyrec/127.0.0.1/%Y-%m-%d.%H-%M-%S.#usec#.cafed00dcafe.bastionuser.randomuser.127.0.0.1.7979.ttyrec',
|
'/home/randomuser/ttyrec/127.0.0.1/%Y-%m-%d.%H-%M-%S.#usec#.cafed00dcafe.bastionuser.randomuser.127.0.0.1.7979.ttyrec',
|
||||||
'-k',
|
|
||||||
29,
|
|
||||||
'-t',
|
'-t',
|
||||||
17,
|
17,
|
||||||
'-s',
|
'-s',
|
||||||
|
@ -147,12 +145,12 @@ cmp_deeply(
|
||||||
$fnret->value->{'saveFile'},
|
$fnret->value->{'saveFile'},
|
||||||
'-F',
|
'-F',
|
||||||
'/home/randomuser/ttyrec/127.0.0.1/%Y-%m-%d.%H-%M-%S.#usec#.cafed00dcafe.bastionuser.randomuser.127.0.0.1.7979.ttyrec',
|
'/home/randomuser/ttyrec/127.0.0.1/%Y-%m-%d.%H-%M-%S.#usec#.cafed00dcafe.bastionuser.randomuser.127.0.0.1.7979.ttyrec',
|
||||||
'-k',
|
|
||||||
88,
|
|
||||||
'-t',
|
'-t',
|
||||||
99,
|
99,
|
||||||
'-s',
|
'-s',
|
||||||
"To unlock, use '--osh unlock' from another console"
|
"To unlock, use '--osh unlock' from another console",
|
||||||
|
'-k',
|
||||||
|
88,
|
||||||
],
|
],
|
||||||
"build_ttyrec_cmdline_part2of2 cmd"
|
"build_ttyrec_cmdline_part2of2 cmd"
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue