Package: debian-goodies
Version: 0.53
Severity: normal

I think the implementation logic of -p is backwards or broken.  Consider this 
case:


$ sudo /usr/sbin/checkrestart 
Found 10 processes using old versions of upgraded files
(1 distinct program)
(1 distinct packages)

Of these, 1 seem to contain init scripts which can be used to restart them:
The following packages seem to have init scripts that could be used
to restart them:
postgresql-8.4:
        11103   /usr/lib/postgresql/8.4/bin/postgres
        15000   /usr/lib/postgresql/8.4/bin/postgres
        9151    /usr/lib/postgresql/8.4/bin/postgres
        11085   /usr/lib/postgresql/8.4/bin/postgres
        13031   /usr/lib/postgresql/8.4/bin/postgres
        13032   /usr/lib/postgresql/8.4/bin/postgres
        12050   /usr/lib/postgresql/8.4/bin/postgres
        13062   /usr/lib/postgresql/8.4/bin/postgres
        5191    /usr/lib/postgresql/8.4/bin/postgres
        12046   /usr/lib/postgresql/8.4/bin/postgres

These are the init scripts:
/etc/init.d/postgresql-8.4 restart


Taking a closer look:

$ sudo /usr/sbin/checkrestart -v
Found 9 processes using old versions of upgraded files
(1 distinct program)
Process /usr/lib/postgresql/8.4/bin/postgres (PID: 11103) 
List of deleted files in use:
        /var/lib/postgresql/8.4/main/pg_xlog/00000001000006D20000000D (deleted)
Process /usr/lib/postgresql/8.4/bin/postgres (PID: 15000) 
List of deleted files in use:
        /var/lib/postgresql/8.4/main/pg_xlog/00000001000006D200000010 (deleted)
Process /usr/lib/postgresql/8.4/bin/postgres (PID: 9151) 
List of deleted files in use:
        /var/lib/postgresql/8.4/main/pg_xlog/00000001000006D20000000A (deleted)
Process /usr/lib/postgresql/8.4/bin/postgres (PID: 11085) 
List of deleted files in use:
        /var/lib/postgresql/8.4/main/pg_xlog/00000001000006D20000000E (deleted)
Process /usr/lib/postgresql/8.4/bin/postgres (PID: 13031) 
List of deleted files in use:
        /var/lib/postgresql/8.4/main/pg_xlog/00000001000006D20000000E (deleted)
Process /usr/lib/postgresql/8.4/bin/postgres (PID: 13032) 
List of deleted files in use:
        /var/lib/postgresql/8.4/main/pg_xlog/00000001000006D20000000E (deleted)
Process /usr/lib/postgresql/8.4/bin/postgres (PID: 13062) 
List of deleted files in use:
        /var/lib/postgresql/8.4/main/pg_xlog/00000001000006D20000000E (deleted)
Process /usr/lib/postgresql/8.4/bin/postgres (PID: 5191) 
List of deleted files in use:
        /var/lib/postgresql/8.4/main/pg_xlog/00000001000006D200000007 (deleted)
Process /usr/lib/postgresql/8.4/bin/postgres (PID: 12046) 
List of deleted files in use:
        /var/lib/postgresql/8.4/main/pg_xlog/00000001000006D20000000E (deleted)
(1 distinct packages)

Of these, 1 seem to contain init scripts which can be used to restart them:
The following packages seem to have init scripts that could be used
to restart them:
postgresql-8.4:
        11103   /usr/lib/postgresql/8.4/bin/postgres
        15000   /usr/lib/postgresql/8.4/bin/postgres
        9151    /usr/lib/postgresql/8.4/bin/postgres
        11085   /usr/lib/postgresql/8.4/bin/postgres
        13031   /usr/lib/postgresql/8.4/bin/postgres
        13032   /usr/lib/postgresql/8.4/bin/postgres
        13062   /usr/lib/postgresql/8.4/bin/postgres
        5191    /usr/lib/postgresql/8.4/bin/postgres
        12046   /usr/lib/postgresql/8.4/bin/postgres

These are the init scripts:
/etc/init.d/postgresql-8.4 restart


So this is a typical false positive, an application accessing data files that 
are deleted.  Now I suppose the -p option should end up ignoring these files 
because they don't belong to a package.  But it doesn't:

$ sudo /usr/sbin/checkrestart -p
dpkg: /var/lib/postgresql/8.4/main/pg_xlog/00000001000006D20000000D (deleted) 
not found.
dpkg: /var/lib/postgresql/8.4/main/pg_xlog/00000001000006D200000010 (deleted) 
not found.
dpkg: /var/lib/postgresql/8.4/main/pg_xlog/00000001000006D20000000A (deleted) 
not found.
dpkg: /var/lib/postgresql/8.4/main/pg_xlog/00000001000006D20000000E (deleted) 
not found.
dpkg: /var/lib/postgresql/8.4/main/pg_xlog/00000001000006D20000000E (deleted) 
not found.
dpkg: /var/lib/postgresql/8.4/main/pg_xlog/00000001000006D20000000E (deleted) 
not found.
dpkg: /var/lib/postgresql/8.4/main/pg_xlog/00000001000006D20000000E (deleted) 
not found.
dpkg: /var/lib/postgresql/8.4/main/pg_xlog/00000001000006D200000007 (deleted) 
not found.
dpkg: /var/lib/postgresql/8.4/main/pg_xlog/00000001000006D20000000E (deleted) 
not found.
Found 9 processes using old versions of upgraded files
(1 distinct program)
(1 distinct packages)

Of these, 1 seem to contain init scripts which can be used to restart them:
The following packages seem to have init scripts that could be used
to restart them:
postgresql-8.4:
        11103   /usr/lib/postgresql/8.4/bin/postgres
        15000   /usr/lib/postgresql/8.4/bin/postgres
        9151    /usr/lib/postgresql/8.4/bin/postgres
        11085   /usr/lib/postgresql/8.4/bin/postgres
        13031   /usr/lib/postgresql/8.4/bin/postgres
        13032   /usr/lib/postgresql/8.4/bin/postgres
        13062   /usr/lib/postgresql/8.4/bin/postgres
        5191    /usr/lib/postgresql/8.4/bin/postgres
        12046   /usr/lib/postgresql/8.4/bin/postgres

These are the init scripts:
/etc/init.d/postgresql-8.4 restart


I think this piece of code doesn't do what it should:

    # Skip, if asked to, files that do not belong to any package
    if onlyPackageFiles:
        dpkgQuery = ["dpkg-query", "--search", f]
        dpkgProc = subprocess.Popen(dpkgQuery, stdout=subprocess.PIPE, 
stderr=None)
        for line in dpkgProc.stdout.readlines():
            if line.endswith(f):
                return 0

First of all, as you can see, it queries dpkg for file names that end on 
"(deleted)".  Then, if dpkg-query doesn't find the file, the for loop doesn't 
read anything and the code falls through to the default case, which is to 
return 1.

I think the code should look more like this:

    # Skip, if asked to, files that do not belong to any package
    if onlyPackageFiles:
        file_in_package = False
        dpkgQuery = ["dpkg-query", "--search", f]
        dpkgProc = subprocess.Popen(dpkgQuery, stdout=subprocess.PIPE, 
stderr=None)
        for line in dpkgProc.stdout.readlines():
            if line.endswith(f):
                file_in_package = True
                break
        if not file_in_package:
            return 0

(plus fixing the "(deleted)" issue and hiding the stderr output of dpkg-query).



-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to