1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-27 14:04:05 +03:00

Actually connect to RPC.

(This used to be commit 3082534454ff936ac0b78b5a2c72c9b060e21244)
This commit is contained in:
Jelmer Vernooij 2008-04-15 18:24:11 +02:00
parent 3db2249886
commit e3246e8720
3 changed files with 50 additions and 5 deletions

View File

@ -74,7 +74,7 @@ NTSTATUS dcerpc_ndr_request_recv(struct rpc_request *req)
prs_init_empty( &r_ps, req, UNMARSHALL );
status = rpc_api_pipe_req(req->pipe->cli, req->opnum, &req->q_ps, &r_ps);
status = rpc_api_pipe_req(req->pipe->rpc_cli, req->opnum, &req->q_ps, &r_ps);
prs_mem_free( &req->q_ps );
@ -104,8 +104,6 @@ NTSTATUS dcerpc_ndr_request_recv(struct rpc_request *req)
return ndr_map_error2ntstatus(ndr_err);
}
return NT_STATUS_NOT_IMPLEMENTED;
}
@ -117,14 +115,23 @@ _PUBLIC_ NTSTATUS dcerpc_pipe_connect(TALLOC_CTX *parent_ctx, struct dcerpc_pipe
struct dcerpc_pipe *p = talloc(parent_ctx, struct dcerpc_pipe);
struct dcerpc_binding *binding;
NTSTATUS nt_status;
int idx;
RPC_IFACE iface_syntax;
nt_status = dcerpc_parse_binding(p, binding_string, &binding);
if (NT_STATUS_IS_ERR(nt_status)) {
DEBUG(1, ("Unable to parse binding string '%s'", binding));
DEBUG(1, ("Unable to parse binding string '%s'", binding_string));
talloc_free(p);
return nt_status;
}
if (binding->transport != NCACN_NP) {
DEBUG(0, ("Only ncacn_np supported"));
talloc_free(p);
return NT_STATUS_NOT_SUPPORTED;
}
/* FIXME: Actually use loadparm_context.. */
/* FIXME: actually use credentials */
@ -138,6 +145,28 @@ _PUBLIC_ NTSTATUS dcerpc_pipe_connect(TALLOC_CTX *parent_ctx, struct dcerpc_pipe
get_cmdline_auth_info_use_kerberos() ? CLI_FULL_CONNECTION_USE_KERBEROS : 0,
get_cmdline_auth_info_signing_state(), NULL);
if (NT_STATUS_IS_ERR(nt_status)) {
talloc_free(p);
return nt_status;
}
iface_syntax.uuid = table->syntax_id.uuid;
iface_syntax.version = table->syntax_id.if_version;
idx = cli_get_pipe_idx(&iface_syntax);
if (idx < 0) {
DEBUG(0, ("Unable to find interface index"));
talloc_free(p);
return NT_STATUS_OBJECT_PATH_INVALID;
}
p->rpc_cli = cli_rpc_pipe_open_noauth(p->cli, idx, &nt_status);
if (p->rpc_cli == NULL) {
talloc_free(p);
return nt_status;
}
p->table = table;
*pp = p;

View File

@ -35,7 +35,8 @@ struct cli_credentials;
struct dcerpc_pipe {
const struct ndr_interface_table *table;
struct rpc_pipe_client *cli;
struct cli_state *cli;
struct rpc_pipe_client *rpc_cli;
};
struct rpc_request {

View File

@ -234,6 +234,21 @@ const char *cli_get_pipe_name(int pipe_idx)
return &pipe_names[pipe_idx].client_pipe[5];
}
/****************************************************************************
Return the pipe idx from the syntax.
****************************************************************************/
int cli_get_pipe_idx(const RPC_IFACE *syntax)
{
int i;
for (i = 0; pipe_names[i].client_pipe; i++) {
if (GUID_equal(&pipe_names[i].abstr_syntax.uuid, &syntax->uuid) &&
pipe_names[i].abstr_syntax.version == syntax->version)
return i;
}
return -1;
}
/*******************************************************************
Inits an RPC_HDR structure.
********************************************************************/