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

Bug#653598: status_of_proc should handle not-world-readable pid files better



Le 07.03.2012 11:37, Didier 'OdyX' Raboud a écrit :
> Agreed. I committed the attached patch, attributed to you (as it's not
> 100% the same patch, but equal in functionality and essence).

Meh, failed at attaching.
From 1a02293da50c624a01c61c6fd4e956215726994a Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <petere@debian.org>
Date: Wed, 7 Mar 2012 11:33:43 +0100
Subject: [PATCH] Handle non-world-readable pid files.

Closes: #653598
Reported-by: Peter Eisentraut <petere@debian.org>
Signed-off-by: Didier Raboud <odyx@debian.org>
---
 init-functions |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/init-functions b/init-functions
index 8b14cf7..5b951f0 100644
--- a/init-functions
+++ b/init-functions
@@ -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 redable, hence status is unknown.
+      fi
     fi
     if [ -x /bin/pidof ] && [ ! "$specified" ]; then
         status="0"
-- 
1.7.2.5

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: