diff options
Diffstat (limited to 'sysklogd')
-rw-r--r-- | sysklogd/syslogd.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c index a6a4ff25c..f75851085 100644 --- a/sysklogd/syslogd.c +++ b/sysklogd/syslogd.c | |||
@@ -648,22 +648,24 @@ static void log_locally(time_t now, char *msg, logFile_t *log_file) | |||
648 | } | 648 | } |
649 | /* newFile == "f.0" now */ | 649 | /* newFile == "f.0" now */ |
650 | rename(log_file->path, newFile); | 650 | rename(log_file->path, newFile); |
651 | /* Incredibly, if F and F.0 are hardlinks, POSIX | 651 | } |
652 | * _demands_ that rename returns 0 but does not | 652 | |
653 | * remove F!!! | 653 | /* We may or may not have just renamed the file away; |
654 | * (hardlinked F/F.0 pair was observed after | 654 | * if we didn't rename because we aren't keeping any backlog, |
655 | * power failure during rename()). | 655 | * then it's time to clobber the file. If we did rename it..., |
656 | * Ensure old file is gone: | 656 | * incredibly, if F and F.0 are hardlinks, POSIX _demands_ |
657 | */ | 657 | * that rename returns 0 but does not remove F!!! |
658 | unlink(log_file->path); | 658 | * (hardlinked F/F.0 pair was observed after |
659 | * power failure during rename()). | ||
660 | * So ensure old file is gone in any case: | ||
661 | */ | ||
662 | unlink(log_file->path); | ||
659 | #ifdef SYSLOGD_WRLOCK | 663 | #ifdef SYSLOGD_WRLOCK |
660 | fl.l_type = F_UNLCK; | 664 | fl.l_type = F_UNLCK; |
661 | fcntl(log_file->fd, F_SETLKW, &fl); | 665 | fcntl(log_file->fd, F_SETLKW, &fl); |
662 | #endif | 666 | #endif |
663 | close(log_file->fd); | 667 | close(log_file->fd); |
664 | goto reopen; | 668 | goto reopen; |
665 | } | ||
666 | ftruncate(log_file->fd, 0); | ||
667 | } | 669 | } |
668 | log_file->size += | 670 | log_file->size += |
669 | #endif | 671 | #endif |