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

According to the LSB specification from

http://refspecs.freestandards.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptfunc.html

the init scripts should not use any other mechanisms than checking on
the pidfile when a pidfile is provided:

  "Conforming implementations may use other mechanisms besides those
   based on pidfiles, unless the -p pidfile option has been used [...]."

This has a good reason: If you start a daemon that is being initialized
by an interpreter (like ruby), the process-name applied to the --name
option that is being looked up in /proc/<pid>/stat will not match the
daemon's name.

As an example, the puppetmaster package comes with an init-script that
will call ruby to get up and running. Thus, the stat file will contain
the label `ruby' and hence stopping of the daemon definitely fails as
the detected name differs from the daemon's name `puppetmasterd'.

I have included a patch that will use the --name option only if no pidfile
has been provided.


-- System Information:
Debian Release: 3.1
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i686)
Kernel: Linux 2.6.8
Locale: [EMAIL PROTECTED], [EMAIL PROTECTED] (charmap=ISO-8859-15)

Versions of packages lsb-base depends on:
ii  ncurses-bin                   5.4-4      Terminal-related programs and man 
ii  sed                           4.1.2-8    The GNU sed stream editor

-- no debconf information
diff -Naur lsb-3.1/init-functions lsb-3.1.patched/init-functions
--- lsb-3.1/init-functions      2006-10-31 02:09:16.000000000 +0100
+++ lsb-3.1.patched/init-functions      2006-11-10 19:57:42.000000000 +0100
@@ -95,8 +95,9 @@
 
 # start-stop-daemon uses the same algorithm as "pidofproc" above.
 killproc () {
-    local pidfile sig status base i
+    local pidfile sig status base i name_param
     pidfile=
+    name_param=
 
     OPTIND=1
     while getopts p: opt ; do
@@ -109,14 +110,15 @@
     base=${1##*/}
     if [ ! $pidfile ]; then
         pidfile=/var/run/$base.pid
+        name_param="--name $base"
     fi
 
     sig=$(echo ${2:-} | sed -e 's/^-\(.*\)/\1/')
     sig=$(echo $sig | sed -e 's/^SIG\(.*\)/\1/')
     if [ -n "$sig" ]; then
-        /sbin/start-stop-daemon --stop --pidfile "$pidfile" --signal "$sig" 
--quiet --name "$base"
+        /sbin/start-stop-daemon --stop --pidfile "$pidfile" --signal "$sig" 
--quiet $name_param
     else
-        /sbin/start-stop-daemon --stop --pidfile "$pidfile" --retry 5 --quiet 
--oknodo --name "$base"
+        /sbin/start-stop-daemon --stop --pidfile "$pidfile" --retry 5 --quiet 
--oknodo $name_param
     fi
     status="$?"
     if [ "$status" = 1 ]; then

Reply via email to