1

Topic: Hotfix for iRedMail-0.8.4: Incorrect logrotate config file of iRedAPD

Issue description

There's an typo error in logrotate config file of iRedAPD (/etc/logrotate.d/iredapd) on all Linux distributions supported by iRedMail, it causes program "logrotate" cannot rotate iRedAPD log file (/var/log/iredapd.log) at all. The potential risk is that the log file may takes too much disk space if it grows quickly.

Impacted iRedMail versions
  • Version iRedMail-0.8.4, downloaded before Apr 6, 2013.

Notes:

  • You can see a timestamp in file /etc/logrotate.d/iredapd, that shows when you installed iRedMail. e.g. "File generated by iRedMail (2013.04.03.11.40.51)" (format is YEAR.MONTH.DAY.HOUR.MINUTE.SECOND).

  • We re-packed iRedMail-0.8.4 on Apr 6, 2013, so there's no need to fix it if you downloaded iRedMail-0.8.4 after that day, which means you can safely ignore this hotfix.

  • You don't need this hotfix if your server was upgraded from an old release. e.g. 0.8.3.

Impacted Linux/BSD distributions

It impacts all LINUX distributions supported by iRedMail, but not BSD distributions since they use different logrotate config file.

How to fix it

Please fix it manually by following below steps:

  • Open /etc/logrotate.d/iredapd with your favorite text editor (e.g. vi, vim, emacs), find below line:

/var/log/iredapd.log
  • Append a whitespace and a '{':

/var/log/iredapd.log {
  • You can now verify this config file with command "logrotate" like below, it will print debug message on terminal.

# logrotate -d /etc/logrotate.d/iredapd

That's all.

Credit

All credit goes to our forum user bantopalmarino, thanks for the report here: http://www.iredmail.org/forum/post21327.html#p21327

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: Hotfix for iRedMail-0.8.4: Incorrect logrotate config file of iRedAPD

I Zhang, I have recently update to iredmail 0.8.4, but seems that /etc/logrotate.d/iredapd doesn't exist on my server, is it possible?

==== Required information ====
- iRedMail version: 0.8.4 (First installed version 0.7.4)
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): iRedAdmin-Pro v1.6.0 MySql (First version 1.4.0)
- Linux/BSD distribution name and version: CentOS 6.2 x64
- Related log if you're reporting an issue:
====

3

Re: Hotfix for iRedMail-0.8.4: Incorrect logrotate config file of iRedAPD

Hi agattei,

All Linux distribution should have /etc/logrotate.d/iredapd, no idea about why it wasn't there on your server.

1) Please check whether iRedAPD log file was configured to rotated in other config files under /etc/logrotate.d/.
2) If not configured, you can create it manually with below content:

/var/log/iredapd.log {
    compress
    weekly
    rotate 10
    create 0600 root root
    missingok

    # Use bzip2 for compress.
    compresscmd /bin/bzip2
    uncompresscmd /bin/bunzip2
    compressoptions -9
    compressext .bz2

    postrotate
        /etc/init.d/iredapd restart
    endscript
}

Note: Make sure you have correct paths to bzip2 and bunzip2.

4

Re: Hotfix for iRedMail-0.8.4: Incorrect logrotate config file of iRedAPD

Hi Zhang, thank you for your reply.
This is the output of ls command:

[root@mx logrotate.d]# ls -al
total 56
drwxr-xr-x.  2 root root 4096 Oct  6  2012 .
drwxr-xr-x. 71 root root 4096 Mar 29 00:27 ..
-rw-r--r--   1 root root  161 Sep 23  2012 clamav
-rw-r--r--   1 root root  551 May 21  2012 dovecot
-rw-r--r--.  1 root root  103 Dec  8  2011 dracut
-rw-r--r--.  1 root root  198 Mar  4  2011 fail2ban
-rw-r--r--   1 root root   92 Sep 23  2012 freshclam
-rw-r--r--.  1 root root  185 Jun 24  2010 httpd
-rw-r--r--.  1 root root  173 Dec  8  2011 iscsiuiolog
-rw-r--r--.  1 root root   68 Aug 23  2010 sa-update
-rw-r--r--.  1 root root   81 Jul  2  2010 shorewall
-rw-r--r--.  1 root root  377 Jan  9  2012 sieve
-rw-r--r--.  1 root root  210 Aug  2  2011 syslog
-rw-r--r--.  1 root root  100 Dec  8  2011 yum

now I have created the config file manually (the path to bzip2 and bunzip2 was /usr/bin/...)

After that I have restart iredapd, now how can I check if it's all ok?

5

Re: Hotfix for iRedMail-0.8.4: Incorrect logrotate config file of iRedAPD

As mentioned in my post, you can now verify this config file with command "logrotate" like below, it will print debug message on terminal.

# logrotate -d /etc/logrotate.d/iredapd

6

Re: Hotfix for iRedMail-0.8.4: Incorrect logrotate config file of iRedAPD

ZhangHuangbin wrote:

As mentioned in my post, you can now verify this config file with command "logrotate" like below, it will print debug message on terminal.

# logrotate -d /etc/logrotate.d/iredapd

I'm sorry :-)
This is the output:

[root@mx ~]# logrotate -d /etc/logrotate.d/iredapd
reading config file /etc/logrotate.d/iredapd
reading config info for /var/log/iredapd.log
compress_prog is now /usr/bin/bzip2
uncompress_prog is now /usr/bin/bunzip2
compress_options is now -9
compress_ext is now .bz2

Handling 1 logs

rotating pattern: /var/log/iredapd.log  weekly (10 rotations)
empty log files are rotated, old logs are removed
considering log /var/log/iredapd.log
  log does not need rotating
not running postrotate script, since no logs were rotated

seems to be ok now...

7

Re: Hotfix for iRedMail-0.8.4: Incorrect logrotate config file of iRedAPD

The same here,

no /etc/logrotate.d/iredapd

on an upgraded 0.8.3 to 0.8.4 before Apr 6, 2013 ubuntu 12.04 without configuration in the other config files.
I've created it as mentioned.

On last sunday (after upgrade 0.8.3 -> 0.8.4) I have received these via mail to root:

Subject: Cron <root@hostname> test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
/etc/cron.daily/logrotate:
Stopping iredapd ...
Starting iredapd ...
iredapd is already stopped.
Starting iredapd ...
Traceback (most recent call last):
  File "/opt/iredapd/iredapd.py", line 166, in <module>
    main()
  File "/opt/iredapd/iredapd.py", line 143, in main
    DaemonSocket((settings.listen_address, int(settings.listen_port)))
  File "/opt/iredapd/iredapd.py", line 94, in __init__
    self.bind(localaddr)
  File "/usr/lib/python2.7/asyncore.py", line 341, in bind
    return self.socket.bind(addr)
  File "/usr/lib/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
socket.error: [Errno 98] Address already in use

8

Re: Hotfix for iRedMail-0.8.4: Incorrect logrotate config file of iRedAPD

Hi Bronko,

You can modify /etc/init.d/iredapd, to sleep 2 seconds before starting it again.
Find below line in /etc/init.d/iredapd:

    restart) stop && start ;;

Modify it to:

    restart) stop && sleep 2 && start ;;

9

Re: Hotfix for iRedMail-0.8.4: Incorrect logrotate config file of iRedAPD

Done; thanks!