From 80cd127b20f46bfece91316171958a054a78cb00 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 13 Feb 2024 13:05:42 +0100 Subject: [PATCH] smbd: Remove sconn->using_smb2 We have the same information available via conn_using_smb2() Signed-off-by: Volker Lendecke Reviewed-by: Martin Schwenke --- source3/smbd/close.c | 2 +- source3/smbd/conn_idle.c | 2 +- source3/smbd/dir.c | 4 ++-- source3/smbd/filename.c | 2 +- source3/smbd/globals.h | 1 - source3/smbd/open.c | 4 ++-- source3/smbd/smb1_process.c | 4 ++-- source3/smbd/smb2_negprot.c | 2 -- source3/smbd/smb2_nttrans.c | 2 +- source3/smbd/smb2_oplock.c | 4 ++-- source3/smbd/smb2_process.c | 8 ++++---- source3/smbd/smb2_service.c | 2 +- source3/smbd/smb2_trans2.c | 15 ++++++++------- 13 files changed, 25 insertions(+), 27 deletions(-) diff --git a/source3/smbd/close.c b/source3/smbd/close.c index bbca474a28a..987a0ed5183 100644 --- a/source3/smbd/close.c +++ b/source3/smbd/close.c @@ -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; diff --git a/source3/smbd/conn_idle.c b/source3/smbd/conn_idle.c index 870b2b717df..6eebdd363b1 100644 --- a/source3/smbd/conn_idle.c +++ b/source3/smbd/conn_idle.c @@ -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; } diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c index 49c37cbb4d9..76eb5756dc8 100644 --- a/source3/smbd/dir.c +++ b/source3/smbd/dir.c @@ -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); /* diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c index 4370d733048..7fafc1718c7 100644 --- a/source3/smbd/filename.c +++ b/source3/smbd/filename.c @@ -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; } } diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h index bec4ce0f64e..bfa3b124d73 100644 --- a/source3/smbd/globals.h +++ b/source3/smbd/globals.h @@ -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; diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 9512fb20c59..16950eb4144 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -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)) { /* diff --git a/source3/smbd/smb1_process.c b/source3/smbd/smb1_process.c index 535561ae6ce..9b5a1bb1602 100644 --- a/source3/smbd/smb1_process.c +++ b/source3/smbd/smb1_process.c @@ -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; } diff --git a/source3/smbd/smb2_negprot.c b/source3/smbd/smb2_negprot.c index 8c50fc95553..d355b87f9d6 100644 --- a/source3/smbd/smb2_negprot.c +++ b/source3/smbd/smb2_negprot.c @@ -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); } diff --git a/source3/smbd/smb2_nttrans.c b/source3/smbd/smb2_nttrans.c index 49bddf5d0e2..44aab9af34b 100644 --- a/source3/smbd/smb2_nttrans.c +++ b/source3/smbd/smb2_nttrans.c @@ -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; } diff --git a/source3/smbd/smb2_oplock.c b/source3/smbd/smb2_oplock.c index 75d50b38f6c..9d61bc2ff63 100644 --- a/source3/smbd/smb2_oplock.c +++ b/source3/smbd/smb2_oplock.c @@ -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) diff --git a/source3/smbd/smb2_process.c b/source3/smbd/smb2_process.c index 5b113d4d219..eb94fa12f19 100644 --- a/source3/smbd/smb2_process.c +++ b/source3/smbd/smb2_process.c @@ -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); diff --git a/source3/smbd/smb2_service.c b/source3/smbd/smb2_service.c index 856974c4077..e7f5d9ed358 100644 --- a/source3/smbd/smb2_service.c +++ b/source3/smbd/smb2_service.c @@ -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); diff --git a/source3/smbd/smb2_trans2.c b/source3/smbd/smb2_trans2.c index 8997c402c12..5198a04a74c 100644 --- a/source3/smbd/smb2_trans2.c +++ b/source3/smbd/smb2_trans2.c @@ -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, -- 2.34.1