Package: lsb-base
Version: 3.1-6
Severity: important
Tags: patch

killproc() fails if the optional signal argument isn't supplied.  There
are two problems here:

1) specified takes the value of either 0 or 1, both of which
evaluate to true when tested at line 111 using "if [ $specified ]".

2) Inside that block, it's then assumed that a signal argument was
passed, but sig will end up empty if that wasn't the case, resulting in
an error from start-stop-daemon.

The solution in the attached patch is to initialise specified to an
empty string, which evaluates to false and makes the test meaningful.
Secondly, after fiddling with sed, we fall back to setting sig to TERM
if it is still empty.

Tested briefly with both bash and dash.


-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.16-1-amd64-k8-smp
Locale: LANG=en_AU.UTF-8, LC_CTYPE=en_AU.UTF-8 (charmap=UTF-8)

Versions of packages lsb-base depends on:
ii  ncurses-bin                   5.5-2      Terminal-related programs and man 
ii  sed                           4.1.5-1    The GNU sed stream editor

lsb-base recommends no packages.

-- no debconf information
--- /lib/lsb/init-functions     2006-06-02 04:19:47.000000000 +1000
+++ ./init-functions    2006-06-03 16:25:06.000000000 +1000
@@ -94,7 +94,7 @@
     local pidfile sig status base i specified
     set -- `POSIXLY_CORRECT=1 getopt "p:" $*`
     pidfile=
-    specified=0
+    specified=
 
     for i in $*; do
         case $i in
@@ -111,6 +111,7 @@
     if [ $specified ]; then
         sig=$(echo $2 | sed -e 's/^-\(.*\)/\1/')
         sig=$(echo $sig | sed -e 's/^SIG\(.*\)/\1/')
+        sig=${sig:-TERM}
         /sbin/start-stop-daemon --stop --pidfile "$pidfile" --signal $sig 
--quiet --name "$base"
         status="$?"
         [ "$status" = 1 ] && return 3 # program is not running

Reply via email to