Bug 11407 - Pidfile mismatch between /etc/amavisd/amavisd.conf and /etc/init.d/amavisd
Summary: Pidfile mismatch between /etc/amavisd/amavisd.conf and /etc/init.d/amavisd
Status: RESOLVED FIXED
Alias: None
Product: Mageia
Classification: Unclassified
Component: RPM Packages (show other bugs)
Version: 3
Hardware: All Linux
Priority: Normal normal
Target Milestone: ---
Assignee: QA Team
QA Contact:
URL:
Whiteboard: advisory MGA3-64-OK MGA3-32-OK
Keywords: validated_update
Depends on:
Blocks:
 
Reported: 2013-10-08 11:55 CEST by Luca Olivetti
Modified: 2014-05-08 18:05 CEST (History)
5 users (show)

See Also:
Source RPM: amavisd-new-2.8.0-14.mga3.src.rpm
CVE:
Status comment:


Attachments

Description Luca Olivetti 2013-10-08 11:55:39 CEST
The default for amavisd is to write the pidfile in /var/lib/amavis/amavisd.pid, however /etc/init.d/amavisd specifies /var/run/amavis/amavisd.pid.
The result is that systemd gets confused and thinks amavisd didn't start:

# systemctl status amavisd
amavisd.service - LSB: A Mail Virus Scanner
          Loaded: loaded (/etc/rc.d/init.d/amavisd)
          Active: failed (Result: timeout) since Tue, 2013-10-08 11:43:00 CEST; 1min 10s ago
         Process: 6248 ExecStart=/etc/rc.d/init.d/amavisd start (code=exited, status=0/SUCCESS)
          CGroup: name=systemd:/system/amavisd.service
                  â 6257 /usr/sbin/amavisd (master)
                  â 6263 /usr/sbin/amavisd (ch1-avail)
                  â 6264 /usr/sbin/amavisd (ch1-avail)
                  â 6265 /usr/sbin/amavisd (ch1-avail)
                  â 6266 /usr/sbin/amavisd (ch1-avail)
                  â 6267 /usr/sbin/amavisd (ch1-avail)


worse, it cannot stop or restart it.

To solve the problem I had to

1) edit /etc/init.d/amavisd to specify the correct pid file /var/lib/amavis/amavisd.pid [*]
2) systemctl stop amavisd
3) manually kill amavisd (since 3 cannot work)
4) systemctl --system daemon-reload
5) systemctl start amavisd

After that systemctl shows the correct status:

# systemctl status amavisd
amavisd.service - LSB: A Mail Virus Scanner
          Loaded: loaded (/etc/rc.d/init.d/amavisd)
          Active: active (running) since Tue, 2013-10-08 11:45:08 CEST; 6min ago
         Process: 6579 ExecStart=/etc/rc.d/init.d/amavisd start (code=exited, status=0/SUCCESS)
        Main PID: 6588 (/usr/sbin/amavi)
          CGroup: name=systemd:/system/amavisd.service
                  â 6588 /usr/sbin/amavisd (master)
                  â 6596 /usr/sbin/amavisd (ch3-avail)
                  â 6597 /usr/sbin/amavisd (ch3-avail)
                  â 6598 /usr/sbin/amavisd (ch2-avail)
                  â 6599 /usr/sbin/amavisd (ch2-avail)
                  â 6600 /usr/sbin/amavisd (ch2-avail)



[*] maybe now pid files should be under /var/run, but simply shipping an updated amavisd.conf wouldn't solve the problem for upgrades (like my case, where I just upgraded my mail server from mageia 2 to mageia 3).

Reproducible: 

Steps to Reproduce:
Comment 1 David Walser 2013-10-08 17:13:55 CEST
The /var/run location is the correct one for PID files, so it should be patched to store its PID file in the location matching what's in the init script.

Hardware: x86_64 => All
Assignee: bugsquad => thomas

Comment 2 David Walser 2013-10-08 17:14:25 CEST
And actually if you're patching it anyway, even better to change both to say /run instead of /var/run
Comment 3 Thomas Spuhler 2013-10-10 19:02:57 CEST
Why do we need a patch. It is already in /var/run/

I have no problem with amavisd in relation to the PID file.
Neither for stopping nor for restart (or start).
What takes up to 10 minutes is the command 
systemctl status amavisd
to complete. 

But this isn't an amavisd problem, it's a problem with every program.
Comment 4 David Walser 2013-10-10 19:18:23 CEST
According to this report, it's not consistently using the same PID location specification everywhere.  I haven't confirmed this myself.  Certainly if systemctl status is taking 10 minutes, there's a problem, and it certainly does not affect everything (I haven't seen this behavior at all).
Comment 5 Luca Olivetti 2013-10-10 21:53:15 CEST
I just downloaded amavisd-new-2.8.0-14.mga3.noarch.rpm to check if I did a mistake, but it is exactly as I reported: amavisd, if not configured specifically, uses /var/lib/amavis/amavisd.pid, the supplied configuration doesn't override the default (and even if it did it wouldn't work for upgrades).
The init file however specifies "pidfile: /var/run/amavis/amavisd.pid".
This causes the symptoms I reported originally, I don't understand how it is possible that it works for you.
Maybe it doesn't but you don't realize it: it takes forever to start because it doesn't find the pidfile and eventually it will timeout.
For the same reason it will tell it has stopped it while it is still running.
Comment 6 Thomas Spuhler 2013-10-11 01:13:07 CEST
You may need to update your /etc/amavisd/amavisd.conf
you should have a line:
$MYHOME = '/var/run/amavis';   # a convenient default for other settings, -H

This should take care of the location of several tmp files
Comment 7 Luca Olivetti 2013-10-11 09:11:02 CEST
1) that's wrong, at least some of the files under $MYHOME are permanent, so they shouldn't be under /var/run (see  http://www.pathname.com/fhs/2.2/fhs-5.13.html vs. http://www.pathname.com/fhs/2.2/fhs-5.8.html). There are other configuration parameters to fine tune individual directories without touching $MYHOME (e.g. there's one for the pidfile, named $pid_file).

2) even if it were right, the default configuration supplied with the package doesn't specify the correct directory for the pid file.

3) even if the package supplies a corrected configuration file, that wouldn't solve the problem for updates, that's why I proposed to change the pidfile in the init file (which would replace the existing one for update)

4) maybe the correct solution would be to patch amavis to conform to the fhs

5) even better would be to adopt the debian solution: patch amavisd to read a directory of configuration files instead of a single file, put there a default configuration with the correct settings, leaving users the option to override the settings in another file (though this approach too has problems for upgrades). See http://packages.debian.org/wheezy/amavisd-new
Comment 8 Luca Olivetti 2013-10-11 09:15:25 CEST
The bug has been introduced here
http://svnweb.mageia.org/packages/cauldron/amavisd-new/current/SOURCES/amavisd-new-2.4.5-init.patch?r1=389214&r2=400941

i.e, it patches the init file without patching anything else.
Comment 9 Thomas Spuhler 2013-10-16 03:44:26 CEST
See comment 2. The pid file needs to be in /run
This make certain that it's being deleted when we reboot the box and we don't have a stale PID file as in the past and amavisd doesn't start.
I am going to close this as invalid.

Status: NEW => RESOLVED
Resolution: (none) => INVALID

Comment 10 Luca Olivetti 2013-10-16 08:59:57 CEST
My solution may be invalid, but the bug certainly stands. According to comment 2 both the init file and amavisd need to be patched so that both point to the same file.
In fact, there's already a patch 
http://svnweb.mageia.org/packages/cauldron/amavisd-new/current/SOURCES/amavisd-new-mga_conf-2.diff?view=log that changes the default location of $MYHOME, it should be amended to also change $pid_file (in "sub supply_after_defaults") so that it points to /run/amavisd.pid.
Or maybe just change the init file to supply the -P option to amavisd

Status: RESOLVED => REOPENED
Resolution: INVALID => (none)

Comment 11 Colin Guthrie 2013-11-04 19:59:12 CET
Hmm, one of my servers seemed to get stung by this on reboot today... Can't say I can work out what's going on here as the configs on a working server are near identical to one on a broken one.

I guess the best fix is just to pass -P /run/amavis/amavis.pid on the command line in the initscript, that way it's specified absolutely? WDYT?

CC: (none) => mageia

Comment 12 Colin Guthrie 2013-11-04 20:48:50 CET
Converted to native systemd unit in cauldron and mga3 updates testing. Will test this myself tomorrow once the package has bubbled through.
Comment 13 Thomas Spuhler 2013-11-12 18:00:44 CET
Colin, thanks for doing this.
Have you been able to run some tests?
If not, I think, I am going to upgrade my mga3 box with amavis from update-testing.
I have a quite a lot of e-mails coming in from all the mailing lists.
Comment 14 Colin Guthrie 2013-11-12 18:29:28 CET
Oh yeah, forgot to report back. Been using this for 1 week now and seems to be going strong:

amavisd.service - AMAVIS interface between MTA and content checkers
	  Loaded: loaded (/usr/lib/systemd/system/amavisd.service; enabled)
	  Active: active (running) since Mon, 2013-11-04 23:37:42 GMT; 1 weeks and 0 days ago
	 Process: 8070 ExecStart=/usr/sbin/amavisd -c /etc/amavisd/amavisd.conf -P /run/amavis/amavis.pid (code=exited, status=0/SUCCESS)
	Main PID: 8071 (/usr/sbin/amavi)
	  CGroup: name=systemd:/system/amavisd.service
		  â  8071 /usr/sbin/amavisd (master)
		  â 28813 /usr/sbin/amavisd (ch9-avail)
		  â 28954 /usr/sbin/amavisd (ch7-avail)
Comment 15 David Walser 2013-11-13 16:43:36 CET
Is this ready to be tested and pushed as an update?  Please assign to QA if so.
Comment 16 Thomas Spuhler 2013-11-13 17:22:15 CET
(In reply to David Walser from comment #15)
> Is this ready to be tested and pushed as an update?  Please assign to QA if
> so.

David:
I only upgraded my server this morning. 
I haven't found a problem when enabling or starting it. But
I would like to have it running for a least a full day.
So be a little patient. This is a package we cannot afford it to fail.
Comment 17 Thomas Spuhler 2013-11-14 16:49:25 CET
I have been running this update for a day, processing some hunderts of e-mails.
I don't see any regressions.
The program starts and creates the tempdirs at the desired location. 
The package to be updated is amavisd-new-2.8.0
I am going to assign this to QA

CC: (none) => thomas
Assignee: thomas => qa-bugs

Comment 18 Dave Hodgins 2013-11-30 14:47:00 CET
Advisory 11407.adv committed to svn

CC: (none) => davidwhodgins
Whiteboard: (none) => advisory

Comment 19 Dave Hodgins 2013-11-30 19:37:08 CET
Testing complete on Mageia 3 i586 and x86_64.

Someone from the sysadmin team please push 11407.adv to updates.

Keywords: (none) => validated_update
Whiteboard: advisory => advisory MGA3-64-OK MGA3-32-OK
CC: (none) => sysadmin-bugs

Comment 20 Thomas Backlund 2013-11-30 23:03:06 CET
Update pushed:
http://advisories.mageia.org/MGAA-2013-0127.html

Status: REOPENED => RESOLVED
CC: (none) => tmb
Resolution: (none) => FIXED

Comment 21 Luca Olivetti 2013-12-01 10:20:57 CET
Somebody forgot to remove the boilerplate text from the advisory

"Advisory text to describe the update.
Wrap lines at ~75 chars."
Comment 22 Nicolas Vigier 2013-12-01 10:55:39 CET
Boilerplate text removed. Thanks.

CC: (none) => boklm

Comment 23 Dave Hodgins 2013-12-02 19:30:43 CET
(In reply to Nicolas Vigier from comment #22)
> Boilerplate text removed. Thanks.

Thanks. Sorry about that.
Nicolas Vigier 2014-05-08 18:05:59 CEST

CC: boklm => (none)


Note You need to log in before you can comment on or make changes to this bug.