Logrotate failed if logrotate status file got corrupted
Manoj-red-hat opened this issue · 3 comments
[Problem]
Logrotate failed if logrotate status file got corrupted.
[root]# /usr/sbin/logrotate /etc/logrotate.conf
error: line 92 too long in state file /var/lib/logrotate.status
error: could not read state file, will not attempt to write into it
[Reason]
logroatet.c check each line of logrotate status file which is terminated with new line,
if it fails it return and exist with error.
while (fgets(buf, sizeof(buf) - 1, f)) {
argv = NULL;
line++;
i = strlen(buf);
if (buf[i - 1] != '\n') {
message(MESS_ERROR, "line %d too long in state file %s\n",
line, stateFilename);
fclose(f);
return 1;
}
/var/lib/logrotate.status contains line number 92 ,
which exist without newline and thus causing this issue.
89 "/var/log/vsftpd.log" 2016-3-18
90 "/var/log/actlog.exports/meminfo" 2016-10-8
91 "/var/log/boot.log" 2016-10-2
92 "/var/log/network/update_swi
[Workaround]
Remove bad line and restart log rotate.
@Manoj-red-hat Is there behavior you are looking for in the logrotate chef cookbook to address this? The logrotate cookbook doesn't directly touch the status file, so the corruption was likely the result of a logrotate bug or some other process that is modifying that file.
HI @stevendanna my var partition got full , which causing the status file corruption.
https://bugzilla.redhat.com/show_bug.cgi?id=735093 -->existing bug
which got fixed in RHEL 5.8 onwards
https://bugzilla.redhat.com/show_bug.cgi?id=447022--->same bug
Patch reverted in RHEL 7.
I'm going to close this out as it looks like it was indeed an upstream bug. Thanks for reaching out, let me know if you think there is still something that needs to be done in this cookbook.