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

I ran into this bug recently.  In my case it turned out to be a
program that changed its argv0 whereby the resulting /proc/PID/cmdline
contained "empty string" arguments (i.e. adjacent null bytes).  I've
been able to reproduce it as follows:

$ cat > ./-foo.py # start w/ - to be treated as option
#!/usr/bin/python
import time
with open('/__foo'):
  time.sleep(3600)

$ sudo touch /__foo
$ python -- -foo.py '' # keeps running
$ sudo rm -i /__foo
$ sudo checkrestart
AttributeError: 'list' object has no attribute 'startswith'

Which brought me to a second bug when I forgot the argument:

$ python -- -foo.py # no empty arg
$ sudo checkrestart
IndexError: list index out of range

I've attached a patch for both bugs.  I would also like to suggest
changing the /usr/bin/(perl|python) regex to include ruby.


- - Felix
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)
Comment: Using GnuPG with Icedove - http://www.enigmail.net/

iQIcBAEBCgAGBQJTVoSnAAoJELIY/ywn/GzGTncP/1zdVhIuSNB2qtX610Q0te/g
3mC8fGtKVKvEBpW/ZWCopnxRV/Ut1kOVcEhwRt7cZRh4Q9CLEgkaovRJNXfQSlDW
oiGEZmP8raQnQbM3mBZZLYgyVkraF925Jao5jW47Cwznh+qDhO0koJUi/NRg3Ayy
NuF1TRCDdTcA96+DS5QnDjvq9Q4GJZsjSVitF/YqohHHDVrEHydRp1PA1a+CVQKs
nUP5NHLY1xTgEVr65zXP0fNkrO8SCeWm74ELlpod/gp01IOLpeYGVlZhWuecaA5D
cu8mIgfbyb7MI6RMGKr/pag4JIQogTVkZyw8mJKCCQwXxEgo9sLgxPKlXqYzZPaF
pgPEDcVMIA3y5rrp6+iWl+xpG/xAW0vQdBskX+x3ELSqY7DffYzWFbVfPm/e7OMU
BZYB8Qn18B1+M+W4++pHUtjB4v2J0sfQTMZ7tZmRq8F38Gvs96qeTHKMvravyj9p
KZEE6RNi09YzYQqWWt1FiGAsAChIJPwIGqGScx5nke6OUPCBb0c8+MBDHxpG0VK2
xEcWdvnIIEYB7FqcAXdF3pN0G31HYAdxsCtR3WAkUxr3M+cLXZ6KtA+VMgAT5lGY
uvNRRQvLGnfix2pEVW0/+6j5ztHMByXfVt+DZBkL10TUbqX+c4ob63Zjjb/8fKh6
fHsGRLVsqvDXWZfEEHN/
=yXaQ
-----END PGP SIGNATURE-----
--- checkrestart	2013-07-05 14:37:50.000000000 +0200
+++ checkrestart_	2014-04-22 16:47:50.503469698 +0200
@@ -552,13 +552,14 @@
                             m = re.match("^-", data[0])
                             while (m):
                                 data.pop(0)
+                                if not data: break
                                 m = re.match("^-", data[0])
-                            if data and data[0]: data = data[0]
-                            data = self.which(data)
-                            m = re.search(r'^(/usr/\S+)$', data)
-                            if m:
-                                # store the real full path of script as the program
-                                self.program = m.group(1)
+                            if data and data[0]:
+                                data = self.which(data[0])
+                                m = re.search(r'^(/usr/\S+)$', data)
+                                if m:
+                                    # store the real full path of script as the program
+                                    self.program = m.group(1)
         except OSError, e:
             if e.errno != errno.ENOENT:
                 if self.pid == 1:

Attachment: checkrestart.patch.sig
Description: PGP signature

Reply via email to