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

Volker Lendecke vlendec at samba.org
Fri Apr 25 14:35:13 GMT 2008


The branch, v3-2-test has been updated
       via  6b2b45002449140b06eaea2e5132e03029555d01 (commit)
       via  74dce8c79a6402721bf7371bf2906d3476855c10 (commit)
       via  04e1a1f23b3083d4f3c61c9271ed216c88e36386 (commit)
       via  0dc88c3efcc26038aca79f425db7c6daf3b372f2 (commit)
       via  1ec14224e7c041756118d3c5a32eb3385d720e27 (commit)
       via  f889ed188f6cddf2862f7f53956a263bdfee6bff (commit)
       via  3312c93cc6760b1ebdfcd7a2b1508b23a780173c (commit)
       via  b71e9eafc9f4806365446aa65a6b67e6dac5286e (commit)
       via  6fe266f8d42c9634d0c87a8f56357e5cd2804ae9 (commit)
       via  d0068b08ee6e8ee723943c244aad73f1d9d3a997 (commit)
       via  cee2119701ec0b4ead3049d2ae3a3a2fb4ab9e54 (commit)
       via  db0dbe1d100b59bae28a59fe0ec940e5989cb58d (commit)
       via  298fbbf1c9693f49f3b9b142111f31c20f40ce1f (commit)
       via  bf2c31ae0b11fb18b7e3f23695784bb834145ec7 (commit)
       via  b44d1b2ed54b5b858c834da48e08eff3b7a4800c (commit)
       via  1db152ed07e748727b99e3bb2895faa5bc48bf04 (commit)
      from  ec46de7e0550ea94ade60af29734de8891804c87 (commit)

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


- Log -----------------------------------------------------------------
commit 6b2b45002449140b06eaea2e5132e03029555d01
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Apr 25 16:35:23 2008 +0200

    Revert "Set the right domain\user in cli_rpc_pipe_open_ntlmssp_internal"
    
    This reverts commit b90062e33cbde7de4961414fd35a3a588760d002.

commit 74dce8c79a6402721bf7371bf2906d3476855c10
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Apr 25 16:35:10 2008 +0200

    Revert "Refactoring: Make struct rpc_pipe_client its own talloc parent"
    
    This reverts commit a6d74a5a562b54f0b36934965f545fdeb1e8b34a.

commit 04e1a1f23b3083d4f3c61c9271ed216c88e36386
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Apr 25 16:35:05 2008 +0200

    Revert "Add "desthost" to rpc_pipe_client"
    
    This reverts commit 783afab9c891dd7bcb78895b2a639b6f3a0edf5b.

commit 0dc88c3efcc26038aca79f425db7c6daf3b372f2
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Apr 25 16:34:59 2008 +0200

    Revert "Fix two "ignoring asprintf result" warnings"
    
    This reverts commit 1d261e78b38e8080ca7122037d33c8ef913a4558.

commit 1ec14224e7c041756118d3c5a32eb3385d720e27
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Apr 25 16:34:30 2008 +0200

    Revert "Move srv_name_slash from cli_state to rpc_pipe_client"
    
    This reverts commit a9061e52e1ff8e31aa480f4a30cda64c9d93214e.

commit f889ed188f6cddf2862f7f53956a263bdfee6bff
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Apr 25 16:34:18 2008 +0200

    Revert "Introduce rpccli_set_timeout()"
    
    This reverts commit 2e4c1ba38963cffe4c3f25ab24bc28975f2fc291.

commit 3312c93cc6760b1ebdfcd7a2b1508b23a780173c
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Apr 25 16:34:11 2008 +0200

    Revert "Use rpc_pipe_client->user_name instead of rpc_pipe_client->cli->user_name"
    
    This reverts commit 3f6c5b99664a75a6f490ee3b6980b89cacf7f579.

commit b71e9eafc9f4806365446aa65a6b67e6dac5286e
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Apr 25 16:34:05 2008 +0200

    Revert "Remove some unused code referencing pipe_names[]"
    
    This reverts commit d8a04b798c44c26a91a37fa7090dd071a1909166.

commit 6fe266f8d42c9634d0c87a8f56357e5cd2804ae9
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Apr 25 16:33:54 2008 +0200

    Revert "Remove the pipe_idx variable from rpc_pipe_client"
    
    This reverts commit 4840febcd481563c3d9b2fabc1fe1b2ae5a76cf6.

commit d0068b08ee6e8ee723943c244aad73f1d9d3a997
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Apr 25 16:33:47 2008 +0200

    Revert "Refactoring: Move stuff around for creating a pipe"
    
    This reverts commit 45be749ed69f8c1ad3ebe8ea1f35c806db2ed5d0.

commit cee2119701ec0b4ead3049d2ae3a3a2fb4ab9e54
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Apr 25 16:33:35 2008 +0200

    Revert "Replace cli_rpc_pipe_close by a talloc destructor on rpc_pipe_struct"
    
    This reverts commit 99fc3283c4ecc791f5a242bd1983b4352ce3e6cf.

commit db0dbe1d100b59bae28a59fe0ec940e5989cb58d
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Apr 25 16:33:30 2008 +0200

    Revert "Remove a redundant reference to rpc_pipe_state->cli from srv_spoolss"
    
    This reverts commit 7331c4c2781bf7904942c119f1a8de8eda00ae7e.

commit 298fbbf1c9693f49f3b9b142111f31c20f40ce1f
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Apr 25 16:33:23 2008 +0200

    Revert "Introduce rpc_pipe_np_smb_conn()"
    
    This reverts commit c56e1c08cef107ff33a34346ceeca3475a102b19.

commit bf2c31ae0b11fb18b7e3f23695784bb834145ec7
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Apr 25 16:33:15 2008 +0200

    Revert "Make convert_samr_dispinfo_to_NET_DISPLAY() static"
    
    This reverts commit a30a26d471a572167ee13bf10be1a275a6592851.

commit b44d1b2ed54b5b858c834da48e08eff3b7a4800c
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Apr 25 16:33:01 2008 +0200

    Revert "Fix some empty lines with just spaces"
    
    This reverts commit f8fb9b7e3759bec7fbcf93b27438ca6b03202ddb.

commit 1db152ed07e748727b99e3bb2895faa5bc48bf04
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Apr 25 16:32:44 2008 +0200

    Revert "Remove the "pwd" struct from rpc_pipe_client"
    
    This reverts commit 3d8c2a47e677a4c4aacf4abf148b1bd8163c3351.

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

Summary of changes:
 source/client/client.c             |    6 +-
 source/include/client.h            |   15 +-
 source/include/rpc_client.h        |    2 +-
 source/lib/netapi/cm.c             |    6 +-
 source/lib/netapi/user.c           |   10 +-
 source/libads/ldap_printer.c       |    7 +-
 source/libnet/libnet_join.c        |   10 +-
 source/libsmb/cliconnect.c         |    2 +
 source/libsmb/clientgen.c          |   48 +++++-
 source/libsmb/libsmb_dir.c         |    4 +-
 source/libsmb/libsmb_xattr.c       |    2 +-
 source/libsmb/passchange.c         |   15 +-
 source/libsmb/smbencrypt.c         |   10 +-
 source/libsmb/trusts_util.c        |    2 +-
 source/rpc_client/cli_lsarpc.c     |    2 +-
 source/rpc_client/cli_netlogon.c   |   10 +-
 source/rpc_client/cli_pipe.c       |  317 ++++++++++++++++--------------------
 source/rpc_client/cli_samr.c       |   12 +-
 source/rpc_client/cli_spoolss.c    |   16 +-
 source/rpc_client/ndr.c            |    2 +-
 source/rpc_parse/parse_rpc.c       |    3 +-
 source/rpc_server/srv_spoolss_nt.c |    6 +-
 source/rpcclient/cmd_lsarpc.c      |   37 +---
 source/rpcclient/cmd_netlogon.c    |   40 ++---
 source/rpcclient/cmd_samr.c        |    5 +-
 source/rpcclient/cmd_spoolss.c     |   78 +++++----
 source/rpcclient/cmd_srvsvc.c      |   30 ++--
 source/rpcclient/cmd_test.c        |   10 +-
 source/rpcclient/cmd_wkssvc.c      |   12 +-
 source/rpcclient/rpcclient.c       |    8 +-
 source/smbd/change_trust_pw.c      |    3 +-
 source/utils/net_rpc.c             |  108 ++++++-------
 source/utils/net_rpc_join.c        |   10 +-
 source/utils/net_rpc_printer.c     |    9 +-
 source/utils/net_rpc_samsync.c     |    6 +-
 source/utils/net_rpc_service.c     |   12 +-
 source/utils/net_rpc_sh_acct.c     |    2 +-
 source/utils/net_rpc_shell.c       |    2 +-
 source/utils/net_util.c            |    2 +-
 source/utils/smbcacls.c            |    8 +-
 source/utils/smbtree.c             |    6 +-
 source/winbindd/winbindd_ads.c     |    2 +-
 source/winbindd/winbindd_cm.c      |   64 ++++----
 source/winbindd/winbindd_misc.c    |    4 +-
 source/winbindd/winbindd_rpc.c     |    4 +-
 45 files changed, 484 insertions(+), 485 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/client/client.c b/source/client/client.c
index b4e1985..276ffb9 100644
--- a/source/client/client.c
+++ b/source/client/client.c
@@ -3650,7 +3650,7 @@ static bool browse_host_rpc(bool sort)
 	info_ctr.ctr.ctr1 = &ctr1;
 
 	status = rpccli_srvsvc_NetShareEnumAll(pipe_hnd, frame,
-					      pipe_hnd->desthost,
+					      pipe_hnd->cli->desthost,
 					      &info_ctr,
 					      0xffffffff,
 					      &total_entries,
@@ -3658,7 +3658,7 @@ static bool browse_host_rpc(bool sort)
 					      &werr);
 
 	if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(werr)) {
-		TALLOC_FREE(pipe_hnd);
+		cli_rpc_pipe_close(pipe_hnd);
 		TALLOC_FREE(frame);
 		return false;
 	}
@@ -3668,7 +3668,7 @@ static bool browse_host_rpc(bool sort)
 		browse_fn(info.name, info.type, info.comment, NULL);
 	}
 
-	TALLOC_FREE(pipe_hnd);
+	cli_rpc_pipe_close(pipe_hnd);
 	TALLOC_FREE(frame);
 	return true;
 }
diff --git a/source/include/client.h b/source/include/client.h
index 9cbfa51..0e73745 100644
--- a/source/include/client.h
+++ b/source/include/client.h
@@ -60,19 +60,17 @@ struct cli_pipe_auth_data {
 struct rpc_pipe_client {
 	struct rpc_pipe_client *prev, *next;
 
+	TALLOC_CTX *mem_ctx;
+
 	struct cli_state *cli;
 
+	int pipe_idx;
 	const char *pipe_name;
 	uint16 fnum;
 
-	const struct ndr_syntax_id *abstract_syntax;
-	const struct ndr_syntax_id *transfer_syntax;
-
-	char *desthost;
-	char *srv_name_slash;
-
-	char *domain;
-	char *user_name;
+	const char *domain;
+	const char *user_name;
+	struct pwd_info pwd;
 
 	uint16 max_xmit_frag;
 	uint16 max_recv_frag;
@@ -125,6 +123,7 @@ struct cli_state {
 	int privileges;
 
 	fstring desthost;
+	fstring srv_name_slash;
 
 	/* The credentials used to open the cli_state connection. */
 	fstring domain;
diff --git a/source/include/rpc_client.h b/source/include/rpc_client.h
index ce0c932..c552271 100644
--- a/source/include/rpc_client.h
+++ b/source/include/rpc_client.h
@@ -91,7 +91,7 @@
 #define CLI_DO_RPC_WERR( pcli, ctx, p_idx, opnum, q_in, r_out, \
                              q_ps, r_ps, q_io_fn, r_io_fn, default_error ) \
 {\
-	SMB_ASSERT(rpccli_is_pipe_idx(pcli, p_idx)); \
+	SMB_ASSERT(pcli->pipe_idx == p_idx); \
 	if (!prs_init( &q_ps, RPC_MAX_PDU_FRAG_LEN, ctx, MARSHALL )) { \
 		return WERR_NOMEM;\
 	}\
diff --git a/source/lib/netapi/cm.c b/source/lib/netapi/cm.c
index ae1091c..071ebfd 100644
--- a/source/lib/netapi/cm.c
+++ b/source/lib/netapi/cm.c
@@ -99,13 +99,13 @@ static struct rpc_pipe_client *pipe_cm_find(struct cli_state *cli,
 
 	for (p = pipe_connections; p; p = p->next) {
 
-		if (!rpc_pipe_np_smb_conn(p->pipe)) {
+		if (!p->pipe->cli) {
 			*status = NT_STATUS_PIPE_EMPTY;
 			return NULL;
 		}
 
-		if (strequal(cli->desthost, p->pipe->desthost) &&
-		    rpccli_is_pipe_idx(p->pipe, pipe_idx)) {
+		if (strequal(cli->desthost, p->pipe->cli->desthost) &&
+		    pipe_idx == p->pipe->pipe_idx) {
 			*status = NT_STATUS_OK;
 			return p->pipe;
 		}
diff --git a/source/lib/netapi/user.c b/source/lib/netapi/user.c
index f2dc785..05a0510 100644
--- a/source/lib/netapi/user.c
+++ b/source/lib/netapi/user.c
@@ -845,11 +845,11 @@ static WERROR convert_samr_dispinfo_to_NET_DISPLAY_GROUP(TALLOC_CTX *mem_ctx,
 /****************************************************************
 ****************************************************************/
 
-static WERROR convert_samr_dispinfo_to_NET_DISPLAY(TALLOC_CTX *mem_ctx,
-						   union samr_DispInfo *info,
-						   uint32_t level,
-						   uint32_t *entries_read,
-						   void **buffer)
+WERROR convert_samr_dispinfo_to_NET_DISPLAY(TALLOC_CTX *mem_ctx,
+					    union samr_DispInfo *info,
+					    uint32_t level,
+					    uint32_t *entries_read,
+					    void **buffer)
 {
 	switch (level) {
 		case 1:
diff --git a/source/libads/ldap_printer.c b/source/libads/ldap_printer.c
index 6682ec2..05fbc07 100644
--- a/source/libads/ldap_printer.c
+++ b/source/libads/ldap_printer.c
@@ -288,15 +288,16 @@ WERROR get_remote_printer_publishing_data(struct rpc_pipe_client *cli,
 	uint32 i;
 	POLICY_HND pol;
 
-	if ((asprintf(&servername, "\\\\%s", cli->desthost) == -1)
-	    || (asprintf(&printername, "%s\\%s", servername, printer) == -1)) {
+	asprintf(&servername, "\\\\%s", cli->cli->desthost);
+	asprintf(&printername, "%s\\%s", servername, printer);
+	if (!servername || !printername) {
 		DEBUG(3, ("Insufficient memory\n"));
 		return WERR_NOMEM;
 	}
 	
 	result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername, 
 					     "", MAXIMUM_ALLOWED_ACCESS, 
-					     servername, cli->user_name, &pol);
+					     servername, cli->cli->user_name, &pol);
 	if (!W_ERROR_IS_OK(result)) {
 		DEBUG(3, ("Unable to open printer %s, error is %s.\n",
 			  printername, dos_errstr(result)));
diff --git a/source/libnet/libnet_join.c b/source/libnet/libnet_join.c
index 7e348e2..9834a37 100644
--- a/source/libnet/libnet_join.c
+++ b/source/libnet/libnet_join.c
@@ -706,7 +706,7 @@ static NTSTATUS libnet_join_lookup_dc_rpc(TALLOC_CTX *mem_ctx,
 	}
 
 	rpccli_lsa_Close(pipe_hnd, mem_ctx, &lsa_pol);
-	TALLOC_FREE(pipe_hnd);
+	cli_rpc_pipe_close(pipe_hnd);
 
  done:
 	return status;
@@ -755,7 +755,7 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx,
 	}
 
 	status = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
-				      pipe_hnd->desthost,
+				      pipe_hnd->cli->desthost,
 				      SEC_RIGHTS_MAXIMUM_ALLOWED,
 				      &sam_pol);
 	if (!NT_STATUS_IS_OK(status)) {
@@ -951,7 +951,7 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx,
 	if (is_valid_policy_hnd(&user_pol)) {
 		rpccli_samr_Close(pipe_hnd, mem_ctx, &user_pol);
 	}
-	TALLOC_FREE(pipe_hnd);
+	cli_rpc_pipe_close(pipe_hnd);
 
 	return status;
 }
@@ -1137,7 +1137,7 @@ static NTSTATUS libnet_join_unjoindomain_rpc(TALLOC_CTX *mem_ctx,
 	}
 
 	status = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
-				      pipe_hnd->desthost,
+				      pipe_hnd->cli->desthost,
 				      SEC_RIGHTS_MAXIMUM_ALLOWED,
 				      &sam_pol);
 	if (!NT_STATUS_IS_OK(status)) {
@@ -1217,7 +1217,7 @@ done:
 	if (pipe_hnd) {
 		rpccli_samr_Close(pipe_hnd, mem_ctx, &domain_pol);
 		rpccli_samr_Close(pipe_hnd, mem_ctx, &sam_pol);
-		TALLOC_FREE(pipe_hnd);
+		cli_rpc_pipe_close(pipe_hnd);
 	}
 
 	if (cli) {
diff --git a/source/libsmb/cliconnect.c b/source/libsmb/cliconnect.c
index 7d3d246..949bca7 100644
--- a/source/libsmb/cliconnect.c
+++ b/source/libsmb/cliconnect.c
@@ -1492,6 +1492,8 @@ NTSTATUS cli_connect(struct cli_state *cli,
 	}
 
 	fstrcpy(cli->desthost, host);
+	fstr_sprintf(cli->srv_name_slash, "\\\\%s", cli->desthost);
+	strupper_m(cli->srv_name_slash);
 
 	/* allow hostnames of the form NAME#xx and do a netbios lookup */
 	if ((p = strchr(cli->desthost, '#'))) {
diff --git a/source/libsmb/clientgen.c b/source/libsmb/clientgen.c
index e64b6fa..6419123 100644
--- a/source/libsmb/clientgen.c
+++ b/source/libsmb/clientgen.c
@@ -617,16 +617,54 @@ struct cli_state *cli_initialise(void)
 }
 
 /****************************************************************************
+ External interface.
+ Close an open named pipe over SMB. Free any authentication data.
+ Returns false if the cli_close call failed.
+ ****************************************************************************/
+
+bool cli_rpc_pipe_close(struct rpc_pipe_client *cli)
+{
+	bool ret;
+
+	if (!cli) {
+		return false;
+	}
+
+	ret = cli_close(cli->cli, cli->fnum);
+
+	if (!ret) {
+		DEBUG(1,("cli_rpc_pipe_close: cli_close failed on pipe %s, "
+                         "fnum 0x%x "
+                         "to machine %s.  Error was %s\n",
+                         cli->pipe_name,
+                         (int) cli->fnum,
+                         cli->cli->desthost,
+                         cli_errstr(cli->cli)));
+	}
+
+	if (cli->auth.cli_auth_data_free_func) {
+		(*cli->auth.cli_auth_data_free_func)(&cli->auth);
+	}
+
+	DEBUG(10,("cli_rpc_pipe_close: closed pipe %s to machine %s\n",
+		cli->pipe_name, cli->cli->desthost ));
+
+	DLIST_REMOVE(cli->cli->pipe_list, cli);
+	talloc_destroy(cli->mem_ctx);
+	return ret;
+}
+
+/****************************************************************************
  Close all pipes open on this session.
 ****************************************************************************/
 
 void cli_nt_pipes_close(struct cli_state *cli)
 {
-	while (cli->pipe_list != NULL) {
-		/*
-		 * No TALLOC_FREE here!
-		 */
-		talloc_free(cli->pipe_list);
+	struct rpc_pipe_client *cp, *next;
+
+	for (cp = cli->pipe_list; cp; cp = next) {
+		next = cp->next;
+		cli_rpc_pipe_close(cp);
 	}
 }
 
diff --git a/source/libsmb/libsmb_dir.c b/source/libsmb/libsmb_dir.c
index aea4f10..f836989 100644
--- a/source/libsmb/libsmb_dir.c
+++ b/source/libsmb/libsmb_dir.c
@@ -287,7 +287,7 @@ net_share_enum_rpc(struct cli_state *cli,
 
         /* Issue the NetShareEnum RPC call and retrieve the response */
 	nt_status = rpccli_srvsvc_NetShareEnumAll(pipe_hnd, talloc_tos(),
-						  pipe_hnd->desthost,
+						  pipe_hnd->cli->desthost,
 						  &info_ctr,
 						  preferred_len,
 						  &total_entries,
@@ -319,7 +319,7 @@ net_share_enum_rpc(struct cli_state *cli,
 
 done:
         /* Close the server service pipe */
-        TALLOC_FREE(pipe_hnd);
+        cli_rpc_pipe_close(pipe_hnd);
 
         /* Tell 'em if it worked */
         return W_ERROR_IS_OK(result) ? 0 : -1;
diff --git a/source/libsmb/libsmb_xattr.c b/source/libsmb/libsmb_xattr.c
index 8763205..e17146e 100644
--- a/source/libsmb/libsmb_xattr.c
+++ b/source/libsmb/libsmb_xattr.c
@@ -39,7 +39,7 @@ find_lsa_pipe_hnd(struct cli_state *ipc_cli)
              pipe_hnd;
              pipe_hnd = pipe_hnd->next) {
                 
-		if (rpccli_is_pipe_idx(pipe_hnd, PI_LSARPC)) {
+		if (pipe_hnd->pipe_idx == PI_LSARPC) {
 			return pipe_hnd;
 		}
 	}
diff --git a/source/libsmb/passchange.c b/source/libsmb/passchange.c
index 8f7cbf2..468750f 100644
--- a/source/libsmb/passchange.c
+++ b/source/libsmb/passchange.c
@@ -177,9 +177,8 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam
 		}
 	}
 
-	result = rpccli_samr_chgpasswd_user(pipe_hnd, talloc_tos(),
-					    user_name, new_passwd, old_passwd);
-	if (NT_STATUS_IS_OK(result)) {
+	if (NT_STATUS_IS_OK(result = rpccli_samr_chgpasswd_user(pipe_hnd, pipe_hnd->mem_ctx, user_name, 
+							     new_passwd, old_passwd))) {
 		/* Great - it all worked! */
 		cli_shutdown(cli);
 		return NT_STATUS_OK;
@@ -196,7 +195,7 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam
 	}
 
 	/* OK, that failed, so try again... */
-	TALLOC_FREE(pipe_hnd);
+	cli_rpc_pipe_close(pipe_hnd);
 	
 	/* Try anonymous NTLMSSP... */
 	cli_init_creds(cli, "", "", NULL);
@@ -207,9 +206,11 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam
 	pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_SAMR, &result);
 
 	if ( pipe_hnd &&
-		(NT_STATUS_IS_OK(result = rpccli_samr_chgpasswd_user(
-					 pipe_hnd, talloc_tos(), user_name,
-					 new_passwd, old_passwd)))) {
+		(NT_STATUS_IS_OK(result = rpccli_samr_chgpasswd_user(pipe_hnd,
+						pipe_hnd->mem_ctx,
+						user_name, 
+						new_passwd,
+						old_passwd)))) {
 		/* Great - it all worked! */
 		cli_shutdown(cli);
 		return NT_STATUS_OK;
diff --git a/source/libsmb/smbencrypt.c b/source/libsmb/smbencrypt.c
index 11f8780..e7198b8 100644
--- a/source/libsmb/smbencrypt.c
+++ b/source/libsmb/smbencrypt.c
@@ -630,23 +630,27 @@ void sess_crypt_blob(DATA_BLOB *out, const DATA_BLOB *in, const DATA_BLOB *sessi
 }
 
 /* Decrypts password-blob with session-key
- * @param nt_hash	NT hash for the session key
+ * @param pass		password for session-key
  * @param data_in 	DATA_BLOB encrypted password
  *
  * Returns cleartext password in CH_UNIX 
  * Caller must free the returned string
  */
 
-char *decrypt_trustdom_secret(uint8_t nt_hash[16], DATA_BLOB *data_in)
+char *decrypt_trustdom_secret(const char *pass, DATA_BLOB *data_in)
 {
 	DATA_BLOB data_out, sess_key;
+	uchar nt_hash[16];
 	uint32_t length;
 	uint32_t version;
 	fstring cleartextpwd;
 
-	if (!data_in || !nt_hash)
+	if (!data_in || !pass)
 		return NULL;
 
+	/* generate md4 password-hash derived from the NT UNICODE password */
+	E_md4hash(pass, nt_hash);
+
 	/* hashed twice with md4 */
 	mdfour(nt_hash, nt_hash, 16);
 
diff --git a/source/libsmb/trusts_util.c b/source/libsmb/trusts_util.c
index 20ac014..c3f5f25 100644
--- a/source/libsmb/trusts_util.c
+++ b/source/libsmb/trusts_util.c
@@ -43,7 +43,7 @@ static NTSTATUS just_change_the_password(struct rpc_pipe_client *cli, TALLOC_CTX
 		uint32_t neg_flags = NETLOGON_NEG_AUTH2_ADS_FLAGS;
 
 		result = rpccli_netlogon_setup_creds(cli, 
-					cli->desthost, /* server name */
+					cli->cli->desthost, /* server name */
 					lp_workgroup(), /* domain */
 					global_myname(), /* client name */
 					global_myname(), /* machine account name */
diff --git a/source/rpc_client/cli_lsarpc.c b/source/rpc_client/cli_lsarpc.c
index a799f92..37387a0 100644
--- a/source/rpc_client/cli_lsarpc.c
+++ b/source/rpc_client/cli_lsarpc.c
@@ -108,7 +108,7 @@ NTSTATUS rpccli_lsa_open_policy2(struct rpc_pipe_client *cli,
 	}
 
 	return rpccli_lsa_OpenPolicy2(cli, mem_ctx,
-				      cli->srv_name_slash,
+				      cli->cli->srv_name_slash,
 				      &attr,
 				      des_access,
 				      pol);
diff --git a/source/rpc_client/cli_netlogon.c b/source/rpc_client/cli_netlogon.c
index cb1d93e..851a4a8 100644
--- a/source/rpc_client/cli_netlogon.c
+++ b/source/rpc_client/cli_netlogon.c
@@ -134,7 +134,7 @@ NTSTATUS rpccli_netlogon_setup_creds(struct rpc_pipe_client *cli,
 	struct dcinfo *dc;
 	bool retried = false;
 
-	SMB_ASSERT(rpccli_is_pipe_idx(cli, PI_NETLOGON));
+	SMB_ASSERT(cli->pipe_idx == PI_NETLOGON);
 
 	dc = cli->dc;
 	if (!dc) {
@@ -159,7 +159,7 @@ NTSTATUS rpccli_netlogon_setup_creds(struct rpc_pipe_client *cli,
 	generate_random_buffer(clnt_chal_send.data, 8);
 
 	/* Get the server challenge. */
-	result = rpccli_netr_ServerReqChallenge(cli, talloc_tos(),
+	result = rpccli_netr_ServerReqChallenge(cli, cli->mem_ctx,
 						dc->remote_machine,
 						clnt_name,
 						&clnt_chal_send,
@@ -180,7 +180,7 @@ NTSTATUS rpccli_netlogon_setup_creds(struct rpc_pipe_client *cli,
 	 * Send client auth-2 challenge and receive server repy.
 	 */
 
-	result = rpccli_netr_ServerAuthenticate2(cli, talloc_tos(),
+	result = rpccli_netr_ServerAuthenticate2(cli, cli->mem_ctx,
 						 dc->remote_machine,
 						 dc->mach_acct,
 						 sec_chan_type,
@@ -212,13 +212,13 @@ NTSTATUS rpccli_netlogon_setup_creds(struct rpc_pipe_client *cli,
 		 */
 		DEBUG(0,("rpccli_netlogon_setup_creds: server %s "
 			"replied with bad credential\n",
-			cli->desthost ));
+			cli->cli->desthost ));
 		return NT_STATUS_ACCESS_DENIED;
 	}
 
 	DEBUG(5,("rpccli_netlogon_setup_creds: server %s credential "
 		"chain established.\n",
-		cli->desthost ));
+		cli->cli->desthost ));
 
 	return NT_STATUS_OK;
 }
diff --git a/source/rpc_client/cli_pipe.c b/source/rpc_client/cli_pipe.c
index 828307c..2a2b547 100644
--- a/source/rpc_client/cli_pipe.c
+++ b/source/rpc_client/cli_pipe.c
@@ -279,7 +279,7 @@ static NTSTATUS cli_pipe_verify_ntlmssp(struct rpc_pipe_client *cli, RPC_HDR *pr
 				DEBUG(0,("cli_pipe_verify_ntlmssp: failed to unseal "
 					"packet from remote machine %s on pipe %s "
 					"fnum 0x%x. Error was %s.\n",
-					cli->desthost,
+					cli->cli->desthost,
 					cli->pipe_name,
 					(unsigned int)cli->fnum,
 					nt_errstr(status) ));
@@ -297,7 +297,7 @@ static NTSTATUS cli_pipe_verify_ntlmssp(struct rpc_pipe_client *cli, RPC_HDR *pr
 				DEBUG(0,("cli_pipe_verify_ntlmssp: check signing failed on "
 					"packet from remote machine %s on pipe %s "
 					"fnum 0x%x. Error was %s.\n",
-					cli->desthost,
+					cli->cli->desthost,
 					cli->pipe_name,
 					(unsigned int)cli->fnum,
 					nt_errstr(status) ));
@@ -373,7 +373,7 @@ static NTSTATUS cli_pipe_verify_schannel(struct rpc_pipe_client *cli, RPC_HDR *p
 			(unsigned int)RPC_HEADER_LEN + RPC_HDR_RESP_LEN + data_len ));
 		return NT_STATUS_BUFFER_TOO_SMALL;
 	}
-
+                                                                                                                             
 	if(!smb_io_rpc_hdr_auth("hdr_auth", &auth_info, current_pdu, 0)) {
 		DEBUG(0,("cli_pipe_verify_schannel: failed to unmarshall RPC_HDR_AUTH.\n"));
 		return NT_STATUS_BUFFER_TOO_SMALL;
@@ -400,7 +400,7 @@ static NTSTATUS cli_pipe_verify_schannel(struct rpc_pipe_client *cli, RPC_HDR *p
 		DEBUG(3,("cli_pipe_verify_schannel: failed to decode PDU "
 				"Connection to remote machine %s "
 				"pipe %s fnum 0x%x.\n",
-				cli->desthost,
+				cli->cli->desthost,
 				cli->pipe_name,
 				(unsigned int)cli->fnum ));
 		return NT_STATUS_INVALID_PARAMETER;
@@ -461,7 +461,7 @@ static NTSTATUS cli_pipe_validate_rpc_response(struct rpc_pipe_client *cli, RPC_
 			if (prhdr->auth_len) {
 				DEBUG(3, ("cli_pipe_validate_rpc_response: Connection to remote machine %s "


-- 
Samba Shared Repository


More information about the samba-cvs mailing list