Using close on exec in tdb

simo idra at samba.org
Mon Sep 24 19:50:36 GMT 2007


On Mon, 2007-09-24 at 12:44 -0700, James Peach wrote:
> On Sep 24, 2007, at 12:31 PM, simo wrote:
> 
> >
> > It seem we don;t set close on exec on tdb files despite the fact  
> > that we
> > do fork+exec in many case (preexec, root prexec, various scripts and
> > commands we launch).
> >
> > The attached patch would set close on exec on every tdb we use in  
> > samba
> > and utilities.
> >
> > As far as I know there is no case where we rely on an executed process
> > to inherit tdb file descriptors.
> >
> > If this is ok I'd like to apply this patch to all trees.
> 
> 
> Does libreplace guarantee to provide FD_CLOEXEC? Some systems (Darwin  
> for one) don't have FD_CLOEXEC, but describe F_SETFD like this:
> 
>       F_SETFD            Set the close-on-exec flag associated with  
> fildes to
>                          the low order bit of arg (0 or 1 as above).
> 
> So in this case it is safe to "#define FD_CLOEXEC 1".

Feel free to add it to libreplace if it is not there :-)
We already use this piece of code (including the ifdef) elsewhere.

Do you have any comment on the effect of the patch ?

Simo.

-- 
Simo Sorce
Samba Team GPL Compliance Officer
email: idra at samba.org
http://samba.org



More information about the samba-technical mailing list