[SCM] Samba Shared Repository - branch master updated

Stefan Metzmacher metze at samba.org
Thu May 23 13:38:02 UTC 2024


The branch, master has been updated
       via  5a54c9b28ab s3:utils: let smbstatus report anonymous signing/encryption explicitly
       via  f3ddfb828e6 s3:smbd: allow anonymous encryption after one authenticated session setup
       via  551756abd2c s3:utils: let smbstatus also report partial tcon signing/encryption
       via  8119fd6d6a4 s3:utils: let smbstatus also report AES-256 encryption types for tcons
       via  5089d855064 s3:utils: let connections_forall_read() report if the session was authenticated
       via  596a10d1079 s3:lib: let sessionid_traverse_read() report if the session was authenticated
       via  a9f84593f44 s3:utils: remove unused signing_flags in connections_forall()
       via  6c5781b5f15 s4:torture/smb2: add smb2.session.anon-{encryption{1,2,},signing{1,2}}
       via  6a89615d781 s4:libcli/smb2: add hack to test anonymous signing and encryption
       via  14d6e267212 smbXcli_base: add hacks to test anonymous signing and encryption
      from  d6581d213d5 ldb: move struct ldb_debug_ops to ldb_private.h

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


- Log -----------------------------------------------------------------
commit 5a54c9b28abb1464c84cb4be15a49718d8ae6795
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Jul 3 15:14:38 2023 +0200

    s3:utils: let smbstatus report anonymous signing/encryption explicitly
    
    We should mark sessions/tcons with anonymous encryption or signing
    in a special way, as the value of it is void, all based on a
    session key with 16 zero bytes.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15412
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Günther Deschner <gd at samba.org>
    
    Autobuild-User(master): Stefan Metzmacher <metze at samba.org>
    Autobuild-Date(master): Thu May 23 13:37:09 UTC 2024 on atb-devel-224

commit f3ddfb828e66738ca461c3284c423defb774547c
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Jun 30 18:05:51 2023 +0200

    s3:smbd: allow anonymous encryption after one authenticated session setup
    
    I have captures where a client tries smb3 encryption on an anonymous session,
    we used to allow that before commit da7dcc443f45d07d9963df9daae458fbdd991a47
    was released with samba-4.15.0rc1.
    
    Testing against Windows Server 2022 revealed that anonymous signing is always
    allowed (with the session key derived from 16 zero bytes) and
    anonymous encryption is allowed after one authenticated session setup on
    the tcp connection.
    
    https://bugzilla.samba.org/show_bug.cgi?id=15412
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Günther Deschner <gd at samba.org>

commit 551756abd2c9e4922075bc3037db645355542363
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Jul 3 15:12:38 2023 +0200

    s3:utils: let smbstatus also report partial tcon signing/encryption
    
    We already do that for sessions and also for the json output,
    but it was missing in the non-json output for tcons.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15412
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Günther Deschner <gd at samba.org>

commit 8119fd6d6a49b869bd9e8ff653b500e194b070de
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Jul 3 15:12:38 2023 +0200

    s3:utils: let smbstatus also report AES-256 encryption types for tcons
    
    We already do that for sessions.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15412
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Günther Deschner <gd at samba.org>

commit 5089d8550640f72b1e0373f8ac321378ccaa8bd5
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Jul 3 15:10:08 2023 +0200

    s3:utils: let connections_forall_read() report if the session was authenticated
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15412
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Günther Deschner <gd at samba.org>

commit 596a10d1079f5c4a954108c81efc862c22a11f28
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Jul 3 15:08:31 2023 +0200

    s3:lib: let sessionid_traverse_read() report if the session was authenticated
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15412
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Günther Deschner <gd at samba.org>

commit a9f84593f44f15a19c4cdde1e7ad53cd5e03b4d9
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Jul 3 15:05:59 2023 +0200

    s3:utils: remove unused signing_flags in connections_forall()
    
    We never use the signing flags from the session, as the tcon
    has its own signing flags.
    
    https://bugzilla.samba.org/show_bug.cgi?id=15412
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Günther Deschner <gd at samba.org>

commit 6c5781b5f154857f1454f41133687fba8c4c9df9
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed May 15 10:02:00 2024 +0200

    s4:torture/smb2: add smb2.session.anon-{encryption{1,2,},signing{1,2}}
    
    These demonstrate how anonymous encryption and signing work.
    They pass against Windows 2022 as ad dc.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15412
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Günther Deschner <gd at samba.org>

commit 6a89615d78119c0bff2fb07bd0c62e4c31ea8441
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed May 15 10:51:42 2024 +0200

    s4:libcli/smb2: add hack to test anonymous signing and encryption
    
    This will be used in torture tests.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15412
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Günther Deschner <gd at samba.org>

commit 14d6e2672126adee85997dc3d3c64607c987e8b9
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue May 14 18:21:33 2024 +0200

    smbXcli_base: add hacks to test anonymous signing and encryption
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15412
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Günther Deschner <gd at samba.org>

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

Summary of changes:
 libcli/smb/smbXcli_base.c      | 104 ++++++-
 libcli/smb/smbXcli_base.h      |   5 +
 source3/include/session.h      |   1 +
 source3/lib/sessionid_tdb.c    |   8 +
 source3/smbd/globals.h         |   5 +
 source3/smbd/smb2_server.c     |  11 +
 source3/smbd/smb2_sesssetup.c  |  18 +-
 source3/smbd/smb2_tcon.c       |   4 +
 source3/utils/conn_tdb.c       |  12 +-
 source3/utils/conn_tdb.h       |   1 +
 source3/utils/status.c         |  82 +++++-
 source3/utils/status.h         |   1 +
 source3/utils/status_json.c    |   2 +
 source4/libcli/smb2/session.c  |  16 +-
 source4/libcli/smb2/smb2.h     |   2 +
 source4/torture/smb2/session.c | 629 +++++++++++++++++++++++++++++++++++++++++
 16 files changed, 881 insertions(+), 20 deletions(-)


Changeset truncated at 500 lines:

diff --git a/libcli/smb/smbXcli_base.c b/libcli/smb/smbXcli_base.c
index 90e343c9d12..f3b534a6c6b 100644
--- a/libcli/smb/smbXcli_base.c
+++ b/libcli/smb/smbXcli_base.c
@@ -166,6 +166,13 @@ struct smb2cli_session {
 	uint16_t channel_sequence;
 	bool replay_active;
 	bool require_signed_response;
+
+	/*
+	 * The following are just for torture tests
+	 */
+	bool anonymous_signing;
+	bool anonymous_encryption;
+	bool no_signing_disconnect;
 };
 
 struct smbXcli_session {
@@ -3999,6 +4006,9 @@ static NTSTATUS smb2cli_conn_dispatch_incoming(struct smbXcli_conn *conn,
 
 		if (NT_STATUS_EQUAL(status, NT_STATUS_NETWORK_NAME_DELETED) ||
 		    NT_STATUS_EQUAL(status, NT_STATUS_FILE_CLOSED) ||
+		    (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED) &&
+		     session != NULL &&
+		     session->smb2->no_signing_disconnect) ||
 		    NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER)) {
 			/*
 			 * if the server returns
@@ -4042,8 +4052,29 @@ static NTSTATUS smb2cli_conn_dispatch_incoming(struct smbXcli_conn *conn,
 				/*
 				 * If the signing check fails, we disconnect
 				 * the connection.
+				 *
+				 * Unless
+				 * smb2cli_session_torture_no_signing_disconnect
+				 * was called in torture tests
 				 */
-				return signing_status;
+
+				if (!NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) {
+					return signing_status;
+				}
+
+				if (!NT_STATUS_EQUAL(status, signing_status)) {
+					return signing_status;
+				}
+
+				if (session == NULL) {
+					return signing_status;
+				}
+
+				if (!session->smb2->no_signing_disconnect) {
+					return signing_status;
+				}
+
+				state->smb2.signing_skipped = true;
 			}
 		}
 
@@ -6322,6 +6353,23 @@ void smb2cli_session_require_signed_response(struct smbXcli_session *session,
 	session->smb2->require_signed_response = require_signed_response;
 }
 
+void smb2cli_session_torture_anonymous_signing(struct smbXcli_session *session,
+					       bool anonymous_signing)
+{
+	session->smb2->anonymous_signing = anonymous_signing;
+}
+
+void smb2cli_session_torture_anonymous_encryption(struct smbXcli_session *session,
+						  bool anonymous_encryption)
+{
+	session->smb2->anonymous_encryption = anonymous_encryption;
+}
+
+void smb2cli_session_torture_no_signing_disconnect(struct smbXcli_session *session)
+{
+	session->smb2->no_signing_disconnect = true;
+}
+
 NTSTATUS smb2cli_session_update_preauth(struct smbXcli_session *session,
 					const struct iovec *iov)
 {
@@ -6422,6 +6470,10 @@ NTSTATUS smb2cli_session_set_session_key(struct smbXcli_session *session,
 						  conn->protocol,
 						  preauth_hash);
 
+	if (session->smb2->anonymous_encryption) {
+		goto skip_signing_key;
+	}
+
 	status = smb2_signing_key_sign_create(session->smb2,
 					      conn->smb2.server.sign_algo,
 					      &_session_key,
@@ -6431,6 +6483,15 @@ NTSTATUS smb2cli_session_set_session_key(struct smbXcli_session *session,
 		return status;
 	}
 
+	if (session->smb2->anonymous_signing) {
+		/*
+		 * skip encryption and application keys
+		 */
+		goto skip_application_key;
+	}
+
+skip_signing_key:
+
 	status = smb2_signing_key_cipher_create(session->smb2,
 						conn->smb2.server.cipher,
 						&_session_key,
@@ -6449,6 +6510,10 @@ NTSTATUS smb2cli_session_set_session_key(struct smbXcli_session *session,
 		return status;
 	}
 
+	if (session->smb2->anonymous_encryption) {
+		goto skip_application_key;
+	}
+
 	status = smb2_signing_key_sign_create(session->smb2,
 					      conn->smb2.server.sign_algo,
 					      &_session_key,
@@ -6458,6 +6523,8 @@ NTSTATUS smb2cli_session_set_session_key(struct smbXcli_session *session,
 		return status;
 	}
 
+skip_application_key:
+
 	status = smb2_signing_key_copy(session,
 				       session->smb2->signing_key,
 				       &session->smb2_channel.signing_key);
@@ -6467,6 +6534,18 @@ NTSTATUS smb2cli_session_set_session_key(struct smbXcli_session *session,
 
 	check_signature = conn->mandatory_signing;
 
+	if (conn->protocol >= PROTOCOL_SMB3_11) {
+		check_signature = true;
+	}
+
+	if (session->smb2->anonymous_signing) {
+		check_signature = false;
+	}
+
+	if (session->smb2->anonymous_encryption) {
+		check_signature = false;
+	}
+
 	hdr_flags = IVAL(recv_iov[0].iov_base, SMB2_HDR_FLAGS);
 	if (hdr_flags & SMB2_HDR_FLAG_SIGNED) {
 		/*
@@ -6482,10 +6561,6 @@ NTSTATUS smb2cli_session_set_session_key(struct smbXcli_session *session,
 		check_signature = true;
 	}
 
-	if (conn->protocol >= PROTOCOL_SMB3_11) {
-		check_signature = true;
-	}
-
 	if (check_signature) {
 		status = smb2_signing_check_pdu(session->smb2_channel.signing_key,
 						recv_iov, 3);
@@ -6517,6 +6592,15 @@ NTSTATUS smb2cli_session_set_session_key(struct smbXcli_session *session,
 		session->smb2->should_encrypt = false;
 	}
 
+	if (session->smb2->anonymous_signing) {
+		session->smb2->should_sign = true;
+	}
+
+	if (session->smb2->anonymous_encryption) {
+		session->smb2->should_encrypt = true;
+		session->smb2->should_sign = false;
+	}
+
 	/*
 	 * CCM and GCM algorithms must never have their
 	 * nonce wrap, or the security of the whole
@@ -6688,6 +6772,16 @@ NTSTATUS smb2cli_session_set_channel_key(struct smbXcli_session *session,
 
 NTSTATUS smb2cli_session_encryption_on(struct smbXcli_session *session)
 {
+	if (session->smb2->anonymous_signing) {
+		return NT_STATUS_INVALID_PARAMETER_MIX;
+	}
+
+	if (session->smb2->anonymous_encryption) {
+		SMB_ASSERT(session->smb2->should_encrypt);
+		SMB_ASSERT(!session->smb2->should_sign);
+		return NT_STATUS_OK;
+	}
+
 	if (!session->smb2->should_sign) {
 		/*
 		 * We need required signing on the session
diff --git a/libcli/smb/smbXcli_base.h b/libcli/smb/smbXcli_base.h
index 25ccd84b336..69fa131a31d 100644
--- a/libcli/smb/smbXcli_base.h
+++ b/libcli/smb/smbXcli_base.h
@@ -535,6 +535,11 @@ void smb2cli_session_start_replay(struct smbXcli_session *session);
 void smb2cli_session_stop_replay(struct smbXcli_session *session);
 void smb2cli_session_require_signed_response(struct smbXcli_session *session,
 					     bool require_signed_response);
+void smb2cli_session_torture_anonymous_signing(struct smbXcli_session *session,
+					       bool anonymous_signing);
+void smb2cli_session_torture_anonymous_encryption(struct smbXcli_session *session,
+						  bool anonymous_encryption);
+void smb2cli_session_torture_no_signing_disconnect(struct smbXcli_session *session);
 NTSTATUS smb2cli_session_update_preauth(struct smbXcli_session *session,
 					const struct iovec *iov);
 NTSTATUS smb2cli_session_set_session_key(struct smbXcli_session *session,
diff --git a/source3/include/session.h b/source3/include/session.h
index 40c25e514bb..903208e9b0b 100644
--- a/source3/include/session.h
+++ b/source3/include/session.h
@@ -39,6 +39,7 @@ struct sessionid {
 	fstring ip_addr_str;
 	time_t connect_start;
 	uint16_t connection_dialect;
+	bool authenticated;
 	uint8_t encryption_flags;
 	uint16_t cipher;
 	uint16_t signing;
diff --git a/source3/lib/sessionid_tdb.c b/source3/lib/sessionid_tdb.c
index 53bb9aeebbc..6af2ad9b9e9 100644
--- a/source3/lib/sessionid_tdb.c
+++ b/source3/lib/sessionid_tdb.c
@@ -25,6 +25,7 @@
 #include "util_tdb.h"
 #include "smbd/globals.h"
 #include "source3/smbd/smbXsrv_session.h"
+#include "../libcli/security/session.h"
 
 struct sessionid_traverse_read_state {
 	int (*fn)(const char *key, struct sessionid *session,
@@ -49,11 +50,18 @@ static int sessionid_traverse_read_fn(struct smbXsrv_session_global0 *global,
 	};
 
 	if (session_info != NULL) {
+		enum security_user_level ul;
+
 		session.uid = session_info->unix_token->uid;
 		session.gid = session_info->unix_token->gid;
 		strncpy(session.username,
 			session_info->unix_info->unix_name,
 			sizeof(fstring)-1);
+
+		ul = security_session_user_level(session_info, NULL);
+		if (ul >= SECURITY_USER) {
+			session.authenticated = true;
+		}
 	}
 
 	strncpy(session.remote_machine,
diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h
index bfa3b124d73..7d0d924dd73 100644
--- a/source3/smbd/globals.h
+++ b/source3/smbd/globals.h
@@ -522,6 +522,11 @@ struct smbXsrv_connection {
 		} smbtorture;
 
 		bool signing_mandatory;
+		/*
+		 * This is ConstrainedConnection in MS-SMB2,
+		 * but with reversed value...
+		 */
+		bool got_authenticated_session;
 	} smb2;
 };
 
diff --git a/source3/smbd/smb2_server.c b/source3/smbd/smb2_server.c
index 642b530134b..a32044d9357 100644
--- a/source3/smbd/smb2_server.c
+++ b/source3/smbd/smb2_server.c
@@ -495,6 +495,17 @@ static NTSTATUS smbd_smb2_inbuf_parse_compound(struct smbXsrv_connection *xconn,
 				goto inval;
 			}
 
+			if (!xconn->smb2.got_authenticated_session) {
+				D_INFO("Got SMB2_TRANSFORM header, "
+				       "but not no authenticated session yet "
+				       "client[%s] server[%s]\n",
+				       tsocket_address_string(
+					xconn->remote_address, talloc_tos()),
+				       tsocket_address_string(
+					xconn->local_address, talloc_tos()));
+				goto inval;
+			}
+
 			if (len < SMB2_TF_HDR_SIZE) {
 				DEBUG(1, ("%d bytes left, expected at least %d\n",
 					   (int)len, SMB2_TF_HDR_SIZE));
diff --git a/source3/smbd/smb2_sesssetup.c b/source3/smbd/smb2_sesssetup.c
index 3005385ac9c..d4140af2f1f 100644
--- a/source3/smbd/smb2_sesssetup.c
+++ b/source3/smbd/smb2_sesssetup.c
@@ -272,6 +272,13 @@ static NTSTATUS smbd_smb2_auth_generic_return(struct smbXsrv_session *session,
 		x->global->signing_flags &= ~SMBXSRV_SIGNING_REQUIRED;
 		/* we map anonymous to guest internally */
 		guest = true;
+	} else {
+		/*
+		 * Remember we got one authenticated session on the connection
+		 * in order to allow SMB3 decryption to happen
+		 * (sadly even for future anonymous connections).
+		 */
+		xconn->smb2.got_authenticated_session = true;
 	}
 
 	if (guest && (x->global->encryption_flags & SMBXSRV_ENCRYPTION_REQUIRED)) {
@@ -289,7 +296,10 @@ static NTSTATUS smbd_smb2_auth_generic_return(struct smbXsrv_session *session,
 	}
 	x->global->signing_algo = xconn->smb2.server.sign_algo;
 	x->global->encryption_cipher = xconn->smb2.server.cipher;
-	if (guest) {
+	if (*out_session_flags & SMB2_SESSION_FLAG_IS_GUEST) {
+		/*
+		 * A fallback to guest can't do any encryption
+		 */
 		x->global->encryption_cipher = SMB2_ENCRYPTION_NONE;
 	}
 
@@ -643,6 +653,12 @@ static NTSTATUS smbd_smb2_bind_auth_return(struct smbXsrv_session *session,
 		return NT_STATUS_LOGON_FAILURE;
 	}
 
+	/*
+	 * Remember we got one authenticated session on the connection
+	 * in order to allow SMB3 decryption to happen
+	 */
+	xconn->smb2.got_authenticated_session = true;
+
 	*out_session_id = session->global->session_wire_id;
 
 	return NT_STATUS_OK;
diff --git a/source3/smbd/smb2_tcon.c b/source3/smbd/smb2_tcon.c
index b228036510a..20d89670df1 100644
--- a/source3/smbd/smb2_tcon.c
+++ b/source3/smbd/smb2_tcon.c
@@ -331,6 +331,10 @@ static NTSTATUS smbd_smb2_tree_connect(struct smbd_smb2_request *req,
 		}
 	}
 
+	if (guest_session) {
+		/* make sure we don't ask for optional encryption */
+		encryption_desired = false;
+	}
 	if (encryption_desired) {
 		encryption_flags |= SMBXSRV_ENCRYPTION_DESIRED;
 	}
diff --git a/source3/utils/conn_tdb.c b/source3/utils/conn_tdb.c
index 1109f08541c..7d31ae5759f 100644
--- a/source3/utils/conn_tdb.c
+++ b/source3/utils/conn_tdb.c
@@ -28,6 +28,7 @@
 #include "conn_tdb.h"
 #include "util_tdb.h"
 #include "lib/util/string_wrappers.h"
+#include "../libcli/security/session.h"
 
 struct connections_forall_state {
 	struct db_context *session_by_pid;
@@ -45,7 +46,7 @@ struct connections_forall_session {
 	uint16_t cipher;
 	uint16_t dialect;
 	uint16_t signing;
-	uint8_t signing_flags;
+	bool authenticated;
 };
 
 static int collect_sessions_fn(struct smbXsrv_session_global0 *global,
@@ -57,6 +58,7 @@ static int collect_sessions_fn(struct smbXsrv_session_global0 *global,
 
 	uint32_t id = global->session_global_id;
 	struct connections_forall_session sess;
+	enum security_user_level ul;
 
 	if (global->auth_session_info == NULL) {
 		sess.uid = -1;
@@ -70,7 +72,12 @@ static int collect_sessions_fn(struct smbXsrv_session_global0 *global,
 	sess.cipher = global->channels[0].encryption_cipher;
 	sess.signing = global->channels[0].signing_algo;
 	sess.dialect = global->connection_dialect;
-	sess.signing_flags = global->signing_flags;
+	ul = security_session_user_level(global->auth_session_info, NULL);
+	if (ul >= SECURITY_USER) {
+		sess.authenticated = true;
+	} else {
+		sess.authenticated = false;
+	}
 
 	status = dbwrap_store(state->session_by_pid,
 			      make_tdb_data((void*)&id, sizeof(id)),
@@ -135,6 +142,7 @@ static int traverse_tcon_fn(struct smbXsrv_tcon_global0 *global,
 	data.dialect = sess.dialect;
 	data.signing = sess.signing;
 	data.signing_flags = global->signing_flags;
+	data.authenticated = sess.authenticated;
 
 	state->count++;
 
diff --git a/source3/utils/conn_tdb.h b/source3/utils/conn_tdb.h
index 2a6e04e0a82..23a5e214ff2 100644
--- a/source3/utils/conn_tdb.h
+++ b/source3/utils/conn_tdb.h
@@ -36,6 +36,7 @@ struct connections_data {
 	uint16_t dialect;
 	uint8_t signing_flags;
 	uint16_t signing;
+	bool authenticated;
 };
 
 /* The following definitions come from lib/conn_tdb.c  */
diff --git a/source3/utils/status.c b/source3/utils/status.c
index 4102b415601..02a5f6dbaba 100644
--- a/source3/utils/status.c
+++ b/source3/utils/status.c
@@ -483,9 +483,33 @@ static int traverse_connections_stdout(struct traverse_state *state,
 				       char *server_id,
 				       const char *machine,
 				       const char *timestr,
-				       const char *encryption,
-				       const char *signing)
+				       const char *encryption_cipher,
+				       enum crypto_degree encryption_degree,
+				       const char *signing_cipher,
+				       enum crypto_degree signing_degree)
 {
+	fstring encryption;
+	fstring signing;
+
+	if (encryption_degree == CRYPTO_DEGREE_FULL) {
+		fstr_sprintf(encryption, "%s", encryption_cipher);
+	} else if (encryption_degree == CRYPTO_DEGREE_ANONYMOUS) {
+		fstr_sprintf(encryption, "anonymous(%s)", encryption_cipher);
+	} else if (encryption_degree == CRYPTO_DEGREE_PARTIAL) {
+		fstr_sprintf(encryption, "partial(%s)", encryption_cipher);
+	} else {
+		fstr_sprintf(encryption, "-");
+	}
+	if (signing_degree == CRYPTO_DEGREE_FULL) {
+		fstr_sprintf(signing, "%s", signing_cipher);
+	} else if (signing_degree == CRYPTO_DEGREE_ANONYMOUS) {
+		fstr_sprintf(signing, "anonymous(%s)", signing_cipher);
+	} else if (signing_degree == CRYPTO_DEGREE_PARTIAL) {
+		fstr_sprintf(signing, "partial(%s)", signing_cipher);
+	} else {
+		fstr_sprintf(signing, "-");
+	}
+
 	d_printf("%-12s %-7s %-13s %-32s %-12s %-12s\n",
 		 servicename, server_id, machine, timestr, encryption, signing);
 
@@ -538,7 +562,9 @@ static int traverse_connections(const struct connections_data *crec,
 		return -1;
 	}
 
-	if (smbXsrv_is_encrypted(crec->encryption_flags)) {
+	if (smbXsrv_is_encrypted(crec->encryption_flags) ||
+	    smbXsrv_is_partially_encrypted(crec->encryption_flags))
+	{
 		switch (crec->cipher) {
 		case SMB_ENCRYPTION_GSSAPI:
 			encryption = "GSSAPI";
@@ -549,14 +575,31 @@ static int traverse_connections(const struct connections_data *crec,
 		case SMB2_ENCRYPTION_AES128_GCM:
 			encryption = "AES-128-GCM";
 			break;
+		case SMB2_ENCRYPTION_AES256_CCM:
+			encryption = "AES-256-CCM";
+			break;
+		case SMB2_ENCRYPTION_AES256_GCM:
+			encryption = "AES-256-GCM";
+			break;
 		default:
 			encryption = "???";
 			break;
 		}
-		encryption_degree = CRYPTO_DEGREE_FULL;
+		if (smbXsrv_is_encrypted(crec->encryption_flags)) {
+			encryption_degree = CRYPTO_DEGREE_FULL;
+		} else if (smbXsrv_is_partially_encrypted(crec->encryption_flags)) {
+			encryption_degree = CRYPTO_DEGREE_PARTIAL;
+		}
+		if (encryption_degree != CRYPTO_DEGREE_NONE &&
+		    !crec->authenticated)
+		{
+			encryption_degree = CRYPTO_DEGREE_ANONYMOUS;
+		}
 	}
 
-	if (smbXsrv_is_signed(crec->signing_flags)) {
+	if (smbXsrv_is_signed(crec->signing_flags) ||
+	    smbXsrv_is_partially_signed(crec->signing_flags))
+	{
 		switch (crec->signing) {
 		case SMB2_SIGNING_MD5_SMB1:
 			signing = "HMAC-MD5";
@@ -574,7 +617,16 @@ static int traverse_connections(const struct connections_data *crec,
 			signing = "???";
 			break;
 		}


-- 
Samba Shared Repository



More information about the samba-cvs mailing list