From ced449b016631347d308643ea1de47a260f4671a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 25 Nov 2005 05:25:37 +0000 Subject: r11889: added support for dcerpc ncacn_np over SMB2. You use it by giving the flag 'smb2' in the dcerpc binding string. This gives a pretty good test to the new SMB2 trans call. (This used to be commit f99bef585d4c1e52becc06b581bd5aaa62cf9dd7) --- source4/librpc/rpc/dcerpc_util.c | 72 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 65 insertions(+), 7 deletions(-) (limited to 'source4/librpc/rpc/dcerpc_util.c') diff --git a/source4/librpc/rpc/dcerpc_util.c b/source4/librpc/rpc/dcerpc_util.c index c3e928b6f1..b21ab38b05 100644 --- a/source4/librpc/rpc/dcerpc_util.c +++ b/source4/librpc/rpc/dcerpc_util.c @@ -201,7 +201,8 @@ static const struct { {"validate", DCERPC_DEBUG_VALIDATE_BOTH}, {"print", DCERPC_DEBUG_PRINT_BOTH}, {"padcheck", DCERPC_DEBUG_PAD_CHECK}, - {"bigendian", DCERPC_PUSH_BIGENDIAN} + {"bigendian", DCERPC_PUSH_BIGENDIAN}, + {"smb2", DCERPC_SMB2} }; const char *epm_floor_string(TALLOC_CTX *mem_ctx, struct epm_floor *epm_floor) @@ -1014,12 +1015,12 @@ NTSTATUS dcerpc_pipe_auth(struct dcerpc_pipe *p, /* open a rpc connection to a rpc pipe on SMB using the binding structure to determine the endpoint and options */ -static NTSTATUS dcerpc_pipe_connect_ncacn_np(TALLOC_CTX *tmp_ctx, - struct dcerpc_pipe *p, - struct dcerpc_binding *binding, - const char *pipe_uuid, - uint32_t pipe_version, - struct cli_credentials *credentials) +static NTSTATUS dcerpc_pipe_connect_ncacn_np_smb(TALLOC_CTX *tmp_ctx, + struct dcerpc_pipe *p, + struct dcerpc_binding *binding, + const char *pipe_uuid, + uint32_t pipe_version, + struct cli_credentials *credentials) { NTSTATUS status; struct smbcli_state *cli; @@ -1056,6 +1057,63 @@ static NTSTATUS dcerpc_pipe_connect_ncacn_np(TALLOC_CTX *tmp_ctx, return NT_STATUS_OK; } +/* open a rpc connection to a rpc pipe on SMB2 using the binding + structure to determine the endpoint and options */ +static NTSTATUS dcerpc_pipe_connect_ncacn_np_smb2(TALLOC_CTX *tmp_ctx, + struct dcerpc_pipe *p, + struct dcerpc_binding *binding, + const char *pipe_uuid, + uint32_t pipe_version, + struct cli_credentials *credentials) +{ + NTSTATUS status; + struct smb2_tree *tree; + const char *pipe_name = NULL; + + if (binding->flags & DCERPC_SCHANNEL) { + credentials = cli_credentials_init(tmp_ctx); + cli_credentials_set_anonymous(credentials); + cli_credentials_guess(credentials); + } + status = smb2_connect(tmp_ctx, binding->host, "IPC$", credentials, &tree, + p->conn->event_ctx); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0,("Failed to connect to %s - %s\n", + binding->host, nt_errstr(status))); + return status; + } + + pipe_name = binding->endpoint; + + status = dcerpc_pipe_open_smb2(p->conn, tree, pipe_name); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0,("Failed to open pipe %s - %s\n", pipe_name, nt_errstr(status))); + return status; + } + + talloc_steal(p->conn, tree); + + return NT_STATUS_OK; +} + + +/* open a rpc connection to a rpc pipe on SMB using the binding + structure to determine the endpoint and options */ +static NTSTATUS dcerpc_pipe_connect_ncacn_np(TALLOC_CTX *tmp_ctx, + struct dcerpc_pipe *p, + struct dcerpc_binding *binding, + const char *pipe_uuid, + uint32_t pipe_version, + struct cli_credentials *credentials) +{ + if (binding->flags & DCERPC_SMB2) { + return dcerpc_pipe_connect_ncacn_np_smb2(tmp_ctx, p, binding, pipe_uuid, + pipe_version, credentials); + } + return dcerpc_pipe_connect_ncacn_np_smb(tmp_ctx, p, binding, pipe_uuid, + pipe_version, credentials); +} + /* open a rpc connection to a rpc pipe on SMP using the binding structure to determine the endpoint and options */ static NTSTATUS dcerpc_pipe_connect_ncalrpc(TALLOC_CTX *tmp_ctx, -- cgit