Ignore:
Timestamp:
Nov 27, 2012, 4:43:17 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.0

Location:
trunk/server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/source4/rpc_server/remote/dcesrv_remote.c

    r414 r745  
    44
    55   Copyright (C) Stefan (metze) Metzmacher 2004
    6    
     6   Copyright (C) Julien Kerihuel 2008-2009
     7   Copyright (C) Andrew Bartlett <abartlet@samba.org> 2010
     8
    79   This program is free software; you can redistribute it and/or modify
    810   it under the terms of the GNU General Public License as published by
     
    2022
    2123#include "includes.h"
     24#include <tevent.h>
    2225#include "rpc_server/dcerpc_server.h"
    2326#include "auth/auth.h"
     
    3639}
    3740
    38 static NTSTATUS remote_op_bind(struct dcesrv_call_state *dce_call, const struct dcesrv_interface *iface)
     41static NTSTATUS remote_op_bind(struct dcesrv_call_state *dce_call, const struct dcesrv_interface *iface, uint32_t if_version)
    3942{
    4043        NTSTATUS status;
    4144        const struct ndr_interface_table *table;
    4245        struct dcesrv_remote_private *priv;
    43         const char *binding = lp_parm_string(dce_call->conn->dce_ctx->lp_ctx, NULL, "dcerpc_remote", "binding");
     46        const char *binding = lpcfg_parm_string(dce_call->conn->dce_ctx->lp_ctx, NULL, "dcerpc_remote", "binding");
    4447        const char *user, *pass, *domain;
    4548        struct cli_credentials *credentials;
     49        bool must_free_credentials = true;
    4650        bool machine_account;
    47 
    48         machine_account = lp_parm_bool(dce_call->conn->dce_ctx->lp_ctx, NULL, "dcerpc_remote", "use_machine_account", false);
     51        struct dcerpc_binding           *b;
     52        struct composite_context        *pipe_conn_req;
     53
     54        machine_account = lpcfg_parm_bool(dce_call->conn->dce_ctx->lp_ctx, NULL, "dcerpc_remote", "use_machine_account", false);
    4955
    5056        priv = talloc(dce_call->conn, struct dcesrv_remote_private);
     
    6167        }
    6268
    63         user = lp_parm_string(dce_call->conn->dce_ctx->lp_ctx, NULL, "dcerpc_remote", "user");
    64         pass = lp_parm_string(dce_call->conn->dce_ctx->lp_ctx, NULL, "dcerpc_remote", "password");
    65         domain = lp_parm_string(dce_call->conn->dce_ctx->lp_ctx, NULL, "dceprc_remote", "domain");
     69        user = lpcfg_parm_string(dce_call->conn->dce_ctx->lp_ctx, NULL, "dcerpc_remote", "user");
     70        pass = lpcfg_parm_string(dce_call->conn->dce_ctx->lp_ctx, NULL, "dcerpc_remote", "password");
     71        domain = lpcfg_parm_string(dce_call->conn->dce_ctx->lp_ctx, NULL, "dceprc_remote", "domain");
    6672
    6773        table = ndr_table_by_uuid(&iface->syntax_id.uuid); /* FIXME: What about if_version ? */
     
    97103                DEBUG(5, ("dcerpc_remote: RPC Proxy: Using delegated credentials\n"));
    98104                credentials = dce_call->conn->auth_state.session_info->credentials;
     105                must_free_credentials = false;
    99106        } else {
    100107                DEBUG(1,("dcerpc_remote: RPC Proxy: You must supply binding, user and password or have delegated credentials\n"));
     
    102109        }
    103110
    104         status = dcerpc_pipe_connect(priv,
    105                                      &(priv->c_pipe), binding, table,
    106                                      credentials, dce_call->event_ctx,
    107                                      dce_call->conn->dce_ctx->lp_ctx);
    108 
    109         talloc_free(credentials);
     111        /* parse binding string to the structure */
     112        status = dcerpc_parse_binding(dce_call->context, binding, &b);
     113        if (!NT_STATUS_IS_OK(status)) {
     114                DEBUG(0, ("Failed to parse dcerpc binding '%s'\n", binding));
     115                return status;
     116        }
     117       
     118        DEBUG(3, ("Using binding %s\n", dcerpc_binding_string(dce_call->context, b)));
     119       
     120        /* If we already have a remote association group ID, then use that */
     121        if (dce_call->context->assoc_group->proxied_id != 0) {
     122                b->assoc_group_id = dce_call->context->assoc_group->proxied_id;
     123        }
     124
     125        b->object.if_version = if_version;
     126
     127        pipe_conn_req = dcerpc_pipe_connect_b_send(dce_call->context, b, table,
     128                                                   credentials, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx);
     129        status = dcerpc_pipe_connect_b_recv(pipe_conn_req, dce_call->context, &(priv->c_pipe));
     130       
     131        if (must_free_credentials) {
     132                talloc_free(credentials);
     133        }
     134
    110135        if (!NT_STATUS_IS_OK(status)) {
    111136                return status;
    112137        }
    113138
     139        if (dce_call->context->assoc_group->proxied_id == 0) {
     140                dce_call->context->assoc_group->proxied_id = priv->c_pipe->assoc_group_id;
     141        }
     142
     143        if (!NT_STATUS_IS_OK(status)) {
     144                return status;
     145        }
     146
    114147        return NT_STATUS_OK;   
    115 }
    116 
    117 static void remote_op_unbind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface)
    118 {
    119         struct dcesrv_remote_private *priv = (struct dcesrv_remote_private *)context->private_data;
    120 
    121         talloc_free(priv->c_pipe);
    122 
    123         return;
    124148}
    125149
     
    155179}
    156180
     181static void remote_op_dispatch_done(struct tevent_req *subreq);
     182
    157183static NTSTATUS remote_op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
    158184{
    159         struct dcesrv_remote_private *priv = dce_call->context->private_data;
     185        struct dcesrv_remote_private *priv = talloc_get_type_abort(dce_call->context->private_data,
     186                                                                   struct dcesrv_remote_private);
    160187        uint16_t opnum = dce_call->pkt.u.request.opnum;
    161188        const struct ndr_interface_table *table = dce_call->context->iface->private_data;
    162189        const struct ndr_interface_call *call;
    163190        const char *name;
     191        struct tevent_req *subreq;
    164192
    165193        name = table->calls[opnum].name;
     
    173201
    174202        /* we didn't use the return code of this function as we only check the last_fault_code */
    175         dcerpc_ndr_request(priv->c_pipe, NULL, table, opnum, mem_ctx,r);
     203        subreq = dcerpc_binding_handle_call_send(dce_call, dce_call->event_ctx,
     204                                                 priv->c_pipe->binding_handle,
     205                                                 NULL, table,
     206                                                 opnum, mem_ctx, r);
     207        if (subreq == NULL) {
     208                DEBUG(0,("dcesrv_remote: call[%s] dcerpc_binding_handle_call_send() failed!\n", name));
     209                return NT_STATUS_NO_MEMORY;
     210        }
     211        tevent_req_set_callback(subreq, remote_op_dispatch_done, dce_call);
     212
     213        dce_call->state_flags |= DCESRV_CALL_STATE_FLAG_ASYNC;
     214        return NT_STATUS_OK;
     215}
     216
     217static void remote_op_dispatch_done(struct tevent_req *subreq)
     218{
     219        struct dcesrv_call_state *dce_call = tevent_req_callback_data(subreq,
     220                                             struct dcesrv_call_state);
     221        struct dcesrv_remote_private *priv = talloc_get_type_abort(dce_call->context->private_data,
     222                                                                   struct dcesrv_remote_private);
     223        uint16_t opnum = dce_call->pkt.u.request.opnum;
     224        const struct ndr_interface_table *table = dce_call->context->iface->private_data;
     225        const struct ndr_interface_call *call;
     226        const char *name;
     227        NTSTATUS status;
     228
     229        name = table->calls[opnum].name;
     230        call = &table->calls[opnum];
     231
     232        /* we didn't use the return code of this function as we only check the last_fault_code */
     233        status = dcerpc_binding_handle_call_recv(subreq);
     234        TALLOC_FREE(subreq);
    176235
    177236        dce_call->fault_code = priv->c_pipe->last_fault_code;
    178237        if (dce_call->fault_code != 0) {
    179                 DEBUG(0,("dcesrv_remote: call[%s] failed with: %s!\n",name, dcerpc_errstr(mem_ctx, dce_call->fault_code)));
    180                 return NT_STATUS_NET_WRITE_FAULT;
    181         }
    182 
    183         if ((dce_call->fault_code == 0) &&
     238                DEBUG(0,("dcesrv_remote: call[%s] failed with: %s!\n",
     239                        name, dcerpc_errstr(dce_call, dce_call->fault_code)));
     240                goto reply;
     241        }
     242
     243        if (NT_STATUS_IS_OK(status) &&
    184244            (priv->c_pipe->conn->flags & DCERPC_DEBUG_PRINT_OUT)) {
    185                 ndr_print_function_debug(call->ndr_print, name, NDR_OUT, r);           
    186         }
    187 
    188         return NT_STATUS_OK;
     245                ndr_print_function_debug(call->ndr_print, name, NDR_OUT, dce_call->r);
     246        }
     247
     248reply:
     249        status = dcesrv_reply(dce_call);
     250        if (!NT_STATUS_IS_OK(status)) {
     251                DEBUG(0,("dcesrv_remote: call[%s]: dcesrv_reply() failed - %s\n",
     252                        name, nt_errstr(status)));
     253        }
    189254}
    190255
     
    207272static NTSTATUS remote_register_one_iface(struct dcesrv_context *dce_ctx, const struct dcesrv_interface *iface)
    208273{
    209         int i;
     274        unsigned int i;
    210275        const struct ndr_interface_table *table = iface->private_data;
    211276
     
    226291static NTSTATUS remote_op_init_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server)
    227292{
    228         int i;
    229         const char **ifaces = (const char **)str_list_make(dce_ctx, lp_parm_string(dce_ctx->lp_ctx, NULL, "dcerpc_remote", "interfaces"),NULL);
     293        unsigned int i;
     294        const char **ifaces = (const char **)str_list_make(dce_ctx, lpcfg_parm_string(dce_ctx->lp_ctx, NULL, "dcerpc_remote", "interfaces"),NULL);
    230295
    231296        if (!ifaces) {
     
    262327       
    263328        iface->bind = remote_op_bind;
    264         iface->unbind = remote_op_unbind;
     329        iface->unbind = NULL;
    265330
    266331        iface->ndr_pull = remote_op_ndr_pull;
Note: See TracChangeset for help on using the changeset viewer.