Move the initialization of smbd_server_conn from smbd/process,
authorJeremy Allison <jra@samba.org>
Sat, 18 Jul 2009 00:57:48 +0000 (17:57 -0700)
committerJeremy Allison <jra@samba.org>
Sat, 18 Jul 2009 00:57:48 +0000 (17:57 -0700)
after the accept and fork, to smbd_init_globals(), so it's
done immediately on server startup. This is needed as some
messages are sent to all active smbd processes (including
the master listening daemon). If it gets a message that
forces it to scan it's current connections (ie. conn_find())
then it discovers that sconn->smb1.tcons.Connections dereferences
null (as sconn == NULL in the parent) and crashes. Yes,
I could fix all cases where sconn is used and explicitly
check for NULL but this fix is easier. It means that
the smbd_event_context() is initialized in the master
daemon and then re-initialized after fork, but that
should be being done correctly in every fork call anyway.
Without this change the previous fix 6a9e0039100b57f9626e87defec6720c476b9789
still panics in the reproducible test case for bug
6564, as this is one case where such a message
(MSG_SMB_CONF_UPDATED) is sent to the parent. Metze
please check. This change passes valgrind.
Jeremy.

source3/smbd/globals.c
source3/smbd/process.c

index 15550ed455e43679c26c3ec9659b7e914e900b64..317304a86db0b0ec0ba4c03a804bbb2745d707e2 100644 (file)
@@ -153,4 +153,9 @@ void smbd_init_globals(void)
        ZERO_STRUCT(conn_ctx_stack);
 
        ZERO_STRUCT(sec_ctx_stack);
+
+       smbd_server_conn = talloc_zero(smbd_event_context(), struct smbd_server_connection);
+       if (!smbd_server_conn) {
+               exit_server("failed to create smbd_server_connection");
+       }
 }
index b26bc150dbdbcc1c558b6892b7bd8d3d7aa880fd..c2065caf798b246a7f223f8893de81c1939f8ec9 100644 (file)
@@ -2015,11 +2015,6 @@ void smbd_process(void)
        TALLOC_CTX *frame = talloc_stackframe();
        char remaddr[INET6_ADDRSTRLEN];
 
-       smbd_server_conn = talloc_zero(smbd_event_context(), struct smbd_server_connection);
-       if (!smbd_server_conn) {
-               exit_server("failed to create smbd_server_connection");
-       }
-
        if (lp_maxprotocol() == PROTOCOL_SMB2 &&
            lp_security() != SEC_SHARE) {
                smbd_server_conn->allow_smb2 = true;