4.10-1: Cannot create + lock headers file ...

Quentin Campbell Q.G.Campbell at NEWCASTLE.AC.UK
Thu Dec 5 15:31:38 GMT 2002


On Thu, 5 Dec 2002, Julian Field wrote:

[snip]
> Did the restart shut down the old version of MailScanner before starting
> the new one? With the new "PID File" instead of "PID Dir" it is much easier
> to kill MailScanner as you have just 1 pid to kill which will take out the
> whole lot, particularly if you do
>          /bin/kill -- -12345
> where 12345 is the PID you are trying to kill. That will kill the whole
> process group at once.
>

Julian

It looks like the restart does not shut down the old version of MS.

After restarting MS I am left with the following MS processes:

[root at cheviot4 init.d]# ps -ef | grep Mail
root 28023  1     0 13:17 ?  00:00:00 /usr/bin/perl -I/opt/MailScanner
root 29335 28023  0 13:43 ?  00:00:09 /usr/bin/perl -I/opt/MailScanner

Process 28023 is the original parent but the child process, 29335, changes
after each restart. I expected to see a new parent process.

If I look at the file /opt/MailScanner/var/MailScanner.pid it contains the
old parent process:

[root at cheviot4 etc]# ls -l /opt/MailScanner/var/MailScanner.pid
-rw-------    1 root     root            6 Dec  5 13:17
/opt/MailScanner/var/MailScanner.pid

[root at cheviot4 etc]# cat /opt/MailScanner/var/MailScanner.pid
28023

I suspect the problem lies with the new /etc/init.d/MailScanner file
(obtained from the 4.10-1 RPM tar ball).

It does not use the /opt/MailScanner/var/MailScanner.pid file directly to
obtain the PID of the parent process and instead uses "killproc
MailScanner & pid=`pidofproc MailScanner`" both of which do _not_ work in
my environment.

I have attached the contents of /etc/init.d/MailScanner.

Quentin
--
PHONE: +44 191 222 8209     Computing Service, University of Newcastle
FAX:   +44 191 222 8765     Newcastle upon Tyne, United Kingdom, NE1 7RU.
-------------------------------------------------------------------------
"Any opinions expressed above are mine. The University can get its own."
-------------- next part --------------
#!/bin/bash
#
# mailscanner   This shell script takes care of starting and stopping
#               MailScanner, and its associated copies of sendmail.
#
# chkconfig: 2345 80 30
# description: MailScanner is an open-source E-Mail Gateway Virus Scanner.
# processname: MailScanner
# config: /etc/MailScanner/MailScanner.conf
# pidfile: /var/run/MailScanner.pid

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

QUEUETIME=15m
WORKDIR=/var/spool/MailScanner/incoming
INQDIR=/var/spool/mqueue.in

# Source mailscanner configureation.
if [ -f /etc/sysconfig/MailScanner ] ; then
        . /etc/sysconfig/MailScanner
fi
export QUEUETIME
export WORKDIR
export INQDIR

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

## NCL Nov/02

[ -f /usr/local/MailScanner/bin/check_MailScanner ] || exit 0
[ -f /usr/sbin/sendmail ] || exit 0

# Start both the sendmail processes
StartInSendmail() {
        /usr/bin/newaliases > /dev/null 2>&1
        if test -x /usr/bin/make -a -f /etc/mail/Makefile ; then
            make -C /etc/mail -q
        else
            for i in virtusertable access domaintable mailertable ; do
                if [ -f /etc/mail/$i ] ; then
                    makemap hash /etc/mail/$i < /etc/mail/$i
                fi
            done
        fi
        /usr/sbin/sendmail -bd -ODeliveryMode=queueonly \
                           -OQueueDirectory=$INQDIR
        success
        echo
}
StartOutSendmail() {
        /usr/sbin/sendmail $([ -n "$QUEUETIME" ] && echo -q$QUEUETIME)
        success
        echo
}

RETVAL=0

# See how we were called.
case "$1" in
  start)
	# Start daemons.
	echo 'Starting MailScanner daemons:'
        echo -n '         incoming sendmail: '
	StartInSendmail
        echo -n '         outgoing sendmail: '
	StartOutSendmail
	echo -n '         MailScanner:       '
	/usr/local/MailScanner/bin/check_MailScanner >/dev/null
	RETVAL=$?
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/MailScanner
	success
	echo
	;;
  stop)
	# Stop daemons.
	echo    'Shutting down MailScanner daemons:'
	echo -n '         MailScanner:       '
	killproc MailScanner
	echo
	echo -n '         incoming sendmail: '
	killproc sendmail 2>/dev/null
	echo
	echo -n '         outgoing sendmail: '
	killproc /usr/sbin/sendmail 2>/dev/null
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/MailScanner
	# Clear out all the old pid files
	rm -f /var/run/MailScanner.pid
	# Clear out the old incoming dirs
	cd $WORKDIR && ls | xargs /bin/rm -rf
	;;
  status)
        # Work out if all of MailScanner is running
	echo    'Checking MailScanner daemons:'
        echo -n '         MailScanner:       '
        pid=`pidofproc MailScanner`
        if [ -z "$pid" ] ; then failure; else success; fi
        echo
        # Now the incoming sendmail
        echo -n '         incoming sendmail: '
        pid=`ps ax | grep 'sendmai[l]: accepting connections'`
        if [ -z "$pid" ] ; then failure; else success; fi
        echo
        # Now the outgoing sendmail
        echo -n '         outgoing sendmail: '
        # More complex regexp to handle other RedHats
        pid=`ps ax | egrep '\[sendmail\]|sendmai[l] -q[0-9]*[mhd]|sendmail: Queue runner'`
        if [ -z "$pid" ] ; then failure; else success; fi
        echo
        ;;
  reload)
	echo    'Reloading MailScanner workers:'
        echo -n '         MailScanner:       '
	pid=`pidofproc MailScanner`
	if [ -z "$pid" ] ; then
	  failure
	else
	  /bin/kill -HUP -- -$pid
	  success
	fi
	echo
	;;
  restart)
	$0 stop
	sleep 2
	$0 start
	RETVAL=$?
	;;
  *)
	echo "Usage: service MailScanner {start|stop|status|restart}"
	exit 1
esac

exit $RETVAL


More information about the MailScanner mailing list