#include "librpc/ndr/ndr_table.h"
#include "param/param.h"
-NTSTATUS dcerpc_server_remote_init(void);
+NTSTATUS dcerpc_server_remote_init(TALLOC_CTX *ctx);
struct dcesrv_remote_private {
struct dcerpc_pipe *c_pipe;
static NTSTATUS remote_op_bind(struct dcesrv_call_state *dce_call, const struct dcesrv_interface *iface, uint32_t if_version)
{
NTSTATUS status;
- const struct ndr_interface_table *table;
+ const struct ndr_interface_table *table =
+ (const struct ndr_interface_table *)dce_call->context->iface->private_data;
struct dcesrv_remote_private *priv;
const char *binding = lpcfg_parm_string(dce_call->conn->dce_ctx->lp_ctx, NULL, "dcerpc_remote", "binding");
const char *user, *pass, *domain;
struct cli_credentials *credentials;
- bool must_free_credentials = true;
+ bool must_free_credentials = false;
bool machine_account;
struct dcerpc_binding *b;
struct composite_context *pipe_conn_req;
+ uint32_t flags = 0;
machine_account = lpcfg_parm_bool(dce_call->conn->dce_ctx->lp_ctx, NULL, "dcerpc_remote", "use_machine_account", false);
pass = lpcfg_parm_string(dce_call->conn->dce_ctx->lp_ctx, NULL, "dcerpc_remote", "password");
domain = lpcfg_parm_string(dce_call->conn->dce_ctx->lp_ctx, NULL, "dceprc_remote", "domain");
- table = ndr_table_by_uuid(&iface->syntax_id.uuid); /* FIXME: What about if_version ? */
- if (!table) {
- dce_call->fault_code = DCERPC_FAULT_UNK_IF;
- return NT_STATUS_NET_WRITE_FAULT;
- }
+ credentials = dcesrv_call_credentials(dce_call);
if (user && pass) {
DEBUG(5, ("dcerpc_remote: RPC Proxy: Using specified account\n"));
if (!credentials) {
return NT_STATUS_NO_MEMORY;
}
+ must_free_credentials = true;
cli_credentials_set_conf(credentials, dce_call->conn->dce_ctx->lp_ctx);
cli_credentials_set_username(credentials, user, CRED_SPECIFIED);
if (domain) {
} else if (machine_account) {
DEBUG(5, ("dcerpc_remote: RPC Proxy: Using machine account\n"));
credentials = cli_credentials_init(priv);
+ if (!credentials) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ must_free_credentials = true;
cli_credentials_set_conf(credentials, dce_call->conn->dce_ctx->lp_ctx);
if (domain) {
cli_credentials_set_domain(credentials, domain, CRED_SPECIFIED);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
- } else if (dce_call->conn->auth_state.session_info->credentials) {
+ } else if (credentials != NULL) {
DEBUG(5, ("dcerpc_remote: RPC Proxy: Using delegated credentials\n"));
- credentials = dce_call->conn->auth_state.session_info->credentials;
- must_free_credentials = false;
} else {
DEBUG(1,("dcerpc_remote: RPC Proxy: You must supply binding, user and password or have delegated credentials\n"));
return NT_STATUS_INVALID_PARAMETER;
DEBUG(0, ("Failed to parse dcerpc binding '%s'\n", binding));
return status;
}
-
- DEBUG(3, ("Using binding %s\n", dcerpc_binding_string(dce_call->context, b)));
-
+
/* If we already have a remote association group ID, then use that */
- if (dce_call->context->assoc_group->proxied_id != 0) {
- b->assoc_group_id = dce_call->context->assoc_group->proxied_id;
+ if (dce_call->conn->assoc_group->proxied_id != 0) {
+ status = dcerpc_binding_set_assoc_group_id(b,
+ dce_call->conn->assoc_group->proxied_id);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("dcerpc_binding_set_assoc_group_id() - %s'\n",
+ nt_errstr(status)));
+ return status;
+ }
+ }
+
+ status = dcerpc_binding_set_abstract_syntax(b, &table->syntax_id);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("dcerpc_binding_set_abstract_syntax() - %s'\n",
+ nt_errstr(status)));
+ return status;
}
- b->object.if_version = if_version;
+ if (dce_call->pkt.pfc_flags & DCERPC_PFC_FLAG_CONC_MPX) {
+ status = dcerpc_binding_set_flags(b, DCERPC_CONCURRENT_MULTIPLEX, 0);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("dcerpc_binding_set_flags(CONC_MPX) - %s'\n",
+ nt_errstr(status)));
+ return status;
+ }
+ }
+
+ DEBUG(3, ("Using binding %s\n", dcerpc_binding_string(dce_call->context, b)));
pipe_conn_req = dcerpc_pipe_connect_b_send(dce_call->context, b, table,
credentials, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx);
return status;
}
- if (dce_call->context->assoc_group->proxied_id == 0) {
- dce_call->context->assoc_group->proxied_id =
+ flags = dcerpc_binding_get_flags(priv->c_pipe->binding);
+ if (!(flags & DCERPC_CONCURRENT_MULTIPLEX)) {
+ dce_call->state_flags &= ~DCESRV_CALL_STATE_FLAG_MULTIPLEXED;
+ }
+
+ if (dce_call->conn->assoc_group->proxied_id == 0) {
+ dce_call->conn->assoc_group->proxied_id =
dcerpc_binding_get_assoc_group_id(priv->c_pipe->binding);
}
return NT_STATUS_OK;
}
+static NTSTATUS remote_get_private(struct dcesrv_call_state *dce_call,
+ struct dcesrv_remote_private **_priv)
+{
+ void *ptr = NULL;
+ struct dcesrv_remote_private *priv = NULL;
+
+ ptr = dce_call->context->private_data;
+ priv = talloc_get_type_abort(ptr, struct dcesrv_remote_private);
+
+ *_priv = priv;
+ return NT_STATUS_OK;
+}
+
static NTSTATUS remote_op_ndr_pull(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_pull *pull, void **r)
{
enum ndr_err_code ndr_err;
static NTSTATUS remote_op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
{
- struct dcesrv_remote_private *priv = talloc_get_type_abort(dce_call->context->private_data,
- struct dcesrv_remote_private);
+ struct dcesrv_remote_private *priv = NULL;
uint16_t opnum = dce_call->pkt.u.request.opnum;
const struct ndr_interface_table *table = dce_call->context->iface->private_data;
const struct ndr_interface_call *call;
const char *name;
struct tevent_req *subreq;
+ NTSTATUS status;
+
+ status = remote_get_private(dce_call, &priv);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
name = table->calls[opnum].name;
call = &table->calls[opnum];
iface->ndr_push = remote_op_ndr_push;
iface->private_data = if_tabl;
+ iface->flags = 0;
return true;
}
return false;
}
-NTSTATUS dcerpc_server_remote_init(void)
+NTSTATUS dcerpc_server_remote_init(TALLOC_CTX *ctx)
{
NTSTATUS ret;
- struct dcesrv_endpoint_server ep_server;
-
- ZERO_STRUCT(ep_server);
-
- /* fill in our name */
- ep_server.name = "remote";
+ static const struct dcesrv_endpoint_server ep_server = {
+ /* fill in our name */
+ .name = "remote",
- /* fill in all the operations */
- ep_server.init_server = remote_op_init_server;
+ /* fill in all the operations */
+ .init_server = remote_op_init_server,
- ep_server.interface_by_uuid = remote_op_interface_by_uuid;
- ep_server.interface_by_name = remote_op_interface_by_name;
+ .interface_by_uuid = remote_op_interface_by_uuid,
+ .interface_by_name = remote_op_interface_by_name
+ };
/* register ourselves with the DCERPC subsystem. */
ret = dcerpc_register_ep_server(&ep_server);