pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pkg/31571: mail/dspam rc script can run too early, and it assumes dspam=YES



>Number:         31571
>Category:       pkg
>Synopsis:       mail/dspam rc script can run too early, and it assumes 
>dspam=YES
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Oct 12 20:00:00 +0000 2005
>Originator:     Jim Bernard
>Release:        NetBSD 3.99.9
>Organization:
>Environment:
System: NetBSD 3.99.9: Sat Sep 24 20:45:22 MDT 2005 i386
Architecture: i386
Machine: i386
>Description:
        There are two separate problems with the daemon startup script,
        dspam.sh:

        1) It is configured to be sorted by rcorder according to:

             PROVIDE: dspam
             BEFORE:  DAEMON

           The result is that, if the script is located someplace other
           than /etc/rc.d (e.g., /etc/pkg/rc.d or /usr/pkg/etc/rc.d), with
           /etc/rc modified to search /etc/rc.d (first) and the second
           directory for scripts, dspam is sorted to run prior to all other
           startup scripts.  That is, its configuration does not pin down its
           position in the execution sequence adequately, and its placement
           in the list of arguments to rcorder can have a huge and undesirable
           impact on its position in the execution sequence.

        2) There is a section at the end of the script that sets up the
           pidfile if the script is executed with any arguments other
           than "stop" or "status".  This section doesn't bother to check
           whether the daemon is configured to run in /etc/rc.conf, so
           it is executed even if rc.conf says "dspam=NO".

>How-To-Repeat:
        * Install mail/dspam, with the rc.d script placed in a location
          separate from /etc/rc.d (e.g., via something like
            RCD_SCRIPTS_DIR= ${PKG_SYSCONFBASEDIR}/rc.d
          in /etc/mk.conf).  That location must be somewhere on the root
          file system (e.g., /etc/pkg/rc.d).

        * Modify /etc/rc to search that other location as well as /etc/rc.d
          for startup scripts.

        * Run rcorder to see what it produces.  E.g.:

            rcorder -s nostart /etc/rc.d/* /etc/pkg/rc.d/*

          and note that dspam is listed first.  This demonstrates the
          first problem noted above.

        * Set dspam=NO in /etc/rc.conf and reboot.  Notice an error message
          complaining that the pid file /var/run/dspam/dspam.pid cannot be
          created, because of a missing directory.  This will be the first
          message from the multiuser startup scripts.  I believe this is caused
          by the combination of the two problems cited above.  dspam runs
          first in the startup sequence, before /var is even mounted, and it
          insists on trying to write the pid file, even if dspam=NO in rc.conf,
          so that the daemon isn't executed.  (The missing piece to the
          puzzle is that it seems like mkdir -p /var/run/dspam should create
          the path even if /var isn't yet mounted, so it's not completely
          clear why the missing-directory error occurs.  I haven't investigated
          that further, but it seems clear that the problems noted above are
          real and should be fixed.)
>Fix:
        I think it's probably best to run the daemon after SERVERS (which
        is where rcorder puts it if dspam is placed in /etc/rc.d), so
        I require that.  The patch to the pidfile section first checks the
        value of the rcvar "dspam".

--- dspam-dist  2005-10-11 12:37:51.000000000 -0600
+++ dspam       2005-10-12 12:16:44.000000000 -0600
@@ -2,10 +2,11 @@
 #
 # $NetBSD: dspam.sh,v 1.2 2005/04/26 15:43:26 jwise Exp $
 #
 
 # PROVIDE: dspam
+# REQUIRE: SERVERS
 # BEFORE:  DAEMON
 
 if [ -f /etc/rc.subr ]; then
        . /etc/rc.subr
 fi
@@ -63,8 +64,8 @@
                fi
                ;;
                esac
 fi
 
-if [ "$1" != "stop" -o "$1" != "status" ]; then
+if checkyesno "${rcvar}" && [ "$1" != "stop" -o "$1" != "status" ]; then
        echo $(check_process $command) > $pidfile
 fi




Home | Main Index | Thread Index | Old Index