mirror of
https://github.com/ovh/the-bastion.git
synced 2025-09-05 04:24:11 +08:00
fix: avoid double-close log messages on HUP
This commit is contained in:
parent
373f4907de
commit
1725130a15
2 changed files with 11 additions and 4 deletions
|
@ -29,15 +29,16 @@ sub exit_sig {
|
|||
);
|
||||
}
|
||||
|
||||
# nullify my own handlers so that they don't get re-executed when my parent
|
||||
# exits because of the signal, and I get sent back a SIGHUP (see Prctl below)
|
||||
$SIG{$_} = 'IGNORE' for qw{ INT HUP TERM SEGV };
|
||||
|
||||
# signal my current process group
|
||||
kill $sig, 0;
|
||||
|
||||
exit(117); # EXIT_GOT_SIGNAL
|
||||
}
|
||||
$SIG{'INT'} = \&exit_sig;
|
||||
$SIG{'HUP'} = \&exit_sig;
|
||||
$SIG{'TERM'} = \&exit_sig;
|
||||
$SIG{'SEGV'} = \&exit_sig;
|
||||
$SIG{$_} = \&exit_sig for qw{ INT HUP TERM SEGV };
|
||||
|
||||
# beautify for ps
|
||||
local $0 = '' . __FILE__ . ' ' . join(' ', @command);
|
||||
|
|
|
@ -646,6 +646,8 @@ sub _write_log {
|
|||
return;
|
||||
}
|
||||
|
||||
my $_log_access_update_done = 0;
|
||||
|
||||
sub log_access_update {
|
||||
my %params = @_;
|
||||
my $account = $params{'account'};
|
||||
|
@ -654,6 +656,10 @@ sub log_access_update {
|
|||
my $uniq_id = $params{'uniq_id'};
|
||||
my $fnret;
|
||||
|
||||
# ensure we never get called more than once in a process
|
||||
return R('OK_DUPLICATE') if $_log_access_update_done;
|
||||
$_log_access_update_done = 1;
|
||||
|
||||
# if we get a valid account, we'll try to log to its files, if enabled.
|
||||
# if not, or if its invalid, still try to log what we can (hence don't return here)
|
||||
my ($remoteaccount, $sysaccount);
|
||||
|
|
Loading…
Add table
Reference in a new issue