From owner-freebsd-hackers@FreeBSD.ORG Mon Oct 27 11:50:25 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9F99616A4B3 for ; Mon, 27 Oct 2003 11:50:25 -0800 (PST) Received: from smtp.omnis.com (smtp.omnis.com [216.239.128.26]) by mx1.FreeBSD.org (Postfix) with ESMTP id 19A2844031 for ; Mon, 27 Oct 2003 11:50:25 -0800 (PST) (envelope-from wes@softweyr.com) Received: from softweyr.homeunix.net (66-91-236-204.san.rr.com [66.91.236.204]) by smtp-relay.omnis.com (Postfix) with ESMTP id 91C015B674; Mon, 27 Oct 2003 11:45:44 -0800 (PST) From: Wes Peters Organization: Softweyr To: "Dan Langille" , freebsd-hackers@freebsd.org Date: Mon, 27 Oct 2003 11:50:23 -0800 User-Agent: KMail/1.5.4 References: <3F9CF3F6.8307.ABC1250@localhost> In-Reply-To: <3F9CF3F6.8307.ABC1250@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200310271150.23193.wes@softweyr.com> Subject: Re: non-root process and PID files X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Oct 2003 19:50:25 -0000 On Monday 27 October 2003 07:31 am, Dan Langille wrote: > If a process starts up and does a setuid, should it be writing the > PID file before or after the setuid? > > Two methods exists AFAIK: > > 1 - write your PID immediately, and the file is chown root:wheel > 2 - write your PID to /var/run/myapp/myapp.pid where /var/run/myapp/ > is chown myapp:myapp > > Of the two, I think #1 is cleaner as it does not require another > directory with special permissions. > > Any suggestions? Create the pid file while still root, and if you are going to change the user or group id, chown(2) or chgrp(2) the file just before setuid(2) / setgid(2) calls. -- Where am I, and what am I doing in this handbasket? Wes Peters wes@softweyr.com