smbd: Remove sconn->using_smb2
authorVolker Lendecke <vl@samba.org>
Tue, 13 Feb 2024 12:05:42 +0000 (13:05 +0100)
committerMartin Schwenke <martins@samba.org>
Wed, 17 Apr 2024 07:57:36 +0000 (07:57 +0000)
We have the same information available via conn_using_smb2()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
13 files changed:
source3/smbd/close.c
source3/smbd/conn_idle.c
source3/smbd/dir.c
source3/smbd/filename.c
source3/smbd/globals.h
source3/smbd/open.c
source3/smbd/smb1_process.c
source3/smbd/smb2_negprot.c
source3/smbd/smb2_nttrans.c
source3/smbd/smb2_oplock.c
source3/smbd/smb2_process.c
source3/smbd/smb2_service.c
source3/smbd/smb2_trans2.c

index bbca474a28a06113ba7f269f9eb5465154a16b2a..987a0ed51835db7c63bf41f309d3eb095cc5493a 100644 (file)
@@ -1480,7 +1480,7 @@ static NTSTATUS close_directory(struct smb_request *req, files_struct *fsp,
 
        SMB_ASSERT(fsp->fsp_flags.is_fsa);
 
-       if (fsp->conn->sconn->using_smb2) {
+       if (conn_using_smb2(fsp->conn->sconn)) {
                notify_status = NT_STATUS_NOTIFY_CLEANUP;
        } else {
                notify_status = NT_STATUS_OK;
index 870b2b717df8356bb3faebec4c77a25038f7ab47..6eebdd363b143352d34677ce0a6ade93770f1ce5 100644 (file)
@@ -238,7 +238,7 @@ static void conn_force_tdis_done(struct tevent_req *req)
                return;
        }
 
-       if (conn->sconn->using_smb2) {
+       if (conn_using_smb2(conn->sconn)) {
                vuid = conn->vuid;
        }
 
index 49c37cbb4d9de9b7bbfa8489a05ecf272a127768..76eb5756dc8759b98068e0e89d82392e7117f79e 100644 (file)
@@ -252,7 +252,7 @@ NTSTATUS dptr_create(connection_struct *conn,
 
        dptr->attr = attr;
 
-       if (sconn->using_smb2) {
+       if (conn_using_smb2(sconn)) {
                goto done;
        }
 
@@ -328,7 +328,7 @@ void dptr_CloseDir(files_struct *fsp)
 
        DBG_INFO("closing dptr key %d\n", fsp->dptr->dnum);
 
-       if (sconn != NULL && !sconn->using_smb2) {
+       if (sconn != NULL && !conn_using_smb2(sconn)) {
                DLIST_REMOVE(sconn->searches.dirptrs, fsp->dptr);
 
                /*
index 4370d7330483a3cc88fc1a7ea08be6bdff6cc979..7fafc1718c734f6cfaeaace9fd775e8d0ceccb05 100644 (file)
@@ -43,7 +43,7 @@ uint32_t ucf_flags_from_smb_request(struct smb_request *req)
        if (req->posix_pathnames) {
                ucf_flags |= UCF_POSIX_PATHNAMES;
 
-               if (!req->sconn->using_smb2) {
+               if (!conn_using_smb2(req->sconn)) {
                        ucf_flags |= UCF_LCOMP_LNK_OK;
                }
        }
index bec4ce0f64eb743fed47206b2d1e5396ff696b89..bfa3b124d73ea10b26231583b8fff2a4ded1e477 100644 (file)
@@ -781,7 +781,6 @@ struct smbd_server_connection {
        struct messaging_context *msg_ctx;
        struct dcesrv_context *dce_ctx;
        struct notify_context *notify_ctx;
-       bool using_smb2;
        int trans_num;
 
        size_t num_users;
index 9512fb20c5981d50bf80645515c715554e5b6980..16950eb414432e1105743520c7f33a8064036e66 100644 (file)
@@ -4399,7 +4399,7 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
         * According to Samba4, SEC_FILE_READ_ATTRIBUTE is always granted,
         * but we don't have to store this - just ignore it on access check.
         */
-       if (conn->sconn->using_smb2) {
+       if (conn_using_smb2(conn->sconn)) {
                /*
                 * SMB2 doesn't return it (according to Microsoft tests).
                 * Test Case: TestSuite_ScenarioNo009GrantedAccessTestS0
@@ -6033,7 +6033,7 @@ static NTSTATUS create_file_unixpath(connection_struct *conn,
                        goto fail;
                }
 
-               if (conn->sconn->using_smb2 &&
+               if (conn_using_smb2(conn->sconn) &&
                    (access_mask == SEC_FLAG_SYSTEM_SECURITY))
                {
                        /*
index 535561ae6cec587c83836f98150c382169c994c4..9b5a1bb16023bd08592c5bf8112061402f766ef2 100644 (file)
@@ -1017,7 +1017,7 @@ static void set_current_case_sensitive(connection_struct *conn, uint16_t flags)
        enum remote_arch_types ra_type;
 
        SMB_ASSERT(conn != NULL);
-       SMB_ASSERT(!conn->sconn->using_smb2);
+       SMB_ASSERT(!conn_using_smb2(conn->sconn));
 
        snum = SNUM(conn);
 
@@ -2119,7 +2119,7 @@ bool keepalive_fn(const struct timeval *now, void *private_data)
        struct smbXsrv_connection *xconn = NULL;
        bool ret;
 
-       if (sconn->using_smb2) {
+       if (conn_using_smb2(sconn)) {
                /* Don't do keepalives on an SMB2 connection. */
                return false;
        }
index 8c50fc9555335645320c930c0c7282049c65306d..d355b87f9d6c87e1fcd3df7e0520adbcf4fba291 100644 (file)
@@ -805,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);
        }
index 49bddf5d0e2bfa17cc4d5b5e5f8a1ddf816a4e74..44aab9af34b5f1c6418567140855951b87503df2 100644 (file)
@@ -184,7 +184,7 @@ static bool check_smb2_posix_chmod_ace(const struct files_struct *fsp,
         * MS NFS style mode entry coming in on a POSIX
         * handle over SMB2+.
         */
-       if (!fsp->conn->sconn->using_smb2) {
+       if (!conn_using_smb2(fsp->conn->sconn)) {
                return false;
        }
 
index 75d50b38f6ceb986e934fbfb0eb906024d8fb55d..9d61bc2ff63631496205e5797b3c4f8873916110 100644 (file)
@@ -1033,7 +1033,7 @@ static void process_oplock_break_message(struct messaging_context *msg_ctx,
        }
 
 #if defined(WITH_SMB1SERVER)
-       if (sconn->using_smb2) {
+       if (conn_using_smb2(sconn)) {
 #endif
                send_break_message_smb2(fsp, break_from, break_to);
 #if defined(WITH_SMB1SERVER)
@@ -1119,7 +1119,7 @@ static void process_kernel_oplock_break(struct messaging_context *msg_ctx,
        }
 
 #if defined(WITH_SMB1SERVER)
-       if (sconn->using_smb2) {
+       if (conn_using_smb2(sconn)) {
 #endif
                send_break_message_smb2(fsp, 0, OPLOCKLEVEL_NONE);
 #if defined(WITH_SMB1SERVER)
index 5b113d4d219e7fb66e41a9c92741866f0ff49e8f..eb94fa12f19c39e91e2b605ae5e3504d211c9639 100644 (file)
@@ -222,7 +222,7 @@ void remove_deferred_open_message_smb(struct smbXsrv_connection *xconn,
        struct smbd_server_connection *sconn = xconn->client->sconn;
        struct pending_message_list *pml;
 
-       if (sconn->using_smb2) {
+       if (conn_using_smb2(sconn)) {
                remove_deferred_open_message_smb2(xconn, mid);
                return;
        }
@@ -295,7 +295,7 @@ bool schedule_deferred_open_message_smb(struct smbXsrv_connection *xconn,
        struct pending_message_list *pml;
        int i = 0;
 
-       if (sconn->using_smb2) {
+       if (conn_using_smb2(sconn)) {
                return schedule_deferred_open_message_smb2(xconn, mid);
        }
 
@@ -365,7 +365,7 @@ bool open_was_deferred(struct smbXsrv_connection *xconn, uint64_t mid)
        struct smbd_server_connection *sconn = xconn->client->sconn;
        struct pending_message_list *pml;
 
-       if (sconn->using_smb2) {
+       if (conn_using_smb2(sconn)) {
                return open_was_deferred_smb2(xconn, mid);
        }
 
@@ -404,7 +404,7 @@ bool get_deferred_open_message_state(struct smb_request *smbreq,
 {
        struct pending_message_list *pml;
 
-       if (smbreq->sconn->using_smb2) {
+       if (conn_using_smb2(smbreq->sconn)) {
                return get_deferred_open_message_state_smb2(smbreq->smb2req,
                                        p_request_time,
                                        open_rec);
index 856974c4077f92908716d5428b5772c1234a34a7..e7f5d9ed358f508c983db22b17b8137b692a1772 100644 (file)
@@ -818,7 +818,7 @@ NTSTATUS make_connection_snum(struct smbXsrv_connection *xconn,
                         tsocket_address_string(conn->sconn->remote_address,
                                                talloc_tos()) );
 #if defined(WITH_SMB1SERVER)
-               if (sconn->using_smb2) {
+               if (conn_using_smb2(sconn)) {
 #endif
                        signing_active = smb2_signing_key_valid(
                                                session->global->encryption_key);
index 8997c402c12ca6e0d7ee91f58c4f6daabc4201d6..5198a04a74c6bc542893bcc0345e541a5503a118 100644 (file)
@@ -648,7 +648,7 @@ unsigned int estimate_ea_size(files_struct *fsp)
                                   &total_ea_len,
                                   &ea_list);
 
-       if(fsp->conn->sconn->using_smb2) {
+       if(conn_using_smb2(fsp->conn->sconn)) {
                unsigned int ret_data_size;
                /*
                 * We're going to be using fill_ea_chained_buffer() to
@@ -1741,7 +1741,7 @@ static NTSTATUS smbd_marshall_dir_entry(TALLOC_CTX *ctx,
 
                        DBG_DEBUG("SMB2_FILE_POSIX_INFORMATION\n");
 
-                       if (!(conn->sconn->using_smb2)) {
+                       if (!conn_using_smb2(conn->sconn)) {
                                return NT_STATUS_INVALID_LEVEL;
                        }
 
@@ -1990,7 +1990,7 @@ static bool fsinfo_unix_valid_level(connection_struct *conn,
                                    struct files_struct *fsp,
                                    uint16_t info_level)
 {
-       if (conn->sconn->using_smb2 &&
+       if (conn_using_smb2(conn->sconn) &&
            fsp->posix_flags == FSP_POSIX_FLAGS_OPEN &&
            info_level == SMB2_FS_POSIX_INFORMATION_INTERNAL)
        {
@@ -3038,7 +3038,7 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
                        ok = true;
                }
 
-               if (conn->sconn->using_smb2 &&
+               if (conn_using_smb2(conn->sconn) &&
                    (fsp->posix_flags & FSP_POSIX_FLAGS_OPEN))
                {
                        DBG_DEBUG("SMB2 posix open\n");
@@ -3407,7 +3407,8 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
                {
                        char *nfname = NULL;
 
-                       if (fsp == NULL || !fsp->conn->sconn->using_smb2) {
+                       if (fsp == NULL ||
+                           !conn_using_smb2(fsp->conn->sconn)) {
                                return NT_STATUS_INVALID_LEVEL;
                        }
 
@@ -3696,7 +3697,7 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
                        };
                        enum ndr_err_code ndr_err;
 
-                       if (!(conn->sconn->using_smb2)) {
+                       if (!conn_using_smb2(conn->sconn)) {
                                return NT_STATUS_INVALID_LEVEL;
                        }
                        if (fsp == NULL) {
@@ -5202,7 +5203,7 @@ NTSTATUS smbd_do_setfilepathinfo(connection_struct *conn,
 
                case SMB_FILE_LINK_INFORMATION:
                {
-                       if (conn->sconn->using_smb2) {
+                       if (conn_using_smb2(conn->sconn)) {
                                status = smb2_file_link_information(conn,
                                                        req,
                                                        pdata,