svn commit: samba r5910 - in branches/SAMBA_3_0/source/utils: .

vlendec at samba.org vlendec at samba.org
Sun Mar 20 11:51:03 GMT 2005


Author: vlendec
Date: 2005-03-20 11:51:01 +0000 (Sun, 20 Mar 2005)
New Revision: 5910

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=5910

Log:
Partial fix for bug 2438. I'll leave the debug message in place, that fix is a
bit more effort.

The real fix for this would be to open an schannel netlogon connection to the
remote DC and change the trust account password...

Volker

Modified:
   branches/SAMBA_3_0/source/utils/net_rpc.c


Changeset:
Modified: branches/SAMBA_3_0/source/utils/net_rpc.c
===================================================================
--- branches/SAMBA_3_0/source/utils/net_rpc.c	2005-03-20 09:23:37 UTC (rev 5909)
+++ branches/SAMBA_3_0/source/utils/net_rpc.c	2005-03-20 11:51:01 UTC (rev 5910)
@@ -4594,7 +4594,7 @@
 	TALLOC_CTX *mem_ctx;
 	NTSTATUS nt_status;
 	DOM_SID *domain_sid;
-	WKS_INFO_100 wks_info;
+	smb_ucs2_t *uni_domain_name;
 	
 	char* domain_name;
 	char* domain_name_pol;
@@ -4663,44 +4663,17 @@
 			 for domain %s\n", domain_name));
 	}
 	 
-	/*
-	 * Call WksQueryInfo to check remote server's capabilities
-	 * note: It is now used only to get unicode domain name
-	 */
-	
-	if (!cli_nt_session_open(cli, PI_WKSSVC)) {
-		DEBUG(0, ("Couldn't not initialise wkssvc pipe\n"));
-		return -1;
-	}
-
-	if (!(mem_ctx = talloc_init("establishing trust relationship to domain %s",
-	                domain_name))) {
+	if (!(mem_ctx = talloc_init("establishing trust relationship to "
+				    "domain %s", domain_name))) {
 		DEBUG(0, ("talloc_init() failed\n"));
 		cli_shutdown(cli);
 		return -1;
 	}
 	
-   	nt_status = cli_wks_query_info(cli, mem_ctx, &wks_info);
-	
-	if (NT_STATUS_IS_ERR(nt_status)) {
-		DEBUG(0, ("WksQueryInfo call failed.\n"));
-		return -1;
-	}
-
-	if (cli->nt_pipe_fnum[cli->pipe_idx])
-		cli_nt_session_close(cli);
-
-
 	/*
 	 * Call LsaOpenPolicy and LsaQueryInfo
 	 */
 	 
-	if (!(mem_ctx = talloc_init("rpc_trustdom_establish"))) {
-		DEBUG(0, ("talloc_init() failed\n"));
-		cli_shutdown(cli);
-		return -1;
-	}
-
 	if (!cli_nt_session_open(cli, PI_LSARPC)) {
 		DEBUG(0, ("Could not initialise lsa pipe\n"));
 		cli_shutdown(cli);
@@ -4718,17 +4691,20 @@
 	/* Querying info level 5 */
 	
 	nt_status = cli_lsa_query_info_policy(cli, mem_ctx, &connect_hnd,
-	                                      5 /* info level */, &domain_name_pol,
-	                                      &domain_sid);
+	                                      5 /* info level */,
+					      &domain_name_pol, &domain_sid);
 	if (NT_STATUS_IS_ERR(nt_status)) {
 		DEBUG(0, ("LSA Query Info failed. Returned error was %s\n",
 			nt_errstr(nt_status)));
 		return -1;
 	}
 
+	if (push_ucs2_talloc(mem_ctx, &uni_domain_name, domain_name_pol) < 0) {
+		DEBUG(0, ("Could not convert domain name %s to unicode\n",
+			  domain_name_pol));
+		return -1;
+	}
 
-
-
 	/* There should be actually query info level 3 (following nt serv behaviour),
 	   but I still don't know if it's _really_ necessary */
 			
@@ -4736,8 +4712,10 @@
 	 * Store the password in secrets db
 	 */
 
-	if (!secrets_store_trusted_domain_password(domain_name, wks_info.uni_lan_grp.buffer,
-						   wks_info.uni_lan_grp.uni_str_len, opt_password,
+	if (!secrets_store_trusted_domain_password(domain_name,
+						   uni_domain_name,
+						   strlen_w(uni_domain_name)+1,
+						   opt_password,
 						   *domain_sid)) {
 		DEBUG(0, ("Storing password for trusted domain failed.\n"));
 		return -1;
@@ -4756,6 +4734,8 @@
 
 	if (cli->nt_pipe_fnum[cli->pipe_idx])
 		cli_nt_session_close(cli);
+
+	cli_shutdown(cli);
 	 
 	talloc_destroy(mem_ctx);
 	 



More information about the samba-cvs mailing list