s4-process_model: Do not close random fds while forking.
authorAndreas Schneider <asn@samba.org>
Thu, 26 Mar 2015 09:48:31 +0000 (10:48 +0100)
committerMichael Adam <obnox@samba.org>
Fri, 27 Mar 2015 03:03:14 +0000 (04:03 +0100)
commitf75182841d4a7d63bd070022270926e324631fa9
tree1da6c9bbf060d96c9da4a14d98f89c6a61f7b4a6
parent14b6e0a599298696d48cbae54d9543f131a3ab95
s4-process_model: Do not close random fds while forking.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11180

The issue has been found with nss_wrapper debug output running:
    samba4.ntvfs.cifs.krb5.base.lock

In the case here, we fork a child and close the fd without resetting
the pipe fd variable. Then the fd was used to open the nss_wrapper
hosts file which got the same fd. We forked again in the process model
called close() on the re-used fd (of the pipe variable) again without
nss_wrapper noticing.  Now Samba opened the secrets tdb and got
the same fd as nss_wrapper was using for the hosts file and next
nss_wrapper tried to parse a TDB ...

Pair-Programmed-With: Michael Adam <obnox@samba.org>
Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source4/smbd/process_standard.c