source3: initilize_password_db after a fork.
authorGary Lockyer <gary@catalyst.net.nz>
Tue, 20 Mar 2018 00:14:38 +0000 (13:14 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 6 Apr 2018 00:08:45 +0000 (02:08 +0200)
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 <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source3/rpc_server/lsasd.c
source3/smbd/process.c
source3/smbd/server_exit.c
source3/winbindd/winbindd.c
source3/winbindd/winbindd_dual.c

index 08e9fe26a74b502add56c27910978292ef7bdb80..9dcf4624aea6c0c682e16af187c611cff3776540 100644 (file)
@@ -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);
index 4376f2eff999259b79fcc861aa9c3c2110742906..df54a44b88409d74344986a8b3aa895f579f90de 100644 (file)
@@ -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);
        }
index dbeb247c17036bfb1e690d78d8100fdc0c2e2eda..50b43a1ced4f6f4c0cba3d7ebde519940da98f6a 100644 (file)
@@ -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;
 }
index 8821f39a0dac51c2f529ac6977356bf56540a902..b908d91e206447975003031a9e6471b654f2ca13 100644 (file)
@@ -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
index 5ae5bbd9468ba987f9a55d65410602d2fb445265..cff2c974deeee5c35a512b6d44afc4e6c589b65d 100644 (file)
@@ -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();