File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change 1+ 2015-01-17 Pierre Schweitzer <pierre@reactos.org>
2+
3+ * ForbidHosts.cpp: Add a wait loop when attempting to reopen auth.log after log rotation.
4+
152015-01-20 Pierre Schweitzer <pierre@reactos.org>
26
37 * ForbidHosts.cpp: Don't use LOG_ERR for syslog, it is set to be ignored
Original file line number Diff line number Diff line change 5252#define MailCommandTpl " /usr/bin/mailx -s '%s - ForbidHosts Report' root"
5353#define CrashMailTpl " /usr/bin/mailx -s '%s - ForbidHosts Crash' root"
5454
55+ const unsigned int MaxWaitRotate = 3600 ;
5556const unsigned int MaxAttempts = 5 ;
5657const time_t HostExpire = 5 ;
5758const unsigned int FailurePenalty = 1 ;
@@ -649,7 +650,17 @@ int main(int argc, char ** argv) {
649650 // Close file and restart
650651 soft_assert (close (AuthLog) == 0 );
651652
652- AuthLog = open (AuthLogFile, O_RDONLY | O_NONBLOCK);
653+ // We will wait a bit to allow rotation
654+ for (unsigned int Attempts = 0 ; Attempts < MaxWaitRotate; ++Attempts) {
655+ AuthLog = open (AuthLogFile, O_RDONLY | O_NONBLOCK);
656+ if (AuthLog != -1 ) {
657+ break ;
658+ }
659+
660+ sleep (1 );
661+ }
662+
663+ // Check the wait loop was a success
653664 if (AuthLog < 0 ) {
654665 AuthLog = 0 ;
655666 syslog (LOG_CRIT, " Failed to reopen auth.log. Quitting." );
You can’t perform that action at this time.
0 commit comments