From owner-svn-src-head@FreeBSD.ORG Sat Feb 4 18:16:50 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 76E1D106564A; Sat, 4 Feb 2012 18:16:50 +0000 (UTC) (envelope-from to.my.trociny@gmail.com) Received: from mail-bk0-f54.google.com (mail-bk0-f54.google.com [209.85.214.54]) by mx1.freebsd.org (Postfix) with ESMTP id 2C3308FC08; Sat, 4 Feb 2012 18:16:49 +0000 (UTC) Received: by bkbzx1 with SMTP id zx1so5285921bkb.13 for ; Sat, 04 Feb 2012 10:16:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:references:x-comment-to:sender:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=OtmKWiHpxUZgZ8fw/YJGZxajsmxY33u5PSeuDGFOWIw=; b=rRvYUECJByrSCi5Fe8LHJLnSik/8uDIISZxTfModxul7X7C5YZLG244OuC8ZTHCMTe O676VEDVgOtQ8z4rmB/GyxR4KGCZh/pfdQGFMYrtcv7OldFrpi2w2ZPRSRS28Wt7jeJA SUdUNoXsQIAfJgi235WXvKhv75JJBrqJr6di4= Received: by 10.204.133.204 with SMTP id g12mr5550045bkt.107.1328379408282; Sat, 04 Feb 2012 10:16:48 -0800 (PST) Received: from localhost ([95.69.173.122]) by mx.google.com with ESMTPS id cz3sm28052968bkb.3.2012.02.04.10.16.44 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 04 Feb 2012 10:16:46 -0800 (PST) From: Mikolaj Golub To: Guy Helmer References: <201202011641.q11Gf0j6095461@svn.freebsd.org> <20120204074201.GA1694@garage.freebsd.pl> <4F2CEB1D.10607@zonov.org> <27A0A960-F767-4D2C-BF3E-31F73FBF4E28@palisadesystems.com> X-Comment-To: Guy Helmer Sender: Mikolaj Golub Date: Sat, 04 Feb 2012 20:16:42 +0200 In-Reply-To: <27A0A960-F767-4D2C-BF3E-31F73FBF4E28@palisadesystems.com> (Guy Helmer's message of "Sat, 4 Feb 2012 10:30:00 -0600") Message-ID: <86zkcy5ur9.fsf@kopusha.home.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, Andrey Zonov , Pawel Jakub Dawidek , src-committers@FreeBSD.org Subject: Re: svn commit: r230869 - head/usr.sbin/daemon X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Feb 2012 18:16:50 -0000 On Sat, 4 Feb 2012 10:30:00 -0600 Guy Helmer wrote: GH> On Feb 4, 2012, at 2:23 AM, Andrey Zonov wrote: >> On 04.02.2012 11:42, Pawel Jakub Dawidek wrote: >>> On Wed, Feb 01, 2012 at 04:41:00PM +0000, Guy Helmer wrote: >>>> Author: ghelmer >>>> Date: Wed Feb 1 16:40:59 2012 >>>> New Revision: 230869 >>>> URL: http://svn.freebsd.org/changeset/base/230869 >>>> >>>> Log: >>>> Change the notes about the pidfile to include Doug's preference >>>> for pre-creating the pidfile with appropriate owner and permissions. >>>> >>>> Requested by dougb >>> >>> Pre-creating pidfiles? That sounds weird. The common practise is to turn >>> eg. /var/run/.pid into /var/run//pid where directory >>> has appropriate permissions. Pre-creating pidfiles is simply wrong, >>> because applications create pidfile on start and unlink it on exit. >>> If application has no permission to remove files from /var/run/ it will >>> leave pidfile with stale PID in it, which is bad. Changing application >>> to truncate pidfile on exit instead of unlinking it also is a bad idea >>> especially because there is working solution - pid directory. >>> >> >> Hi, >> >> There's even worse problem - kernel closes pidfile in execvp() because of >> FD_CLOEXEC flag is set and daemon doesn't hold lock on pidfile. >> >> I reported about that earlier, but was ignored. GH> I don't understand your concern about this -- the daemon(8) program GH> exists to start a program that does not manage its own user authority or GH> pid file, and it is inappropriate to leak the open pidfile descriptor to GH> the program that daemon(8) execs. ref8-amd64:/home/trociny% uname -r 8.2-STABLE ref8-amd64:/home/trociny% daemon -p /tmp/sleep.pid sleep 10 ref8-amd64:/home/trociny% daemon -p /tmp/sleep.pid sleep 10 daemon: process already running, pid: 19799 kopusha:~% uname -r 10.0-CURRENT kopusha:~% daemon -p /tmp/sleep.pid sleep 10 kopusha:~% daemon -p /tmp/sleep.pid sleep 10 kopusha:~% -- Mikolaj Golub