Bug 706257

Summary: amavis failed to start during boot, however it is active
Product: [openSUSE] openSUSE 12.1 Reporter: Freek de Kruijf <freek>
Component: OtherAssignee: Peter Varkoly <varkoly>
Status: RESOLVED DUPLICATE QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P2 - High CC: forgotten__lyEjnLCxo, lnussel, melchiaros, roland, suse-beta, werner
Version: RC 2   
Target Milestone: ---   
Hardware: x86-64   
OS: SUSE Other   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: Patch for /etc/init.d/amavis
modified /etc/init.d/amavis to work around checkproc

Description Freek de Kruijf 2011-07-16 16:26:10 UTC
User-Agent:       Mozilla/5.0 (X11; Linux x86_64; rv:5.0) Gecko/20100101 Firefox/5.0

Performing a boot (till init 3) there is an error message that amavis-new failed (to start). However "ps aux | grep amavis" shows the master and 2 virgin childs active.
The command "rcamavis stop" gives a green "done". However these three processes are still present. Also "netstat -tlnp" shows a listening process on port 10024. After a "kill <process-id_of_amavisd_(master)> the processes are gone.
After this the command "rcamavis start" shows a red "failed", however the processes are there and the master is listening on port 10024.

Reproducible: Always

Steps to Reproduce:
1.
2.
3.
Actual Results:  
Despite the red "failed" message amavis-new is active, however "rcamavis stop" shows a green "done", however does not stop the amavis processes.

Expected Results:  
A green "done" message on the start of amavis and stopped processes after the "rcamavis stop" command.
Comment 1 Freek de Kruijf 2011-09-17 16:56:52 UTC
This is still a bug in openSUSE 12.1 M5 and has not changed
Comment 2 Freek de Kruijf 2011-09-17 19:14:32 UTC
*** Bug 711006 has been marked as a duplicate of this bug. ***
Comment 3 Freek de Kruijf 2011-09-17 19:24:04 UTC
I compared the file /etc/init.d/amavis between 11.4 and 12.1 and they are the same. However the program /usr/sbin/amavisd is different in these versions. I contacted the maintainer of the amavis project to point him to this problem.

I also tried the command "/usr/sbin/amavisd stop" which did stop the amavisd processes in my system. This also seems to be the command given in "/etc/init.d/amavis stop", which does not work.
Comment 4 Freek de Kruijf 2011-09-17 21:03:09 UTC
Analysing the problem I found that the behavior of checkproc is causing the problem.
While amavisd is active, with three processes, 1 master and 2 childs),
the command "checkproc amavisd ; echo $?" gives on
openSUSE 11.4 the result 0
openSUSE 12.1 the result 3
The command "checkproc /usr/sbin/amavisd ; echo $?" gives on
openSUSE 11.4 the result 3
openSUSE 12.1 the result 3
Reading the manual pages of checkproc I conclude that checkproc on openSUSE 11.4 gives the wrong answer.
This means that the file /etc/init.d/amavis on openSUSE 12.1 is wrong. The return codes of "checkproc amavis" in the script are inverted.

Because the manpage of checkproc always talks about the full patch of the executable I made the attached patch for /etc/init.d/amavis
Comment 5 Freek de Kruijf 2011-09-17 22:00:01 UTC
It is more complicated than I thought, so it will take a while for the patch.
Comment 6 Freek de Kruijf 2011-09-17 22:33:46 UTC
Created attachment 451548 [details]
Patch for /etc/init.d/amavis

I did test the new script for start, stop and status, however not with amavis_milter and not for the other commands.
Comment 7 Christian Boltz 2011-09-18 12:59:05 UTC
CC'ing Werner Fink, the maintainer of sysvinit (which includes checkproc).

Werner, please see comment #4 about the changed (broken?) behaviour of checkproc.
Comment 8 Freek de Kruijf 2011-09-18 15:54:40 UTC
Rereading the manpage of checkproc I found that replacing amavisd by $AMAVISD_BIN as the argument of checkproc is not right. The file /usr/sbin/amavisd is a perl script and in that case IMHO the proper way is to use amavisd.

I also read that the return code should be 0 when that process is active. However that is not the case.

Below is the console log as root in my 12.1 M5 system with the above changes in the /etc/init.d/amavis file.

eik121m5:~ # rcamavis status
Checking for service amavis (amavisd-new):                                                               unused
eik121m5:~ # ps aux | grep amavis
root      2436  0.0  0.0   6780   856 pts/1    S+   17:27   0:00 grep amavis
eik121m5:~ # rcamavis start
Starting virus-scanner (amavisd-new):                                                                    done
eik121m5:~ # ps aux | grep amavis
vscan     2497 15.1 10.2 222172 104240 ?       Ss   17:28   0:01 amavisd (master)                        
vscan     2500  0.0 10.1 223444 103264 ?       S    17:28   0:00 amavisd (virgin child)                  
vscan     2501  0.0 10.1 223444 103260 ?       S    17:28   0:00 amavisd (virgin child)                  
root      2507  0.0  0.0   6780   860 pts/1    S+   17:28   0:00 grep amavis
eik121m5:~ # rcamavis status
Checking for service amavis (amavisd-new):                                                               running
eik121m5:~ # checkproc amavisd ; echo $?
3
!!!! The above is wrong, checkproc should return 0, amavisd is active.!!!!!
!!!! 3 means no process and no pid file (maybe it was searched for /var/run/ !!!
eik121m5:~ # checkproc -p /var/spool/amavis/amavisd.pid amavisd ; echo $?
1
!!!! The above is wrong, checkproc should return 0, amavisd is active.!!!!!
!!!! 1 means no process, but there is a pid file. !!!!
eik121m5:~ # rcamavis stop
Shutting down virus-scanner (amavisd-new): Daemon [2497] terminated by SIGTERM
                                                                                                         done
eik121m5:~ # checkproc -p /var/spool/amavis/amavisd.pid amavisd ; echo $?
3
eik121m5:~ # checkproc amavisd ; echo $?
3
eik121m5:~ #

So maybe the solution is that the pid file is stored in /var/run/, which requires a change in /usr/sbin/amavisd
Comment 9 Ludwig Nussel 2011-09-19 14:19:44 UTC
checkproc exit codes were wrong previously, see bug 687547
Comment 10 Freek de Kruijf 2011-11-07 22:44:45 UTC
There was a message on opensuse-factory that this was solved. However I installed a fresh RC2 and installed amavisd-new from oss, but it still has the same problem.
I also tried amavisd-new from server:mail but still the same problem.
Comment 11 Freek de Kruijf 2011-11-07 23:02:51 UTC
The problem is in checkproc not able to find the amavis processes using the full path. However this information is available see below:

# systemctl start amavis.service
Job failed. See system logs and 'systemctl status' for details.

Despite this failure message amavisd is active.

# systemctl status amavis.service
amavis.service - LSB: Start amavisd-new
          Loaded: loaded (/etc/init.d/amavis)
          Active: failed since Mon, 07 Nov 2011 23:59:37 +0100; 13s ago
         Process: 2573 ExecStart=/etc/init.d/amavis start (code=exited, status=7/NOTRUNNING)
          CGroup: name=systemd:/system/amavis.service
                  ├ 2583 /usr/sbin/amavisd (master)              
                  ├ 2588 /usr/sbin/amavisd (virgin child)        
                  └ 2589 /usr/sbin/amavisd (virgin child)

Above you see that the full patch is available in the system about the amavisd processes. Maybe not at the position where checkproc is expecting it, but elsewhere.
Comment 12 Peter Varkoly 2011-11-08 05:08:01 UTC
diplicate

*** This bug has been marked as a duplicate of bug 723708 ***
Comment 13 Pavel Koshevoy 2011-11-19 17:07:03 UTC
Created attachment 463034 [details]
modified /etc/init.d/amavis to work around checkproc

I've worked around amavis sysvinit script problem by replacing checkproc with a shell script function checkproc_script that simulates the intended checkproc behavior.
Comment 14 Peter Varkoly 2012-01-04 14:44:37 UTC
*** Bug 735918 has been marked as a duplicate of this bug. ***
Comment 15 Bernhard Wiedemann 2012-01-04 15:00:08 UTC
This is an autogenerated message for OBS integration:
This bug (706257) was mentioned in
https://build.opensuse.org/request/show/98762 Factory / amavisd-new
https://build.opensuse.org/request/show/98763 12.1 / amavisd-new
Comment 16 Peter Varkoly 2012-01-11 14:56:44 UTC
*** Bug 739673 has been marked as a duplicate of this bug. ***