Changes to bring logging of ComsModule into compliance with CAcert

Security Manual, while keeping logfiles manageable:
- Modify SysLog function to use a new date-stamped logfile every day.
- Placed obvious debug print statement under control of if ($debug).
- Changed print of Version: information into a SysLog call.
pull/1/head
Wytze van der Raay 15 years ago
parent 4252e5bd13
commit e07b52ba77

@ -96,15 +96,20 @@ foreach (keys %revokefile)
#Logging functions:
open LOG,">>logfile.txt";
my $lastdate = "";
sub SysLog($)
{
return if(not defined($_[0]));
my $timestamp=strftime("%Y-%m-%d %H:%M:%S",localtime);
#$syslog->write($_[0]."\x00");
print LOG "$timestamp $_[0]";
print "$timestamp $_[0]";
flush LOG;
return if(not defined($_[0]));
my $timestamp = strftime("%Y-%m-%d %H:%M:%S", localtime);
my $currdate = substr($timestamp, 0, 10);
if ($lastdate ne $currdate) {
close LOG if ($lastdate ne "");
$lastdate = $currdate;
open LOG,">>logfile$lastdate.txt";
}
print LOG "$timestamp $_[0]";
flush LOG;
}
sub Error($)
@ -263,7 +268,9 @@ sub SendIt($)
#usleep(270*$iwrote+9000); # On Linux, we have to wait to make sure it is being sent, and we dont loose any data.
$total+=$iwrote;
$data=substr($data,$iwrote);
print "i wrote: $iwrote total: $total left: ".length($data)."\n" if(!($runcount++ %10));
if ($debug) {
print "i wrote: $iwrote total: $total left: ".length($data)."\n" if(!($runcount++ %10));
}
}
SysLog "Sent message.\n" if($debug);
# print "Sending ".length($_[0])."\n"; #hexdump($_[0])."\n";
@ -401,7 +408,7 @@ SysLog "Waiting on next request ...\n";
# @result(Version,Action,Errorcode,Response)=Request(Version=1,Action=1,System=1,Root=1,Configuration="...",Parameter="...",Request="...");
sub Request($$$$$$$$$$$)
{
print "Version: $_[0] Action: $_[1] System: $_[2] Root: $_[3] Config: $_[4]\n";
SysLog "Version: $_[0] Action: $_[1] System: $_[2] Root: $_[3] Config: $_[4]\n";
$_[3]=0 if($_[3]<0);
SendHandshaked(pack3(pack3(pack("C*",$_[0],$_[1],$_[2],$_[3],$_[4],$_[5],$_[6]>>8,$_[6]&255,$_[7])).pack3($_[8]).pack3($_[9]).pack3($_[10])));
my $data=Receive();

Loading…
Cancel
Save