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

Bug#1437: Debian sendmail



Howdy!

I noticed that the sendmail package,

ftp://ftp.debian.org/debian/binary/mail/sendmail-8.6.12-6.deb

contains a slight error, the included /etc/init.d/sendmail script starts
/usr/sbin/sendmail ok, but 'stop' kills /usr/sbin/cron ! :)

I noticed this when I upgraded and went to restart sendmail,
"Stopped /usr/sbin/cron (pid 123)" ??  Uh, I think not :)


Also, the script "/etc/init.d/functions 2.00 03-Oct-1994" which appears to be
sourced by a number of other /etc/init.d scripts (ppp, xntp, syslogd, etc),
has a minor bug as well.  I currently have sysvinit-2.56-3.deb installed, but
sysvinit-2.57b-0.deb appears to have the same functions script.

Note the following code:

----------------------------------------------------------------------
  # Set RUNLEVEL and PREVLEVEL
  if [ "$RUNLEVEL" = "" ]
  then
        levels=`runlevel`
        if [ $? = 0 ]
        then
                eval set $levels
                PREVLEVEL=$1
                RUNLEVEL=$2
        fi
  fi
----------------------------------------------------------------------

Because it uses 'set' if $RUNLEVEL is not defined, it munges $1 and $2 ...
which may have been arguments the 'real' script needed, i.e "start" or "stop".
This is annoying when, like me, you like to start and stop services
occasionally.  Since these nice init scripts are there, I'd like to use them
to do this consistently.

A quick fix for this, is, if you assume these sripts only accept one argment,
would be to save $1 and restore it.  The other alternative I can think of (not
being a strong /bin/sh programmer), is to turn this section into a function,
and just call it right away, this is what I did.  I was trying to think about
how to use $* or $@ or something to store the previous args, and then later a
set to restore them, but I found this solution to be simpler.

fwiw, I included a patch for how I fixed these at the end.

BTW, where should I look for discusion about 'dpkg' and 'dselect'?  I'm
personally interested in tools like this (standardized software installation,
etc) and may have some input and ideas for improvements.

Cheers,
Brian					http://www.ccs.neu.edu/home/bdowling/


--- sendmail.ORIG       Fri Sep 22 17:03:57 1995
+++ sendmail    Fri Sep 22 17:11:04 1995
@@ -5,7 +5,7 @@

 case "$1" in
 start) start-stop-daemon --start --verbose --exec /usr/sbin/sendmail -- -bd
-q10m ;;
-stop)  start-stop-daemon --stop --verbose --exec /usr/sbin/cron ;;
+stop)  start-stop-daemon --stop --verbose --exec /usr/sbin/sendmail ;;
 *)     echo "Usage: /etc/init.d/sendmail start|stop"; exit 1 ;;
 esac
 exit 0
--- functions.ORIG      Fri Sep 22 16:54:53 1995
+++ functions   Fri Sep 22 17:12:57 1995
@@ -12,6 +12,7 @@
   # First set up a default search path.
   export PATH="/sbin:/usr/sbin:/bin:/usr/bin"

+  setrunlevel() {
   # Set RUNLEVEL and PREVLEVEL
   if [ "$RUNLEVEL" = "" ]
   then
@@ -23,6 +24,9 @@
                RUNLEVEL=$2
        fi
   fi
+  }
+
+  setrunlevel

   # A function to start a program.
   daemon() {


Reply to: