s4-process_model: Do not close random fds while forking.
commitc2ea20726f316b0c232ec26f46258a53628885a6
authorAndreas Schneider <asn@samba.org>
Thu, 26 Mar 2015 09:48:31 +0000 (26 10:48 +0100)
committerKarolin Seeger <kseeger@samba.org>
Wed, 8 Apr 2015 19:34:26 +0000 (8 21:34 +0200)
tree177f0fda25fc0bf9ca539a63754f4194291e6870
parentef714b3f607f8ab4b233cf0c9552f06bb95693db
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>
(cherry picked from commit f75182841d4a7d63bd070022270926e324631fa9)
source4/smbd/process_standard.c