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

Bug#153547: marked as done (start-stop-daemon: pid_is_exec may fails to achieve its goal)



Your message dated Fri, 19 Jul 2002 12:32:53 +0200
with message-id <20020719103253.GY22887@wiggy.net>
and subject line Bug#153547: start-stop-daemon: pid_is_exec may fails to achieve its goal
has caused the attached Bug report to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere.  Please contact me immediately.)

Debian bug tracking system administrator
(administrator, Debian Bugs database)

--------------------------------------
Received: (at submit) by bugs.debian.org; 19 Jul 2002 10:11:13 +0000
>From thomas.morin@enst-bretagne.fr Fri Jul 19 05:11:13 2002
Return-path: <thomas.morin@enst-bretagne.fr>
Received: from smtp-out-4.wanadoo.fr (mel-rto4.wanadoo.fr) [193.252.19.23] 
	by master.debian.org with esmtp (Exim 3.12 1 (Debian))
	id 17VUjB-0006NP-00; Fri, 19 Jul 2002 05:11:13 -0500
Received: from mel-rta10.wanadoo.fr (193.252.19.193) by mel-rto4.wanadoo.fr (6.5.007)
        id 3D18589F00D2B622 for submit@bugs.debian.org; Fri, 19 Jul 2002 12:10:42 +0200
Received: from t0m.dyndns.org (217.128.158.210) by mel-rta10.wanadoo.fr (6.5.007)
        id 3D2A7916005632B0 for submit@bugs.debian.org; Fri, 19 Jul 2002 12:10:42 +0200
Received: by t0m.dyndns.org (Postfix, from userid 33)
	id E9B5A27261; Fri, 19 Jul 2002 12:10:41 +0200 (CEST)
Received: from machine107.rd.francetelecom.com ( [machine107.rd.francetelecom.com])
	as user thomas@localhost by t0m.dyndns.org with HTTP;
	Fri, 19 Jul 2002 12:10:41 +0200
Message-ID: <[🔎] 1027073441.3d37e5a1cc190@t0m.dyndns.org>
Date: Fri, 19 Jul 2002 12:10:41 +0200
From: Thomas Morin <thomas.morin@enst-bretagne.fr>
To: submit@bugs.debian.org
Subject: start-stop-daemon: pid_is_exec may fails to achieve its goal
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit
User-Agent: Internet Messaging Program (IMP) 3.1
Delivered-To: submit@bugs.debian.org

Package: dpkg
Version: 1.10.4
Severity: normal

While looking at start-stop-daemon source to help solving #151996 and
#151992, I noticed this piece of code :

static int
pid_is_exec(pid_t pid, const struct stat *esb)
{
        struct stat sb;
        char buf[32];

        sprintf(buf, "/proc/%d/exe", pid);
        if (stat(buf, &sb) != 0)
                return 0;
        return (sb.st_dev == esb->st_dev && sb.st_ino == esb->st_ino);
}

I guess this is meant to check that the process whose PID is found in
/var/run/foo.pid is actually a process executing the daemon started with
the foo command (using '--exec /usr/bin/foo'). 

There is a case where the test will fail, see for example:

- start-stop-daemon --start --exec /usr/bin/foo --pid-file /var/run/foo.pid
- then for some reason the (inode,dev) of /usr/bin/foo changes.
- then start-stop-daemon --stop --exec /usr/bin/foo --pid-file
/var/run/foo.pid won't stop foo, because it will conclude that the process
which PID is in /var/run/foo.pid is not running foo
 
This inode change happens when the package reinstalled or upgraded.
This maybe not be a problem since '/etc/init.d/foo stop' is called in .prerm
scrit of packages which have init scripts (dh_installinit does that
automatically). Still some packages don't use dh_installinit and don't restart
daemons during .prerm but after (ssh does this, hopefully, it doesn't use
--exec). 

Really, the inode change can happen sometimes (recovering from a backup,
manual operation on file system, etc.), and I feel start-stop-daemon could be
more robust against such cases, perhaps comparing path instead of inodes would
be the solution (maybe symlinks would be problematic ?).

Regards,

-Thomas

( this report is more or less the same as a message I recently posted on
dpkg-dev, but I corrected some points I had wrong ).

-- 
== Thomas Morin   --  GSM: 06 83 20 64 87   --   Tel: 02 98 05 98 54
== thomas.morin@enst-bretagne.fr    --    thomas.morin@tuxfamily.org
== PGP Id:8CEA233D   Key FP:503BF6CFD3AE8719377B832A02FB94E08CEA233D
--


---------------------------------------
Received: (at 153547-done) by bugs.debian.org; 19 Jul 2002 10:32:57 +0000
>From wichert@wiggy.net Fri Jul 19 05:32:57 2002
Return-path: <wichert@wiggy.net>
Received: from cabal.xs4all.nl (mx1.wiggy.net) [213.84.101.140] ([BdTDRxchLj6RRu/uP58cp1yZjeq5RZ9g])
	by master.debian.org with esmtp (Exim 3.12 1 (Debian))
	id 17VV4D-0007IM-00; Fri, 19 Jul 2002 05:32:57 -0500
Received: from wichert by mx1.wiggy.net with local (Exim 3.35 #1 (Debian))
	id 17VV49-00054u-00; Fri, 19 Jul 2002 12:32:53 +0200
Date: Fri, 19 Jul 2002 12:32:53 +0200
From: Wichert Akkerman <wichert@wiggy.net>
To: Thomas Morin <thomas.morin@enst-bretagne.fr>,
	153547-done@bugs.debian.org
Subject: Re: Bug#153547: start-stop-daemon: pid_is_exec may fails to achieve its goal
Message-ID: <20020719103253.GY22887@wiggy.net>
References: <[🔎] 1027073441.3d37e5a1cc190@t0m.dyndns.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <[🔎] 1027073441.3d37e5a1cc190@t0m.dyndns.org>
User-Agent: Mutt/1.3.28i
Delivered-To: 153547-done@bugs.debian.org

Previously Thomas Morin wrote:
> I guess this is meant to check that the process whose PID is found in
> /var/run/foo.pid is actually a process executing the daemon started with
> the foo command (using '--exec /usr/bin/foo'). 

Indeed, and that is what is documented.

> There is a case where the test will fail, see for example:
> 
> - start-stop-daemon --start --exec /usr/bin/foo --pid-file /var/run/foo.pid
> - then for some reason the (inode,dev) of /usr/bin/foo changes.
> - then start-stop-daemon --stop --exec /usr/bin/foo --pid-file
> /var/run/foo.pid won't stop foo, because it will conclude that the process
> which PID is in /var/run/foo.pid is not running foo

Obviously, yes.

> This inode change happens when the package reinstalled or upgraded.
> This maybe not be a problem since '/etc/init.d/foo stop' is called in .prerm
> scrit of packages which have init scripts (dh_installinit does that
> automatically). Still some packages don't use dh_installinit and don't restart
> daemons during .prerm but after (ssh does this, hopefully, it doesn't use
> --exec). 

Those packages are broken.

Wichert.

-- 
  _________________________________________________________________
 /wichert@wiggy.net         This space intentionally left occupied \
| wichert@deephackmode.org            http://www.liacs.nl/~wichert/ |
| 1024D/2FA3BC2D 576E 100B 518D 2F16 36B0  2805 3CB8 9250 2FA3 BC2D |


-- 
To UNSUBSCRIBE, email to debian-dpkg-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org



Reply to: