Your message dated Thu, 27 Jun 2013 10:46:30 +0100
with message-id <20130627094630.ga11...@thinkpad.nowster.org.uk>
and subject line logrotate 3.8.5 fixes this bug
has caused the Debian Bug report #706484,
regarding racy creation of logrotate.state file causing lost logfiles
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact ow...@bugs.debian.org
immediately.)


-- 
706484: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=706484
Debian Bug Tracking System
Contact ow...@bugs.debian.org with problems
--- Begin Message ---
Package: logrotate
Version: 3.7.8-6
Severity: critical
Tags: upstream
Justification: causes serious data loss


Bug occurred with 3.7.8-6ubuntu3.1, but is present in Debian and all
upstream versions up to and including 3.8.4.  When writing the state
file, logrotate essentially does fopen(); fprinf(); fclose();.  If
anything fails between fopen() and fclose(), Bad Stuff happens.
Failures include -ENOSPC, which ought to be fairly common.

On -ENOSPC the state file is truncated, usually with a partial line at
the end.  Future logrotate runs will use the state file, but fail to
write it with
"error: could not read state file, will not attempt to write into it"

Therefore the state file gets both truncated and stale.  Afaics log
rotation still happens, but only for files present in the truncated
stale state file.  So one set of logs is rotated regularly and another
is not.

While trying to debug the partial rotation issue I ran logrotate
manually with -v, causing a second logrotate run for the day.  Because
logrotate hadn't happend in a long time - if you believe the state
file - this destroyed a day's worth of logs for the files that were
rotated.  Afaics the data loss depends on using dateext, which I do.

Obvious fix is to do fopen(); fprintf(); fclose(); rename(); instead.
If the write fails for any reason, you still have the old state file.
However, the obvious fix still falls short, as the state file would
not be untruncated, but still stale.  So future logrotate runs will
still happily destroy data.

I suspect the only sane real fix is to get rid of the state file
for the dateext case.  Glob for "logfile-20130430*", or maybe
"logfile-20130430" and "logfile-20130430.gz" and use that to decide
whether to rotate or not.  The only point of the state file is to get
this information for the "logfile.0" case.  And arguably even then it
should be sufficient to trust the file dates.

-- Package-specific info:
Contents of /etc/logrotate.d
total 36
-rw-r--r-- 1 root root 194 Jan  1  2011 apache2
-rw-r--r-- 1 root root 173 Jan 25  2011 apt
-rw-r--r-- 1 root root  79 Oct 16  2010 aptitude
-rw-r--r-- 1 root root 232 Jan 30  2011 dpkg
-rw-r--r-- 1 root root 146 Jan 31  2011 exim4-base
-rw-r--r-- 1 root root 126 Jan 31  2011 exim4-paniclog
-rw-r--r-- 1 root root 153 Dec  4  2010 postgresql-common
-rw-r--r-- 1 root root 515 Nov 30  2010 rsyslog
-rw-r--r-- 1 root root 322 Dec  7  2010 samba


-- System Information:
Debian Release: 6.0.6
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.32-5-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages logrotate depends on:
ii  base-passwd                   3.5.22     Debian base system master password
ii  cron                          3.0pl1-116 process scheduling daemon
ii  libc6                         2.11.3-4   Embedded GNU C Library: Shared lib
ii  libpopt0                      1.16-1     lib for parsing cmdline parameters
ii  libselinux1                   2.0.96-1   SELinux runtime shared libraries

Versions of packages logrotate recommends:
ii  bsd-mailx [mailx]  8.1.2-0.20100314cvs-1 simple mail user agent

logrotate suggests no packages.

-- no debconf information

--- End Message ---
--- Begin Message ---
Package: logrotate
Version: 3.8.5-1

logrotate (3.8.5-1) unstable; urgency=low

  * New upstream release
    + Check for both possible orders of script output in tests.
      (Closes: #707526)
    + If logrotate state file is corrupted, fail with error.
    + Make logrotate state file creation atomic. (Closes: #706484)
    + Add fsync during log copytruncate and gzip+unlink.
    + Allow 'hourly' rotation.
    + Do not try to parse big (16+ MB) config files.
  * Debian patches merged upstream:
    - dst.patch
    - man-startcount.patch
    - man-compressext-576362.patch
    - asprintf-fixes.patch
    - makefile-test-cleanup.patch
    - manpage-hyphens.patch
    - acl-nosys-706050.patch
    - size-longlong-706460.patch
    - timetraveller-704950.patch

 -- Paul Martin <p...@debian.org>  Wed, 26 Jun 2013 22:26:23 +0100


-- 
Paul Martin <p...@debian.org>

--- End Message ---

Reply via email to