[Patch] rpcclient: allow -U'OTHERDOMAIN\user' again
Stefan Metzmacher
metze at samba.org
Tue Apr 4 14:11:37 UTC 2017
Hi,
here's a fix for
https://bugzilla.samba.org/show_bug.cgi?id=12731
Currently rpcclient -U'OTHERDOMAIN\user' silently becomes
-U$WORKGROUP\user.
I found this while writing tests for
https://bugzilla.samba.org/show_bug.cgi?id=12709.
Please review and push:-)
Thanks!
metze
-------------- next part --------------
From 6c0b63dca58cdfc024deeb8e994d4dbe803355dc Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Mon, 3 Apr 2017 00:19:40 +0200
Subject: [PATCH] rpcclient: allow -U'OTHERDOMAIN\user' again
I guess the primary reason for forcing lp_workgroup()
was the usage of -U% together with schannel,
see source3/script/tests/test_rpcclient_samlogon.sh
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12731
Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
source3/rpcclient/rpcclient.c | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)
diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c
index 9faf01b..6c85165 100644
--- a/source3/rpcclient/rpcclient.c
+++ b/source3/rpcclient/rpcclient.c
@@ -53,6 +53,7 @@ struct messaging_context *rpcclient_msg_ctx;
struct user_auth_info *rpcclient_auth_info;
struct cli_state *rpcclient_cli_state;
struct netlogon_creds_cli_context *rpcclient_netlogon_creds;
+static const char *rpcclient_netlogon_domain;
/* List to hold groups of commands.
*
@@ -764,7 +765,7 @@ static NTSTATUS do_cmd(struct cli_state *cli,
cli, rpcclient_msg_ctx,
cmd_entry->table,
default_transport,
- get_cmdline_auth_info_domain(auth_info),
+ rpcclient_netlogon_domain,
&cmd_entry->rpc_pipe,
talloc_autofree_context(),
&rpcclient_netlogon_creds);
@@ -787,7 +788,7 @@ static NTSTATUS do_cmd(struct cli_state *cli,
if (rpcclient_netlogon_creds == NULL && cmd_entry->use_netlogon_creds) {
const char *dc_name = cmd_entry->rpc_pipe->desthost;
- const char *domain = get_cmdline_auth_info_domain(auth_info);
+ const char *domain = rpcclient_netlogon_domain;
struct cli_credentials *creds = NULL;
ntresult = pdb_get_trust_credentials(domain, NULL,
@@ -946,7 +947,6 @@ out_free:
enum dcerpc_transport_t transport;
uint32_t bflags = 0;
const char *binding_string = NULL;
- char *user, *domain, *q;
const char *host;
int signing_state = SMB_SIGNING_IPC_DEFAULT;
@@ -1141,16 +1141,11 @@ out_free:
flags |= CLI_FULL_CONNECTION_USE_NT_HASH;
}
- user = talloc_strdup(frame, get_cmdline_auth_info_username(rpcclient_auth_info));
- SMB_ASSERT(user != NULL);
- domain = talloc_strdup(frame, lp_workgroup());
- SMB_ASSERT(domain != NULL);
- set_cmdline_auth_info_domain(rpcclient_auth_info, domain);
-
- if ((q = strchr_m(user,'\\'))) {
- *q = 0;
- set_cmdline_auth_info_domain(rpcclient_auth_info, user);
- set_cmdline_auth_info_username(rpcclient_auth_info, q+1);
+ rpcclient_netlogon_domain = get_cmdline_auth_info_domain(rpcclient_auth_info);
+ if (rpcclient_netlogon_domain == NULL ||
+ rpcclient_netlogon_domain[0] == '\0')
+ {
+ rpcclient_netlogon_domain = lp_workgroup();
}
nt_status = cli_full_connection(&cli, lp_netbios_name(), host,
--
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/20170404/45e0d50c/signature.sig>
More information about the samba-technical
mailing list