mirror of
https://github.com/xcat2/xcat-core.git
synced 2025-05-30 09:36:41 +00:00
add umask for command log file /var/log/xcat/commands.log
This commit is contained in:
parent
617831d289
commit
48e64132ed
@ -1053,10 +1053,11 @@ unless ($cmdlog_svrpid){
|
||||
my $writing=0;
|
||||
my $cmdlogfileswitch=0;
|
||||
my $cmdlogservicefile="/var/run/xcat/cmdlogservice.pid";
|
||||
my $cmdlog_logfile_umask;
|
||||
|
||||
$SIG{USR2} = sub {
|
||||
while($writing){sleep(0.01);}
|
||||
if($cmdlogfile){close($cmdlogfile);}
|
||||
if($cmdlogfile){close($cmdlogfile);umask($cmdlog_logfile_umask);}
|
||||
if($clientsock){close($clientsock);}
|
||||
if( -e $cmdlogservicefile){ unlink("$cmdlogservicefile");}
|
||||
if($cmdlogsvrlistener){close($cmdlogsvrlistener);}
|
||||
@ -1066,7 +1067,7 @@ unless ($cmdlog_svrpid){
|
||||
|
||||
$SIG{TERM} = $SIG{INT} = sub {
|
||||
while($writing){sleep(0.01);}
|
||||
if($cmdlogfile){close($cmdlogfile);}
|
||||
if($cmdlogfile){close($cmdlogfile);umask($cmdlog_logfile_umask);}
|
||||
if($clientsock){close($clientsock);}
|
||||
if( -e $cmdlogservicefile){ unlink("$cmdlogservicefile");}
|
||||
if($cmdlogsvrlistener){close($cmdlogsvrlistener);}
|
||||
@ -1095,7 +1096,8 @@ unless ($cmdlog_svrpid){
|
||||
}
|
||||
if(!$trytime){
|
||||
xCAT::MsgUtils->message("S","INFO xcatd: 'Command log writer' process $$ get HUP signal, reopen commands.log file failed, send TERM signal to kill itself");
|
||||
kill 2, $$;
|
||||
umask($cmdlog_logfile_umask);
|
||||
kill 'INT', $$;
|
||||
}else{
|
||||
xCAT::MsgUtils->message("S","INFO xcatd: 'Command log writer' process $$ get HUP signal, reopen commands.log file");
|
||||
}
|
||||
@ -1111,7 +1113,7 @@ unless ($cmdlog_svrpid){
|
||||
xCAT::MsgUtils->message("S","INFO xcatd: 'Command log writer' process $$ is trying to get port $cmdlog_port");
|
||||
my $pid = <$cmdlogpidfile>;
|
||||
if ($pid) {
|
||||
kill 12, $pid;
|
||||
kill 'USR2', $pid;
|
||||
}
|
||||
close($cmdlogpidfile);
|
||||
}
|
||||
@ -1129,9 +1131,15 @@ unless ($cmdlog_svrpid){
|
||||
exit(0);
|
||||
}
|
||||
|
||||
open($cmdlogpidfile,">$cmdlogservicefile");
|
||||
print $cmdlogpidfile $$;
|
||||
close($cmdlogpidfile);
|
||||
xCAT::MsgUtils->trace(0,"I","xcatd: command log process $$ start");
|
||||
|
||||
my $cmdlog_logfile_path=dirname($cmdlog_logfile);
|
||||
mkpath("$cmdlog_logfile_path") unless(-d "$cmdlog_logfile_path");
|
||||
|
||||
$cmdlog_logfile_umask = umask(0077);
|
||||
unless (open ($cmdlogfile, ">>$cmdlog_logfile")) {
|
||||
xCAT::MsgUtils->trace(0,"E","xcatd: Can't open xcat command log file $cmdlog_logfile,command log process $$ stop.");
|
||||
if($cmdlogsvrlistener){close($cmdlogsvrlistener);}
|
||||
@ -1141,11 +1149,6 @@ unless ($cmdlog_svrpid){
|
||||
$|=1;
|
||||
$cmdlogfileswitch=1;
|
||||
|
||||
open($cmdlogpidfile,">$cmdlogservicefile");
|
||||
print $cmdlogpidfile $$;
|
||||
close($cmdlogpidfile);
|
||||
xCAT::MsgUtils->trace(0,"I","xcatd: command log process $$ start");
|
||||
|
||||
while (1)
|
||||
{
|
||||
$clientsock = $cmdlogsvrlistener->accept;
|
||||
@ -1164,7 +1167,7 @@ unless ($cmdlog_svrpid){
|
||||
$writing=0;
|
||||
}
|
||||
|
||||
if($cmdlogfile){close($cmdlogfile);}
|
||||
if($cmdlogfile){close($cmdlogfile);umask($cmdlog_logfile_umask);}
|
||||
if($cmdlogsvrlistener){close($cmdlogsvrlistener);}
|
||||
xCAT::MsgUtils->message("S","INFO xcatd: 'Command log writer' process $$ stop");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user