s4:dsdb: Fix stack use after scope in gkdi_create_root_key()
[samba.git] / source3 / smbd / smb2_negprot.c
index ad40434e5f6dc51b2d3dd25141b25e827157708a..f66ec2aa47f98ad8ada61a25104a1fbcc798b49e 100644 (file)
@@ -96,7 +96,7 @@ enum protocol_types smbd_smb2_protocol_dialect_match(const uint8_t *indyn,
                                const int dialect_count,
                                uint16_t *dialect)
 {
-       struct {
+       static const struct {
                enum protocol_types proto;
                uint16_t dialect;
        } pd[] = {
@@ -142,6 +142,10 @@ static NTSTATUS smb2_negotiate_context_process_posix(
 
        *posix = false;
 
+       if (!lp_smb3_unix_extensions(GLOBAL_SECTION_SNUM)) {
+               return NT_STATUS_OK;
+       }
+
        in_posix = smb2_negotiate_context_find(in_c,
                                               SMB2_POSIX_EXTENSIONS_AVAILABLE);
        if (in_posix == NULL) {
@@ -801,8 +805,6 @@ NTSTATUS smbd_smb2_request_process_negprot(struct smbd_smb2_request *req)
        SIVAL(outbody.data, 0x3C,
              out_negotiate_context_offset);    /* reserved/NegotiateContextOffset */
 
-       req->sconn->using_smb2 = true;
-
        if (dialect == SMB2_DIALECT_REVISION_2FF) {
                return smbd_smb2_request_done(req, outbody, &outdyn);
        }
@@ -899,7 +901,14 @@ static void smbd_smb2_request_process_negprot_mc_done(struct tevent_req *subreq)
        if (NT_STATUS_EQUAL(status, NT_STATUS_MESSAGE_RETRIEVED)) {
                /*
                 * The connection was passed to another process
+                *
+                * We mark the error as NT_STATUS_CONNECTION_IN_USE,
+                * in order to indicate to low level code if
+                * ctdbd_unregister_ips() or ctdbd_passed_ips()
+                * is more useful.
                 */
+               smbXsrv_connection_disconnect_transport(xconn,
+                                               NT_STATUS_CONNECTION_IN_USE);
                smbd_server_connection_terminate(xconn,
                                                 "passed connection");
                /*