[Patch] make sure cm_prepare_connection() only returns OK with a valid tree connect [bug #

Stefan Metzmacher metze at samba.org
Tue Feb 21 15:00:04 UTC 2017


Hi,

here's a patch that makes sure cm_prepare_connection() only returns OK
with a valid tree connect.
https://bugzilla.samba.org/show_bug.cgi?id=12588

Please review and push:-)

Thanks!
metze
-------------- next part --------------
From 529d2834ec67d5dbb70ce99c37fb2ddc06761c4e Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Tue, 31 Jan 2017 15:19:00 +0100
Subject: [PATCH] s3:winbindd: make sure cm_prepare_connection() only returns
 OK with a valid tree connect

If cm_get_ipc_credentials() returned anonymous creds and signing is required
we were returning the result of cm_get_ipc_credentials() instead of
the original error.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12588

Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
 source3/winbindd/winbindd_cm.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/source3/winbindd/winbindd_cm.c b/source3/winbindd/winbindd_cm.c
index d8c894c..41a0076 100644
--- a/source3/winbindd/winbindd_cm.c
+++ b/source3/winbindd/winbindd_cm.c
@@ -1001,6 +1001,8 @@ static NTSTATUS cm_prepare_connection(struct winbindd_domain *domain,
 	struct named_mutex *mutex;
 
 	NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
+	NTSTATUS tmp_status;
+	NTSTATUS tcon_status = NT_STATUS_NETWORK_NAME_DELETED;
 
 	enum smb_signing_setting smb_sign_client_connections = lp_client_ipc_signing();
 
@@ -1152,8 +1154,9 @@ static NTSTATUS cm_prepare_connection(struct winbindd_domain *domain,
 
  ipc_fallback:
 	TALLOC_FREE(creds);
-	result = cm_get_ipc_credentials(talloc_tos(), &creds);
-	if (!NT_STATUS_IS_OK(result)) {
+	tmp_status = cm_get_ipc_credentials(talloc_tos(), &creds);
+	if (!NT_STATUS_IS_OK(tmp_status)) {
+		result = tmp_status;
 		goto done;
 	}
 
@@ -1228,11 +1231,11 @@ static NTSTATUS cm_prepare_connection(struct winbindd_domain *domain,
 	}
 
 	result = cli_tree_connect(*cli, "IPC$", "IPC", NULL);
-
 	if (!NT_STATUS_IS_OK(result)) {
 		DEBUG(1,("failed tcon_X with %s\n", nt_errstr(result)));
 		goto done;
 	}
+	tcon_status = result;
 
 	/* cache the server name for later connections */
 
@@ -1252,6 +1255,10 @@ static NTSTATUS cm_prepare_connection(struct winbindd_domain *domain,
 	TALLOC_FREE(mutex);
 	TALLOC_FREE(creds);
 
+	if (NT_STATUS_IS_OK(result)) {
+		result = tcon_status;
+	}
+
 	if (!NT_STATUS_IS_OK(result)) {
 		winbind_add_failed_connection_entry(domain, controller, result);
 		if ((*cli) != NULL) {
-- 
1.9.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20170221/a330ef9e/signature.sig>


More information about the samba-technical mailing list