Comment 24 for bug 387189

Revision history for this message
Andi Hechtbauer (anti-dotu) wrote : Re: /dev/null corrupted (/dev/null.1)

I think I tracked this down to a syntax thinko in /etc/logrotate.d/apache2 (installed by apache2.2-common), when /etc/apache2/envvars doesn't exist - which can happen easily, e.g., when you do not really need apache2 but only something from the -common package:

logrotate -d /etc/logrotate.conf 2>&1 gives me:

[...]
reading config file apache2
error: error accessing /var/log/apache2: No such file or directory
error: apache2:1 glob failed for /var/log/apache2/*.log
error: found error in /var/log/apache2/*.log , skipping
removing last 1 log configs
error: apache2:11 lines must begin with a keyword or a filename (possibly in double quotes)
error: apache2:12 missing end of line
reading config info for /etc/init.d/apache2 reload > /dev/null
                fi
        endscript
}
[...]
 weekly (4 rotations)
empty log files are rotated, old logs are removed
considering log /etc/init.d/apache2
  log does not need rotating
considering log reload
error: stat of reload failed: No such file or directory
considering log >
error: stat of > failed: No such file or directory
considering log /dev/null
  log does not need rotating
considering log fi
error: stat of fi failed: No such file or directory
considering log endscript
error: stat of endscript failed: No such file or directory
considering log }
error: stat of } failed: No such file or directory

Obviously logrotate fails to parse the output of the backticked command. And trys to interpret the following lines as filenames that should be logrotated. The only file that exists is /dev/null.

Removing the unneeded apache2 logrotate script corrects the logrotate -d output and the behaviour.

I think there could be more than one way to fix this bug:

1. in apache-common: correct the if-statement, taking into account /etc/apache2/envvars might not even exist.
2. in logrotate: make logrotate check if it is told to operate on a regular file (like savelog does)
3. let logrotate discard an erroneous config file, instead of trying to interpret too much.
...

But the quick workaround: remove /etc/logrotate.d/apache2 if you don't need it.