Package: debian-goodies
Version: 0.59
Severity: wishlist
Tags: patch

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hello,

Checkrestart is very useful for daemon written in C, but lacks to detect the
real command when the daemon is written in intrepreted languages.

(As an example) I propose the attached patch, which read /proc/<pid>/cmdline
just in the case of the executable command (/proc/<pid>/exe) is linked to an
interpreter (the regex is definitely not complete; i only test it for perl and
python daemons running on my boxes). With this, the command passed to
"dpkg-search --search" successfully find the initscript used to restart the
daemon.

- -- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.38-12-generic (SMP w/4 CPU cores)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/dash

Versions of packages debian-goodies depends on:
ii  curl                      7.23.1-3
ii  dctrl-tools [grep-dctrl]  2.20.1
ii  dialog                    1.1-20111020-1
ii  less                      444-1
ii  perl                      5.14.2-6
ii  python                    2.7.2-9
ii  whiptail                  0.52.14-7

Versions of packages debian-goodies recommends:
ii  lsof  4.81.dfsg.1-1

Versions of packages debian-goodies suggests:
pn  popularity-contest  <none>
pn  xdg-utils           1.1.0~rc1+git20111210-5
pn  zenity              <none>

- -- no debconf information

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iQIbBAEBCAAGBQJPHeHTAAoJEJmGUYuaqqClg/0P92g6ECmxxdUxJhUp3btv7AHw
FfT28tA5zDp3X/ssWkEhwmywmUvPgvuANFvaZQZ8IWT9EJdsUzVEhUDhEbSVOaiN
GUAgBBlPrjEnKR9moLK70ReQAtC3jc5u/OTvfi43EvS0A2PQemqh+Z+IKYzeQScS
KhtwHCZyHOFYAUXr8qCMREtjl7bJy87skv4L+nyh10L2YvHN94cG2pCudvUe0IGa
tWXYylCgHDiiSlhoNGGF92VX6u65VLijKNrR0Vtlxbhdwp9PgIPTPA9IMewCkVxv
UYzBQk+z3T+J4J62HlfTa9KJwmAynybHMbq03SPeAENgBBsa6VsYWddV6AksvJwu
Fmh8crXG42h1U2gQFWvv8kyL1+N9+xud63azcCHs/UGoBoeTLNFdYIrltFvZ9xCw
mJ4YqIwvt9Z8Nd6mEn9ZtbYrXpSGly4RCNOu86vy8377sQMQd3IhFBfH6rsPAc09
5CH+Mp+IFMufWKdzYQq699aoaolDRjnFfYY6VY4kU8fboRWvKOeaEeofXxvLb8d3
nIlAzkBDFZJJIG4thLS6xK1GgiLN3qdbIRK0gAuAGD+ofiYkyTdpmkxT2jOg83gc
LDAEpkqavkIK7nz+duPwk6ZefwNePYvvRgEZFnfi+yjLR0LB9/QYiG9PIvlSHsTS
oxuhEoDECWBANv/DptQ=
=8pFT
-----END PGP SIGNATURE-----
--- /usr/sbin/checkrestart	2011-10-25 00:20:00.000000000 +0200
+++ /tmp/checkrestart	2012-01-23 22:59:43.052505207 +0100
@@ -426,6 +426,18 @@
 
         try:
             self.program = os.readlink('/proc/%d/exe' % self.pid)
+            # if the executable command is an interpreter such as perl/python,
+            # we want to find the real program
+            m = re.match("^/usr/bin/(perl|python)$", self.program)
+            if m:
+                with open('/proc/%d/cmdline' % self.pid, 'r') as cmdline:
+                    # only match program in /usr (ex.: /usr/sbin/smokeping)
+                    # ignore child, etc.
+                    m = re.search(r'^(([/]\w*){1,5})\s.*$', cmdline.read())
+                    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:
                 raise

Reply via email to