Package: debian-goodies
Version: 0.69.1
Severity: important
Tags: stretch buster patch

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Dear maintainers,

checkrestart fails without setting an error code when lsof is not found,
and reports 0 processes needing to be restarted:

        $ sudo checkrestart
        /bin/sh: 1: lsof: not found
        Found 0 processes using old versions of upgraded files


checkrestart should instead error-out.
Please find enclosed patches to that effect.


Best,

  nicoo

-----BEGIN PGP SIGNATURE-----

iQJNBAEBCgA3FiEEiWEbFKE2h/s1SpJPnU+IAQz+GeMFAloAykkZHG5pY29sYXNA
YnJhdWQtc2FudG9uaS5ldQAKCRCdT4gBDP4Z4wm/EAC9zl+i3CtlfaVlFV22jY+F
iy5iJWqSKgEYPNjpwwbzQQgthLloDhYGnhWE8AL0kwwrKvYo1jbMLErny1QoYT/X
l4Vm6GRPlWJRXSU7+yU779JEBlYGyAmkKXbZPoxC7zPF157m39cANQ1IWeT6BwJh
DhmgkDyY3rxyfnWu1Q21w+Tj+5gXe/d4ZkyABBfDTDajmtkxT2SXADq6Dv80kAxw
vdvnB7+ChxtlCHPcScVlNu0NiiJaAC1s2gHEIej6JVVxHdi1C4MJ5D8/Q6+mviA5
Ei7+9yLl7AFrcUUrjY9DmBdgTFLclP1oghmeLcago7EATNrbITRD8ylpKEHW0XRj
zMQMras+apwcm213feBVNw4RkKroLIwWSVqNtg3wy7RfkJ9+Ume7qnA3O6ucIW5K
2GjDYT4LULQhMV1xvgtB2yoLYtS8xkoy38I3yZqzk+anYUV8ztmnV1VegCDlfCAu
rvx8B6vasQGxpDoU/D6wjOxPdjUtBCCj2iO5rq9YxnuvLskUj8w6FFM0k7PftLo/
c7R5WN6s0sm7JcaApmO7UcOfEi14YIkbf9rz92QM5P9D6YiMdVxyn5DFPC2cQYp+
kGTJkyDCMrrJ+aTZ+UFx6MHiH+HutZZRsXQ4P4WIUxTef2CxLSC54AI6l2/Z23hG
B/YNydO0wT1T+DJSTyqtpQ==
=u3oC
-----END PGP SIGNATURE-----
>From 6e97f7cf789fd8ab2672d9b4faff11de99e865bb Mon Sep 17 00:00:00 2001
From: Nicolas Braud-Santoni <nico...@braud-santoni.eu>
Date: Mon, 6 Nov 2017 21:44:18 +0100
Subject: [PATCH 1/2] checkrestart: Properly error-out when calling lsof fails

---
 checkrestart | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/checkrestart b/checkrestart
index 52dbc70..abf920d 100755
--- a/checkrestart
+++ b/checkrestart
@@ -320,9 +320,10 @@ def main():
 
 def lsoffilescheck(blacklist = None):
 # Use LSOF to extract the list of deleted files
+    from subprocess import check_output
     processes = {}
 
-    for line in os.popen('lsof +XL -F nf').readlines():
+    for line in check_output(['lsof', '+XL', '-F', 'nf']).splitlines():
         field, data = line[0], line[1:-1]
 
         if field == 'p':
-- 
2.14.2

>From dc228ead6cddd9bd2ce6737388917ff236d48070 Mon Sep 17 00:00:00 2001
From: Nicolas Braud-Santoni <nico...@braud-santoni.eu>
Date: Mon, 6 Nov 2017 21:44:51 +0100
Subject: [PATCH 2/2] checkrestart: Properly error-out when calling pmap fails

---
 checkrestart | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/checkrestart b/checkrestart
index abf920d..4fc299a 100755
--- a/checkrestart
+++ b/checkrestart
@@ -364,6 +364,7 @@ def lsoffilescheck(blacklist = None):
 def procfilescheck(blacklist = None, excludepidlist = None):
 # Use the underlying /proc file system to determine processes that
 # are using deleted files
+    from subprocess import check_output
     processes = {}
     # Get a list of running processes
     pids = [pid for pid in os.listdir('/proc') if pid.isdigit()]
@@ -386,7 +387,7 @@ def procfilescheck(blacklist = None, excludepidlist = None):
             continue
 
         # Get the list of memory mapped files using system pmap
-        for output in os.popen('pmap ' + pid).readlines():
+        for output in check_output(['pmap', pid]).splitlines():
             data = re.split('\s+', output.strip('\n'), 3)
             if len(data) == 4:
                 f = data[3]
-- 
2.14.2

Reply via email to