From owner-freebsd-audit Sun Jan 13 17:53:20 2002 Delivered-To: freebsd-audit@freebsd.org Received: from scaup.prod.itd.earthlink.net (scaup.mail.pas.earthlink.net [207.217.120.49]) by hub.freebsd.org (Postfix) with ESMTP id 9367D37B416 for ; Sun, 13 Jan 2002 17:53:17 -0800 (PST) Received: from dialup-209.245.128.42.dial1.sanjose1.level3.net ([209.245.128.42] helo=blossom.cjclark.org) by scaup.prod.itd.earthlink.net with esmtp (Exim 3.33 #1) id 16PwJH-000078-00; Sun, 13 Jan 2002 17:53:16 -0800 Received: (from cjc@localhost) by blossom.cjclark.org (8.11.6/8.11.3) id g0E1rAm24640; Sun, 13 Jan 2002 17:53:10 -0800 (PST) (envelope-from cjc) Date: Sun, 13 Jan 2002 17:53:06 -0800 From: "Crist J . Clark" To: "M. Warner Losh" Cc: bright@mu.org, audit@freebsd.org Subject: Re: netbsd's daemon(3) fixes. Message-ID: <20020113175306.B24290@blossom.cjclark.org> Reply-To: cjclark@alum.mit.edu References: <20020111141420.K11553@blossom.cjclark.org> <20020111.190120.81022760.imp@village.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20020111.190120.81022760.imp@village.org>; from imp@village.org on Fri, Jan 11, 2002 at 07:01:20PM -0700 X-URL: http://people.freebsd.org/~cjc/ Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG [Moved from -security to -audit where this is more on-topic.] On Fri, Jan 11, 2002 at 07:01:20PM -0700, M. Warner Losh wrote: > In message: <20020111141420.K11553@blossom.cjclark.org> > "Crist J . Clark" writes: > : On Fri, 11 Jan 2002 11:21:44 -0800, Alfred Perlstein wrote: > : > I saw some recent fixes in netbsd wrt when daemon is called in > : > various daemons, anyone have time to see if this is applicable > : > to us? And whether or not to merge the fixes in? > : > : If we go back to the recent fixes OpenBSD did first, the cvs logs give > : reasons like, > : > : daemon() can close innocent file descriptors, including opened log. > : be more carefull about that and nicer to debugging. > : daemon() thingie was pointed out by markus@ . > : > : So it's not really a security issue that I can see. I'm not sure if I > : understand under what conditions a daemon(3) call will close > : "innocent" file descriptors. > > I think we need the change, since innocent file descriptors might be > important. The OpenBSD manpage has added a blurb, CAVEATS Unless the noclose argument is non-zero, daemon() will close the first three file descriptors and redirect them to /dev/null. Normally, these correspond to standard input, standard output and standard error. Howev- er, if any of those file descriptors refer to something else they will still be closed, resulting in incorrect behavior of the calling program. This can happen if any of standard input, standard output or standard er- ror have been closed before the program was run. Programs using daemon() should therefor be care to either call daemon() before opening any files or sockets or, alternately, verifying that any file descriptors obtained have a value greater than 2. I'll take a look at this stuff. First, I'll catch up our manpage. ;) -- "It's always funny until someone gets hurt. Then it's hilarious." Crist J. Clark | cjclark@alum.mit.edu | cjclark@jhu.edu http://people.freebsd.org/~cjc/ | cjc@freebsd.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message