From: Gary Lockyer Date: Tue, 20 Mar 2018 00:14:38 +0000 (+1300) Subject: source3: initilize_password_db after a fork. X-Git-Tag: ldb-1.4.0~695 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=428c0a81aecd578e77123ca27b835b2fc8a54e26;p=thirdparty%2Fsamba.git source3: initilize_password_db after a fork. This is required because we need a new pointer for LDB after the fork, and with LMDB we can not longer rely on tdb_reopen_all() to do that for us. This can not be done in reinit_after_fork() due to the dependency loop this would create. Signed-off-by: Gary Lockyer Reviewed-by: Andrew Bartlett --- diff --git a/source3/rpc_server/lsasd.c b/source3/rpc_server/lsasd.c index 08e9fe26a74..9dcf4624aea 100644 --- a/source3/rpc_server/lsasd.c +++ b/source3/rpc_server/lsasd.c @@ -22,6 +22,7 @@ #include "includes.h" #include "messages.h" #include "ntdomain.h" +#include "passdb.h" #include "lib/id_cache.h" @@ -251,6 +252,7 @@ static bool lsasd_child_init(struct tevent_context *ev_ctx, DEBUG(0,("reinit_after_fork() failed\n")); smb_panic("reinit_after_fork() failed"); } + initialize_password_db(true, ev_ctx); lsasd_child_id = child_id; lsasd_reopen_logs(child_id); @@ -856,6 +858,7 @@ void start_lsasd(struct tevent_context *ev_ctx, DEBUG(0,("reinit_after_fork() failed\n")); smb_panic("reinit_after_fork() failed"); } + initialize_password_db(true, ev_ctx); /* save the parent process id so the children can use it later */ parent_id = messaging_server_id(msg_ctx); diff --git a/source3/smbd/process.c b/source3/smbd/process.c index 4376f2eff99..df54a44b884 100644 --- a/source3/smbd/process.c +++ b/source3/smbd/process.c @@ -3412,6 +3412,7 @@ bool fork_echo_handler(struct smbXsrv_connection *xconn) nt_errstr(status))); exit(1); } + initialize_password_db(true, xconn->ev_ctx); smbd_echo_loop(xconn, listener_pipe[1]); exit(0); } diff --git a/source3/smbd/server_exit.c b/source3/smbd/server_exit.c index dbeb247c170..50b43a1ced4 100644 --- a/source3/smbd/server_exit.c +++ b/source3/smbd/server_exit.c @@ -44,6 +44,7 @@ #include "printing.h" #include "serverid.h" #include "messages.h" +#include "passdb.h" #include "../lib/util/pidfile.h" #include "smbprofile.h" #include "libcli/auth/netlogon_creds_cli.h" @@ -261,6 +262,9 @@ NTSTATUS smbd_reinit_after_fork(struct messaging_context *msg_ctx, struct tevent_context *ev_ctx, bool parent_longlived, const char *comment) { + NTSTATUS ret; am_parent = NULL; - return reinit_after_fork(msg_ctx, ev_ctx, parent_longlived, comment); + ret = reinit_after_fork(msg_ctx, ev_ctx, parent_longlived, comment); + initialize_password_db(true, ev_ctx); + return ret; } diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c index 8821f39a0da..b908d91e206 100644 --- a/source3/winbindd/winbindd.c +++ b/source3/winbindd/winbindd.c @@ -44,6 +44,7 @@ #include "lib/async_req/async_sock.h" #include "libsmb/samlogon_cache.h" #include "libcli/auth/netlogon_creds_cli.h" +#include "passdb.h" #undef DBGC_CLASS #define DBGC_CLASS DBGC_WINBIND @@ -1752,6 +1753,7 @@ int main(int argc, const char **argv) if (!NT_STATUS_IS_OK(status)) { exit_daemon("Winbindd reinit_after_fork() failed", map_errno_from_nt_status(status)); } + initialize_password_db(true, server_event_context()); /* * Do not initialize the parent-child-pipe before becoming diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c index 5ae5bbd9468..cff2c974dee 100644 --- a/source3/winbindd/winbindd_dual.c +++ b/source3/winbindd/winbindd_dual.c @@ -40,6 +40,7 @@ #include "lib/param/loadparm.h" #include "lib/util/sys_rw.h" #include "lib/util/sys_rw_data.h" +#include "passdb.h" #undef DBGC_CLASS #define DBGC_CLASS DBGC_WINBIND @@ -1503,6 +1504,7 @@ NTSTATUS winbindd_reinit_after_fork(const struct winbindd_child *myself, DEBUG(0,("reinit_after_fork() failed\n")); return status; } + initialize_password_db(true, server_event_context()); close_conns_after_fork();