[SCM] Samba Shared Repository - branch v3-2-test updated - release-3-2-0pre2-622-gb12edbe

Günther Deschner gd at samba.org
Wed Apr 2 10:54:27 GMT 2008


The branch, v3-2-test has been updated
       via  b12edbeffee1f7d1fd971cde9189e5137ddeb35b (commit)
       via  8a1a9f967db25d3928f19e46d60af249f934f323 (commit)
      from  4714bae0dbbb2ad010c2929f83de6bca84cfac46 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test


- Log -----------------------------------------------------------------
commit b12edbeffee1f7d1fd971cde9189e5137ddeb35b
Author: Günther Deschner <gd at samba.org>
Date:   Wed Apr 2 12:29:24 2008 +0200

    Fix "net rpc trustdom establish" for win2k8 trusts.
    
    When establishing trusts to a windows 2008 dc, the NetServerEnum2 RAP call fails
    with some exotic RAP failure. Let's just try a netlogon getdcname call in
    that case to convince ourselve we're talking to a proper machine.
    
    Rafael, looks ok?
    
    Guenther

commit 8a1a9f967db25d3928f19e46d60af249f934f323
Author: Günther Deschner <gd at samba.org>
Date:   Wed Apr 2 12:23:07 2008 +0200

    Apply some const in clirap.
    
    Guenther

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

Summary of changes:
 source/libsmb/clirap2.c |    2 +-
 source/utils/net_rpc.c  |   66 +++++++++++++++++++++++++++++++++++++----------
 2 files changed, 53 insertions(+), 15 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/libsmb/clirap2.c b/source/libsmb/clirap2.c
index d579564..9cc8110 100644
--- a/source/libsmb/clirap2.c
+++ b/source/libsmb/clirap2.c
@@ -1469,7 +1469,7 @@ int cli_NetShareDelete(struct cli_state *cli, const char * share_name )
 *
 ************************************************************************/
 
-bool cli_get_pdc_name(struct cli_state *cli, char *workgroup, char **pdc_name)
+bool cli_get_pdc_name(struct cli_state *cli, const char *workgroup, char **pdc_name)
 {
 	char *rparam = NULL;
 	char *rdata = NULL;
diff --git a/source/utils/net_rpc.c b/source/utils/net_rpc.c
index 25c1f42..0d47b65 100644
--- a/source/utils/net_rpc.c
+++ b/source/utils/net_rpc.c
@@ -5841,7 +5841,49 @@ static int rpc_trustdom_del(int argc, const char **argv)
 		return -1;
 	}
 }
- 
+
+static NTSTATUS rpc_trustdom_get_pdc(struct cli_state *cli,
+				     TALLOC_CTX *mem_ctx,
+				     const char *domain_name)
+{
+	char *dc_name = NULL;
+	const char *buffer = NULL;
+	struct rpc_pipe_client *netr;
+	NTSTATUS status;
+
+	/* Use NetServerEnum2 */
+
+	if (cli_get_pdc_name(cli, domain_name, &dc_name)) {
+		SAFE_FREE(dc_name);
+		return NT_STATUS_OK;
+	}
+
+	DEBUG(1,("NetServerEnum2 error: Couldn't find primary domain controller\
+		 for domain %s\n", domain_name));
+
+	/* Try netr_GetDcName */
+
+	netr = cli_rpc_pipe_open_noauth(cli, PI_NETLOGON, &status);
+	if (!netr) {
+		return status;
+	}
+
+	status = rpccli_netr_GetDcName(netr, mem_ctx,
+				       cli->desthost,
+				       domain_name,
+				       &buffer,
+				       NULL);
+	cli_rpc_pipe_close(netr);
+
+	if (NT_STATUS_IS_OK(status)) {
+		return status;
+	}
+
+	DEBUG(1,("netr_GetDcName error: Couldn't find primary domain controller\
+		 for domain %s\n", domain_name));
+
+	return status;
+}
 
 /**
  * Establish trust relationship to a trusting domain.
@@ -5866,7 +5908,6 @@ static int rpc_trustdom_establish(int argc, const char **argv)
 	char* domain_name;
 	char* acct_name;
 	fstring pdc_name;
-	char *dc_name;
 	union lsa_PolicyInformation *info = NULL;
 
 	/*
@@ -5927,18 +5968,6 @@ static int rpc_trustdom_establish(int argc, const char **argv)
 		return -1;
 	}
 
-	/*
-	 * Use NetServerEnum2 to make sure we're talking to a proper server
-	 */
-
-	if (!cli_get_pdc_name(cli, domain_name, &dc_name)) {
-		DEBUG(0, ("NetServerEnum2 error: Couldn't find primary domain controller\
-			 for domain %s\n", domain_name));
-		cli_shutdown(cli);
-		return -1;
-	}
-	SAFE_FREE(dc_name);
-	 
 	if (!(mem_ctx = talloc_init("establishing trust relationship to "
 				    "domain %s", domain_name))) {
 		DEBUG(0, ("talloc_init() failed\n"));
@@ -5946,6 +5975,15 @@ static int rpc_trustdom_establish(int argc, const char **argv)
 		return -1;
 	}
 
+	/* Make sure we're talking to a proper server */
+
+	nt_status = rpc_trustdom_get_pdc(cli, mem_ctx, domain_name);
+	if (!NT_STATUS_IS_OK(nt_status)) {
+		cli_shutdown(cli);
+		talloc_destroy(mem_ctx);
+		return -1;
+	}
+
 	/*
 	 * Call LsaOpenPolicy and LsaQueryInfo
 	 */


-- 
Samba Shared Repository


More information about the samba-cvs mailing list