Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 13 Jan 2002 17:53:06 -0800
From:      "Crist J . Clark" <cristjc@earthlink.net>
To:        "M. Warner Losh" <imp@village.org>
Cc:        bright@mu.org, audit@freebsd.org
Subject:   Re: netbsd's daemon(3) fixes.
Message-ID:  <20020113175306.B24290@blossom.cjclark.org>
In-Reply-To: <20020111.190120.81022760.imp@village.org>; from imp@village.org on Fri, Jan 11, 2002 at 07:01:20PM -0700
References:  <20020111141420.K11553@blossom.cjclark.org> <20020111.190120.81022760.imp@village.org>

next in thread | previous in thread | raw e-mail | index | archive | help
[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" <cristjc@earthlink.net> 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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020113175306.B24290>