Changeset 745 for trunk/server/source4/rpc_server/remote
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/source4/rpc_server/remote/dcesrv_remote.c
r414 r745 4 4 5 5 Copyright (C) Stefan (metze) Metzmacher 2004 6 6 Copyright (C) Julien Kerihuel 2008-2009 7 Copyright (C) Andrew Bartlett <abartlet@samba.org> 2010 8 7 9 This program is free software; you can redistribute it and/or modify 8 10 it under the terms of the GNU General Public License as published by … … 20 22 21 23 #include "includes.h" 24 #include <tevent.h> 22 25 #include "rpc_server/dcerpc_server.h" 23 26 #include "auth/auth.h" … … 36 39 } 37 40 38 static NTSTATUS remote_op_bind(struct dcesrv_call_state *dce_call, const struct dcesrv_interface *iface )41 static NTSTATUS remote_op_bind(struct dcesrv_call_state *dce_call, const struct dcesrv_interface *iface, uint32_t if_version) 39 42 { 40 43 NTSTATUS status; 41 44 const struct ndr_interface_table *table; 42 45 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"); 44 47 const char *user, *pass, *domain; 45 48 struct cli_credentials *credentials; 49 bool must_free_credentials = true; 46 50 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); 49 55 50 56 priv = talloc(dce_call->conn, struct dcesrv_remote_private); … … 61 67 } 62 68 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"); 66 72 67 73 table = ndr_table_by_uuid(&iface->syntax_id.uuid); /* FIXME: What about if_version ? */ … … 97 103 DEBUG(5, ("dcerpc_remote: RPC Proxy: Using delegated credentials\n")); 98 104 credentials = dce_call->conn->auth_state.session_info->credentials; 105 must_free_credentials = false; 99 106 } else { 100 107 DEBUG(1,("dcerpc_remote: RPC Proxy: You must supply binding, user and password or have delegated credentials\n")); … … 102 109 } 103 110 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 110 135 if (!NT_STATUS_IS_OK(status)) { 111 136 return status; 112 137 } 113 138 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 114 147 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;124 148 } 125 149 … … 155 179 } 156 180 181 static void remote_op_dispatch_done(struct tevent_req *subreq); 182 157 183 static NTSTATUS remote_op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r) 158 184 { 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); 160 187 uint16_t opnum = dce_call->pkt.u.request.opnum; 161 188 const struct ndr_interface_table *table = dce_call->context->iface->private_data; 162 189 const struct ndr_interface_call *call; 163 190 const char *name; 191 struct tevent_req *subreq; 164 192 165 193 name = table->calls[opnum].name; … … 173 201 174 202 /* 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 217 static 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); 176 235 177 236 dce_call->fault_code = priv->c_pipe->last_fault_code; 178 237 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) && 184 244 (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 248 reply: 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 } 189 254 } 190 255 … … 207 272 static NTSTATUS remote_register_one_iface(struct dcesrv_context *dce_ctx, const struct dcesrv_interface *iface) 208 273 { 209 int i;274 unsigned int i; 210 275 const struct ndr_interface_table *table = iface->private_data; 211 276 … … 226 291 static NTSTATUS remote_op_init_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server) 227 292 { 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); 230 295 231 296 if (!ifaces) { … … 262 327 263 328 iface->bind = remote_op_bind; 264 iface->unbind = remote_op_unbind;329 iface->unbind = NULL; 265 330 266 331 iface->ndr_pull = remote_op_ndr_pull;
Note:
See TracChangeset
for help on using the changeset viewer.