Skip to content

Commit

Permalink
enh: interactive: handle CTRL+C nicely (fix #497)
Browse files Browse the repository at this point in the history
  • Loading branch information
speed47 committed Oct 16, 2024
1 parent 8cafbc8 commit 07b2800
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/perl/OVH/Bastion/interactive.inc
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,20 @@ EOM
exit 1; # normally not reached
}
);
# handle ^C to clear the current prompt
POSIX::sigaction POSIX::SIGINT, POSIX::SigAction->new(
sub {
print "\n"; # ensure we are on a new line
$term->on_new_line(); # print the prompt
$term->replace_line("", 0); # clear the previous text
$term->redisplay();
}
);

my $BASTION_USER = OVH::Bastion::get_user_from_env()->value;
alarm($interactiveModeTimeout);
while (defined(my $line = $term->readline(_get_prompt($self, $bastionName, $slaveOrMaster)))) {
alarm(0); # disable timeout
alarm(0); # disable timeout
$line =~ s/^\s+|\s+$//g;

# disable proactive MFA if it has expired. Even if the user just typed "enter" with no command.
Expand Down

0 comments on commit 07b2800

Please sign in to comment.