diff options
author | Andrew Bartlett <abartlet@samba.org> | 2005-03-19 08:34:43 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:11:07 -0500 |
commit | df643022136a4b229aca817f5b57f7302a97f852 (patch) | |
tree | e2a2b5b20b5b3c580fd899a4f39a7911ac5ea250 /source4/lib | |
parent | 4037a7e80c3e5d9560b084d9925896d2a5a9518c (diff) | |
download | samba-df643022136a4b229aca817f5b57f7302a97f852.tar.gz samba-df643022136a4b229aca817f5b57f7302a97f852.tar.bz2 samba-df643022136a4b229aca817f5b57f7302a97f852.zip |
r5902: A rather large change...
I wanted to add a simple 'workstation' argument to the DCERPC
authenticated binding calls, but this patch kind of grew from there.
With SCHANNEL, the 'workstation' name (the netbios name of the client)
matters, as this is what ties the session between the NETLOGON ops and
the SCHANNEL bind. This changes a lot of files, and these will again
be changed when jelmer does the credentials work.
I also correct some schannel IDL to distinguish between workstation
names and account names. The distinction matters for domain trust
accounts.
Issues in handling this (issues with lifetime of talloc pointers)
caused me to change the 'creds_CredentialsState' and 'struct
dcerpc_binding' pointers to always be talloc()ed pointers.
In the schannel DB, we now store both the domain and computername, and
query on both. This should ensure we fault correctly when the domain
is specified incorrectly in the SCHANNEL bind.
In the RPC-SCHANNEL test, I finally fixed a bug that vl pointed out,
where the comment claimed we re-used a connection, but in fact we made
a new connection.
This was achived by breaking apart some of the
dcerpc_secondary_connection() logic.
The addition of workstation handling was also propogated to NTLMSSP
and GENSEC, for completeness.
The RPC-SAMSYNC test has been cleaned up a little, using a loop over
usernames/passwords rather than manually expanded tests. This will be
expanded further (the code in #if 0 in this patch) to use a newly
created user account for testing.
In making this test pass test_rpc.sh, I found a bug in the RPC-ECHO
server, caused by the removal of [ref] and the assoicated pointer from
the IDL. This has been re-added, until the underlying pidl issues are
solved.
(This used to be commit 824289dcc20908ddec957a4a892a103eec2da9b9)
Diffstat (limited to 'source4/lib')
-rw-r--r-- | source4/lib/com/dcom/main.c | 69 | ||||
-rw-r--r-- | source4/lib/registry/reg_backend_rpc.c | 1 |
2 files changed, 41 insertions, 29 deletions
diff --git a/source4/lib/com/dcom/main.c b/source4/lib/com/dcom/main.c index 4d9c635be8..d3d44edc71 100644 --- a/source4/lib/com/dcom/main.c +++ b/source4/lib/com/dcom/main.c @@ -40,11 +40,15 @@ struct dcom_client_context *dcom_client_init(struct com_context *ctx, const char return ctx->dcom; } -static NTSTATUS dcerpc_binding_from_STRINGBINDING(TALLOC_CTX *mem_ctx, struct dcerpc_binding *b, struct STRINGBINDING *bd) +static NTSTATUS dcerpc_binding_from_STRINGBINDING(TALLOC_CTX *mem_ctx, struct dcerpc_binding **b_out, struct STRINGBINDING *bd) { char *host, *endpoint; + struct dcerpc_binding *b; - ZERO_STRUCTP(b); + b = talloc_zero(mem_ctx, struct dcerpc_binding); + if (!b) { + return NT_STATUS_NO_MEMORY; + } b->transport = dcerpc_transport_by_endpoint_protocol(bd->wTowerId); @@ -53,7 +57,7 @@ static NTSTATUS dcerpc_binding_from_STRINGBINDING(TALLOC_CTX *mem_ctx, struct dc return NT_STATUS_NOT_SUPPORTED; } - host = talloc_strdup(mem_ctx, bd->NetworkAddr); + host = talloc_strdup(b, bd->NetworkAddr); endpoint = strchr(host, '['); if (endpoint) { @@ -64,56 +68,61 @@ static NTSTATUS dcerpc_binding_from_STRINGBINDING(TALLOC_CTX *mem_ctx, struct dc } b->host = host; - b->endpoint = endpoint; + b->endpoint = talloc_strdup(b, endpoint); + *b_out = b; return NT_STATUS_OK; } static NTSTATUS dcom_connect_host(struct com_context *ctx, struct dcerpc_pipe **p, const char *server) { - struct dcerpc_binding bd; - enum dcerpc_transport_t available_transports[] = { NCACN_IP_TCP, NCACN_NP }; + struct dcerpc_binding *bd; + const char * available_transports[] = { "ncacn_ip_tcp", "ncacn_np" }; int i; NTSTATUS status; TALLOC_CTX *mem_ctx = talloc_init("dcom_connect"); if (server == NULL) { - bd.transport = NCALRPC; - return dcerpc_pipe_connect_b(p, &bd, - DCERPC_IREMOTEACTIVATION_UUID, - DCERPC_IREMOTEACTIVATION_VERSION, - ctx->dcom->domain, ctx->dcom->user, ctx->dcom->password); + return dcerpc_pipe_connect(p, "ncalrpc", + DCERPC_IREMOTEACTIVATION_UUID, + DCERPC_IREMOTEACTIVATION_VERSION, + lp_netbios_name(), + ctx->dcom->domain, ctx->dcom->user, ctx->dcom->password); } /* Allow server name to contain a binding string */ if (NT_STATUS_IS_OK(dcerpc_parse_binding(mem_ctx, server, &bd))) { - status = dcerpc_pipe_connect_b(p, &bd, - DCERPC_IREMOTEACTIVATION_UUID, - DCERPC_IREMOTEACTIVATION_VERSION, - ctx->dcom->domain, ctx->dcom->user, ctx->dcom->password); + status = dcerpc_pipe_connect_b(p, bd, + DCERPC_IREMOTEACTIVATION_UUID, + DCERPC_IREMOTEACTIVATION_VERSION, + lp_netbios_name(), + ctx->dcom->domain, ctx->dcom->user, ctx->dcom->password); talloc_free(mem_ctx); return status; } - talloc_free(mem_ctx); - ZERO_STRUCT(bd); - bd.host = server; - for (i = 0; i < ARRAY_SIZE(available_transports); i++) { - bd.transport = available_transports[i]; + char *binding = talloc_asprintf(mem_ctx, "%s:%s", available_transports[i], server); + if (!binding) { + talloc_free(mem_ctx); + return NT_STATUS_NO_MEMORY; + } - status = dcerpc_pipe_connect_b(p, &bd, - DCERPC_IREMOTEACTIVATION_UUID, - DCERPC_IREMOTEACTIVATION_VERSION, - ctx->dcom->domain, ctx->dcom->user, ctx->dcom->password); + status = dcerpc_pipe_connect(p, binding, + DCERPC_IREMOTEACTIVATION_UUID, + DCERPC_IREMOTEACTIVATION_VERSION, + lp_netbios_name(), + ctx->dcom->domain, ctx->dcom->user, ctx->dcom->password); if (NT_STATUS_IS_OK(status)) { + talloc_free(mem_ctx); return status; } } + talloc_free(mem_ctx); return status; } @@ -254,7 +263,7 @@ WERROR dcom_get_class_object(struct com_context *ctx, struct GUID *clsid, const NTSTATUS dcom_get_pipe (struct IUnknown *iface, struct dcerpc_pipe **pp) { - struct dcerpc_binding binding; + struct dcerpc_binding *binding; struct GUID iid; uint64_t oxid; NTSTATUS status; @@ -297,14 +306,16 @@ NTSTATUS dcom_get_pipe (struct IUnknown *iface, struct dcerpc_pipe **pp) if (!NT_STATUS_IS_OK(status)) { DEBUG(1, ("Error parsing string binding")); } else { - status = dcerpc_pipe_connect_b(&p, &binding, + status = dcerpc_pipe_connect_b(&p, binding, uuid, 0.0, - iface->ctx->dcom->domain, iface->ctx->dcom->user, + lp_netbios_name(), + iface->ctx->dcom->domain, + iface->ctx->dcom->user, iface->ctx->dcom->password); } - + talloc_free(binding); i++; - } while (NT_STATUS_IS_ERR(status) && ox->bindings.stringbindings[i]); + } while (!NT_STATUS_IS_OK(status) && ox->bindings.stringbindings[i]); if (NT_STATUS_IS_ERR(status)) { DEBUG(0, ("Unable to connect to remote host - %s\n", nt_errstr(status))); diff --git a/source4/lib/registry/reg_backend_rpc.c b/source4/lib/registry/reg_backend_rpc.c index 2302416554..4a285262c6 100644 --- a/source4/lib/registry/reg_backend_rpc.c +++ b/source4/lib/registry/reg_backend_rpc.c @@ -384,6 +384,7 @@ WERROR reg_open_remote (struct registry_context **ctx, const char *user, const c status = dcerpc_pipe_connect(&p, location, DCERPC_WINREG_UUID, DCERPC_WINREG_VERSION, + lp_netbios_name(), lp_workgroup(), user, pass); (*ctx)->backend_data = p; |