[SCM] Samba Shared Repository - branch master updated

Martin Schwenke martins at samba.org
Wed Apr 17 09:02:02 UTC 2024


The branch, master has been updated
       via  cc7c12e5d5c lib: Remove an obsolete comment
       via  80cd127b20f smbd: Remove sconn->using_smb2
       via  59d7850ffaf smbd: Add conn_using_smb2()
       via  f1bb46ad4e8 smbd: Change protocol selection to not use "sconn->using_smb2"
      from  7e621b1b530 ctdb: Modernize a few DEBUGs

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit cc7c12e5d5c74812e089b7f4bc5b0c78553ccf24
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Mar 12 15:06:33 2024 +0100

    lib: Remove an obsolete comment
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Martin Schwenke <mschwenke at ddn.com>
    
    Autobuild-User(master): Martin Schwenke <martins at samba.org>
    Autobuild-Date(master): Wed Apr 17 09:01:34 UTC 2024 on atb-devel-224

commit 80cd127b20f46bfece91316171958a054a78cb00
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Feb 13 13:05:42 2024 +0100

    smbd: Remove sconn->using_smb2
    
    We have the same information available via conn_using_smb2()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Martin Schwenke <mschwenke at ddn.com>

commit 59d7850ffaf03ad00a9850683fab1b6e64be3e39
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Feb 13 12:28:06 2024 +0100

    smbd: Add conn_using_smb2()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Martin Schwenke <mschwenke at ddn.com>

commit f1bb46ad4e8b0b43ead60c70a463709892fd1779
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Feb 13 12:56:17 2024 +0100

    smbd: Change protocol selection to not use "sconn->using_smb2"
    
    To me this is pretty confusing, it seems to overload this struct
    element.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Martin Schwenke <mschwenke at ddn.com>

-----------------------------------------------------------------------

Summary of changes:
 lib/async_req/async_sock.c  |  7 -------
 source3/smbd/close.c        |  2 +-
 source3/smbd/conn.c         |  6 ++++++
 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/proto.h        |  1 +
 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 | 27 ++++++---------------------
 source3/smbd/smb2_service.c |  2 +-
 source3/smbd/smb2_trans2.c  | 15 ++++++++-------
 16 files changed, 34 insertions(+), 51 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/async_req/async_sock.c b/lib/async_req/async_sock.c
index bdbefd162ac..795a2c63dba 100644
--- a/lib/async_req/async_sock.c
+++ b/lib/async_req/async_sock.c
@@ -144,13 +144,6 @@ struct tevent_req *async_connect_send(
 		return tevent_req_post(req, ev);
 	}
 
-	/*
-	 * Note for historic reasons TEVENT_FD_WRITE is not enough
-	 * to get notified for POLLERR or EPOLLHUP even if they
-	 * come together with POLLOUT. That means we need to
-	 * use TEVENT_FD_READ in addition until we have
-	 * TEVENT_FD_ERROR.
-	 */
 	state->fde = tevent_add_fd(ev, state, fd,
 				   TEVENT_FD_ERROR|TEVENT_FD_WRITE,
 				   async_connect_connected, req);
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.c b/source3/smbd/conn.c
index e6c1fa72dcb..b7a745a951e 100644
--- a/source3/smbd/conn.c
+++ b/source3/smbd/conn.c
@@ -84,6 +84,12 @@ enum protocol_types conn_protocol(struct smbd_server_connection *sconn)
 	return PROTOCOL_COREPLUS;
 }
 
+bool conn_using_smb2(struct smbd_server_connection *sconn)
+{
+	enum protocol_types proto = conn_protocol(sconn);
+	return (proto >= PROTOCOL_SMB2_02);
+}
+
 /****************************************************************************
  Find first available connection slot, starting from a random position.
  The randomisation stops problems with the server dying and clients
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/proto.h b/source3/smbd/proto.h
index 4f0b7ac35da..7f8aee068bd 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -143,6 +143,7 @@ bool has_other_nonposix_opens(struct share_mode_lock *lck,
 int conn_num_open(struct smbd_server_connection *sconn);
 bool conn_snum_used(struct smbd_server_connection *sconn, int snum);
 enum protocol_types conn_protocol(struct smbd_server_connection *sconn);
+bool conn_using_smb2(struct smbd_server_connection *sconn);
 connection_struct *conn_new(struct smbd_server_connection *sconn);
 bool conn_idle_all(struct smbd_server_connection *sconn, time_t t);
 void conn_clear_vuid_caches(struct smbd_server_connection *sconn, uint64_t vuid);
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 4a6cda39a2f..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);
@@ -587,7 +587,7 @@ void process_smb(struct smbXsrv_connection *xconn,
 	}
 
 #if defined(WITH_SMB1SERVER)
-	if (sconn->using_smb2) {
+	if (lp_server_max_protocol() >= PROTOCOL_SMB2_02) {
 		/* At this point we're not really using smb2,
 		 * we make the decision here.. */
 		if (smbd_is_smb2_header(inbuf, nread)) {
@@ -605,7 +605,7 @@ void process_smb(struct smbXsrv_connection *xconn,
 				&& CVAL(inbuf, smb_com) != 0x72) {
 			/* This is a non-negprot SMB1 packet.
 			   Disable SMB2 from now on. */
-			sconn->using_smb2 = false;
+			lp_do_parameter(-1, "server max protocol", "NT1");
 		}
 	}
 	process_smb1(xconn, inbuf, nread, unread_bytes, seqnum, encrypted);
@@ -1876,21 +1876,6 @@ void smbd_process(struct tevent_context *ev_ctx,
 		exit_server("pthreadpool_tevent_init() failed.");
 	}
 
-#if defined(WITH_SMB1SERVER)
-	if (lp_server_max_protocol() >= PROTOCOL_SMB2_02) {
-#endif
-		/*
-		 * We're not making the decision here,
-		 * we're just allowing the client
-		 * to decide between SMB1 and SMB2
-		 * with the first negprot
-		 * packet.
-		 */
-		sconn->using_smb2 = true;
-#if defined(WITH_SMB1SERVER)
-	}
-#endif
-
 	if (!interactive) {
 		smbd_setup_sig_term_handler(sconn);
 		smbd_setup_sig_hup_handler(sconn);
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,


-- 
Samba Shared Repository



More information about the samba-cvs mailing list