[PATCH 20/22] set_dc_type_and_flags_trustinfo: Use init_dc_connection and wb_open_internal_pipe

abartlet at samba.org abartlet at samba.org
Tue Aug 19 20:06:55 MDT 2014


From: Andrew Bartlett <abartlet at samba.org>

This means we call this code, and mark trusted domains as active directory, when we are an AD DC.

Otherwise, in the previous case we would not have domain->active_directory set, and would fail on
connection_ok() due to not having a full connection to our internal DC

Change-Id: I7ccee569d69d6c5466334540db8920e57aafa991
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
---
 source3/winbindd/winbindd_cm.c | 37 ++++++++++++++++++++++---------------
 1 file changed, 22 insertions(+), 15 deletions(-)

diff --git a/source3/winbindd/winbindd_cm.c b/source3/winbindd/winbindd_cm.c
index 09e5be0..bef0114 100644
--- a/source3/winbindd/winbindd_cm.c
+++ b/source3/winbindd/winbindd_cm.c
@@ -2021,9 +2021,11 @@ static bool set_dc_type_and_flags_trustinfo( struct winbindd_domain *domain )
 	}
 
 	our_domain = find_our_domain();
-
-	if ( !connection_ok(our_domain) ) {
-		DEBUG(3,("set_dc_type_and_flags_trustinfo: No connection to our domain!\n"));		
+	result = init_dc_connection(our_domain, false);
+	
+	if (!NT_STATUS_IS_OK(result)) {
+		DEBUG(3,("set_dc_type_and_flags_trustinfo: Not able to make a connection to our domain: %s\n",
+			 nt_errstr(result)));
 		return False;
 	}
 
@@ -2033,25 +2035,30 @@ static bool set_dc_type_and_flags_trustinfo( struct winbindd_domain *domain )
 		return False;
 	}
 
-	/* Use DsEnumerateDomainTrusts to get us the trust direction
-	   and type */
+	mem_ctx = talloc_stackframe();
 
-	result = cm_connect_netlogon(our_domain, &cli);
+	if (our_domain->internal) {
+		result = wb_open_internal_pipe(mem_ctx, &ndr_table_netlogon, &cli);
+	} else if (!connection_ok(our_domain)) {
+		DEBUG(3,("set_dc_type_and_flags_trustinfo: No connection to our domain!\n"));		
+		TALLOC_FREE(mem_ctx);
+		return False;
+	} else {
+		result = cm_connect_netlogon(our_domain, &cli);
+	}
 
 	if (!NT_STATUS_IS_OK(result)) {
 		DEBUG(5, ("set_dc_type_and_flags_trustinfo: Could not open "
 			  "a connection to %s for PIPE_NETLOGON (%s)\n", 
 			  domain->name, nt_errstr(result)));
+		TALLOC_FREE(mem_ctx);
 		return False;
 	}
 
 	b = cli->binding_handle;
-
-	if ( (mem_ctx = talloc_init("set_dc_type_and_flags_trustinfo")) == NULL ) {
-		DEBUG(0,("set_dc_type_and_flags_trustinfo: talloc_init() failed!\n"));
-		return False;
-	}	
-
+	
+	/* Use DsEnumerateDomainTrusts to get us the trust direction and type. */
+		
 	result = dcerpc_netr_DsrEnumerateDomainTrusts(b, mem_ctx,
 						      cli->desthost,
 						      flags,
@@ -2061,14 +2068,14 @@ static bool set_dc_type_and_flags_trustinfo( struct winbindd_domain *domain )
 		DEBUG(0,("set_dc_type_and_flags_trustinfo: "
 			"failed to query trusted domain list: %s\n",
 			nt_errstr(result)));
-		talloc_destroy(mem_ctx);
+		TALLOC_FREE(mem_ctx);
 		return false;
 	}
 	if (!W_ERROR_IS_OK(werr)) {
 		DEBUG(0,("set_dc_type_and_flags_trustinfo: "
 			"failed to query trusted domain list: %s\n",
 			win_errstr(werr)));
-		talloc_destroy(mem_ctx);
+		TALLOC_FREE(mem_ctx);
 		return false;
 	}
 
@@ -2105,7 +2112,7 @@ static bool set_dc_type_and_flags_trustinfo( struct winbindd_domain *domain )
 		}		
 	}
 
-	talloc_destroy( mem_ctx );
+	TALLOC_FREE( mem_ctx );
 
 	return domain->initialized;	
 }
-- 
2.0.1



More information about the samba-technical mailing list