Handle non-world-readable pid files.
authorPeter Eisentraut <petere@debian.org>
Wed, 7 Mar 2012 10:33:43 +0000 (11:33 +0100)
committerDidier Raboud <odyx@debian.org>
Wed, 7 Mar 2012 12:07:36 +0000 (13:07 +0100)
Closes: #653598
Reported-by: Peter Eisentraut <petere@debian.org>
Signed-off-by: Didier Raboud <odyx@debian.org>
init-functions

index 8b14cf7a18507fdf63a283e25a7cc2c7a349cd72..c6460737804bc367d205f4af9aae9d528a3b818f 100644 (file)
@@ -81,7 +81,8 @@ pidofproc () {
         pidfile="/var/run/$base.pid"
     fi
 
-    if [ -n "${pidfile:-}" ] && [ -r "$pidfile" ]; then
+    if [ -n "${pidfile:-}" ]; then
+      if [ -r "$pidfile" ]; then
         read pid < "$pidfile"
         if [ -n "${pid:-}" ]; then
             if $(kill -0 "${pid:-}" 2> /dev/null); then
@@ -94,6 +95,9 @@ pidofproc () {
                 return 1 # program is dead and /var/run pid file exists
             fi
         fi
+      else
+        return 4 # pid file not readable, hence status is unknown.
+      fi
     fi
     if [ -x /bin/pidof ] && [ ! "$specified" ]; then
         status="0"