Package: lsb-base
Version: 3.2-13
Severity: normal
Tags: patch

This patch fixes a couple of minor issues with pidofproc() and reverts a
patch to status_of_proc().

pidofproc():
        
         * If a pidfile is available, but the euid is not that of the
        process owner (or root), the "kill -0" call will fail with
        "Operation not permitted".  This patch adds an "elif" block that
        uses "ps" to check for a matching process in the process table.
        Note that in cases where the pidfile is not available
        and /bin/pidof is used, such an ownership check is *not*
        performed.
        
         * The /bin/pidof call needs to "|| status="$?" in order to be
        "set -e" safe.  This is a patch that Ubuntu is carrying and
        should be applied to Debian.
        
         * Also, per [1], pidofproc() should probably return 3 if the
        program is not running.  At least it does at one point in the
        function, but not in the last return.  Ubuntu has also been
        carrying this patch for some time.

status_of_proc():

         * So this patch reverts my last one for Bug #483285 (sorry!).
        That fix was to solve the problem that pidofproc() required
        privileges to do the "kill -0".  At the urging of Matt Zimmerman
        and Steve Lanagasek, I fixed the problem in pidofproc() instead
        of hacking around it in status_of_proc().

[1] 
http://refspecs.linux-foundation.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html



-- System Information:
Debian Release: lenny/sid
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.24-19-generic (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
--- lsb.debian/lsb-3.2/init-functions	2008-07-08 22:00:08.000000000 -0500
+++ lsb/lsb-3.2/init-functions	2008-07-09 14:04:45.000000000 -0500
@@ -81,14 +81,17 @@ pidofproc () {
             if $(kill -0 "${pid:-}" 2> /dev/null); then
                 echo "$pid"
                 return 0
+            elif ps "${pid:-}" 2>&1 >/dev/null; then
+                echo "$pid"
+                return 0 # program is running, but not owned by this user
             else
                 return 1 # program is dead and /var/run pid file exists
             fi
         fi
     fi
     if [ -x /bin/pidof -a ! "$specified" ]; then
-        /bin/pidof -o %PPID $1
-        status="$?"
+        status="0"
+        /bin/pidof -o %PPID $1 || status="$?"
         if [ "$status" = 1 ]; then
             return 3 # program is not running
         fi
@@ -137,7 +140,7 @@ killproc () {
         if [ -n "$sig" ]; then
             return 0
         fi
-        return 0 # program is not running
+        return 3 # program is not running
     fi
 
     if [ "$status" = 0 -a "$is_term_sig" = yes ]; then
@@ -152,18 +155,14 @@ status_of_proc () {
     daemon="$1"
     name="$2"
     status="0"
-    if [ -x /bin/pidof ]; then
-        /bin/pidof -o %PPID "$daemon" >/dev/null || status="$?"
-        if [ "$status" = 0 ]; then
-            log_success_msg "$name is running."
-        else
-            log_failure_msg "$name is not running."
-        fi
+    pidofproc $daemon >/dev/null || status="$?"
+    if [ "$status" = 0 ]; then
+        log_success_msg "$name is running."
+        return 0
     else
-        log_failure_msg "/bin/pidof not available."
-        status="1"
+        log_failure_msg "$name is not running."
+        return $status
     fi
-    return "$status"
 }
 
 log_use_fancy_output () {

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to