struct pipes_struct *make_internal_rpc_pipe_p(TALLOC_CTX *mem_ctx, const struct ndr_syntax_id *syntax, const struct tsocket_address *remote_address, const struct auth_session_info *session_info, struct messaging_context *msg_ctx) { struct pipes_struct *p; struct pipe_rpc_fns *context_fns; const char *pipe_name; int ret; pipe_name = get_pipe_name_from_syntax(talloc_tos(), syntax); DEBUG(4,("Create pipe requested %s\n", pipe_name)); ret = make_base_pipes_struct(mem_ctx, msg_ctx, pipe_name, NCALRPC, RPC_LITTLE_ENDIAN, false, remote_address, NULL, &p); if (ret) { DEBUG(0,("ERROR! no memory for pipes_struct!\n")); return NULL; } if (!init_pipe_handles(p, syntax)) { DEBUG(0,("open_rpc_pipe_p: init_pipe_handles failed.\n")); TALLOC_FREE(p); return NULL; } p->session_info = copy_session_info(p, session_info); if (p->session_info == NULL) { DEBUG(0, ("open_rpc_pipe_p: copy_serverinfo failed\n")); close_policy_by_pipe(p); TALLOC_FREE(p); return NULL; } context_fns = talloc(p, struct pipe_rpc_fns); if (context_fns == NULL) { DEBUG(0,("talloc() failed!\n")); TALLOC_FREE(p); return NULL; } context_fns->next = context_fns->prev = NULL; context_fns->n_cmds = rpc_srv_get_pipe_num_cmds(syntax); context_fns->cmds = rpc_srv_get_pipe_cmds(syntax); context_fns->context_id = 0; context_fns->syntax = *syntax; /* add to the list of open contexts */ DLIST_ADD(p->contexts, context_fns); DEBUG(4,("Created internal pipe %s\n", pipe_name)); return p; }
static bool check_bind_req(struct pipes_struct *p, struct ndr_syntax_id* abstract, struct ndr_syntax_id* transfer, uint32_t context_id) { struct pipe_rpc_fns *context_fns; bool ok; DEBUG(3,("check_bind_req for %s\n", ndr_interface_name(&abstract->uuid, abstract->if_version))); /* we have to check all now since win2k introduced a new UUID on the lsaprpc pipe */ if (rpc_srv_pipe_exists_by_id(abstract) && ndr_syntax_id_equal(transfer, &ndr_transfer_syntax_ndr)) { DEBUG(3, ("check_bind_req: %s -> %s rpc service\n", rpc_srv_get_pipe_cli_name(abstract), rpc_srv_get_pipe_srv_name(abstract))); } else { return false; } ok = init_pipe_handles(p, abstract); if (!ok) { DEBUG(1, ("Failed to init pipe handles!\n")); return false; } context_fns = talloc(p, struct pipe_rpc_fns); if (context_fns == NULL) { DEBUG(0,("check_bind_req: talloc() failed!\n")); return false; } context_fns->next = context_fns->prev = NULL; context_fns->n_cmds = rpc_srv_get_pipe_num_cmds(abstract); context_fns->cmds = rpc_srv_get_pipe_cmds(abstract); context_fns->context_id = context_id; context_fns->syntax = *abstract; /* add to the list of open contexts */ DLIST_ADD( p->contexts, context_fns ); return True; }
struct pipes_struct *make_internal_rpc_pipe_p(TALLOC_CTX *mem_ctx, const struct ndr_syntax_id *syntax, const struct tsocket_address *remote_address, const struct auth_serversupplied_info *session_info, struct messaging_context *msg_ctx) { struct pipes_struct *p; struct pipe_rpc_fns *context_fns; DEBUG(4,("Create pipe requested %s\n", get_pipe_name_from_syntax(talloc_tos(), syntax))); p = talloc_zero(mem_ctx, struct pipes_struct); if (!p) { DEBUG(0,("ERROR! no memory for pipes_struct!\n")); return NULL; } p->mem_ctx = talloc_named(p, 0, "pipe %s %p", get_pipe_name_from_syntax(talloc_tos(), syntax), p); if (p->mem_ctx == NULL) { DEBUG(0,("open_rpc_pipe_p: talloc_init failed.\n")); TALLOC_FREE(p); return NULL; } if (!init_pipe_handles(p, syntax)) { DEBUG(0,("open_rpc_pipe_p: init_pipe_handles failed.\n")); TALLOC_FREE(p); return NULL; } p->session_info = copy_serverinfo(p, session_info); if (p->session_info == NULL) { DEBUG(0, ("open_rpc_pipe_p: copy_serverinfo failed\n")); close_policy_by_pipe(p); TALLOC_FREE(p); return NULL; } p->msg_ctx = msg_ctx; DLIST_ADD(InternalPipes, p); p->remote_address = tsocket_address_copy(remote_address, p); if (p->remote_address == NULL) { return false; } p->endian = RPC_LITTLE_ENDIAN; p->transport = NCALRPC; context_fns = SMB_MALLOC_P(struct pipe_rpc_fns); if (context_fns == NULL) { DEBUG(0,("malloc() failed!\n")); return False; } context_fns->next = context_fns->prev = NULL; context_fns->n_cmds = rpc_srv_get_pipe_num_cmds(syntax); context_fns->cmds = rpc_srv_get_pipe_cmds(syntax); context_fns->context_id = 0; context_fns->syntax = *syntax; /* add to the list of open contexts */ DLIST_ADD(p->contexts, context_fns); DEBUG(4,("Created internal pipe %s\n", get_pipe_name_from_syntax(talloc_tos(), syntax))); talloc_set_destructor(p, close_internal_rpc_pipe_hnd); return p; }
struct pipes_struct *make_internal_rpc_pipe_p(TALLOC_CTX *mem_ctx, const struct ndr_syntax_id *syntax, const struct tsocket_address *remote_address, const struct tsocket_address *local_address, const struct auth_session_info *session_info, struct messaging_context *msg_ctx) { struct pipes_struct *p; struct pipe_rpc_fns *context_fns; const char *pipe_name; int ret; const struct ndr_interface_table *table; table = ndr_table_by_uuid(&syntax->uuid); if (table == NULL) { DEBUG(0,("unknown interface\n")); return NULL; } pipe_name = dcerpc_default_transport_endpoint(mem_ctx, NCACN_NP, table); DEBUG(4,("Create pipe requested %s\n", pipe_name)); ret = make_base_pipes_struct(mem_ctx, msg_ctx, pipe_name, NCALRPC, RPC_LITTLE_ENDIAN, remote_address, local_address, &p); if (ret) { DEBUG(0,("ERROR! no memory for pipes_struct!\n")); return NULL; } if (!init_pipe_handles(p, syntax)) { DEBUG(0,("open_rpc_pipe_p: init_pipe_handles failed.\n")); TALLOC_FREE(p); return NULL; } p->session_info = copy_session_info(p, session_info); if (p->session_info == NULL) { DEBUG(0, ("open_rpc_pipe_p: copy_serverinfo failed\n")); close_policy_by_pipe(p); TALLOC_FREE(p); return NULL; } context_fns = talloc_zero(p, struct pipe_rpc_fns); if (context_fns == NULL) { DEBUG(0,("talloc() failed!\n")); TALLOC_FREE(p); return NULL; } context_fns->next = context_fns->prev = NULL; context_fns->n_cmds = rpc_srv_get_pipe_num_cmds(syntax); context_fns->cmds = rpc_srv_get_pipe_cmds(syntax); context_fns->context_id = 0; context_fns->syntax = *syntax; /* add to the list of open contexts */ DLIST_ADD(p->contexts, context_fns); DEBUG(4,("Created internal pipe %s\n", pipe_name)); return p; }
/* Creates a pipes_struct and initializes it with the information * sent from the client */ static int make_server_pipes_struct(TALLOC_CTX *mem_ctx, const char *pipe_name, const struct ndr_syntax_id id, enum dcerpc_transport_t transport, bool ncalrpc_as_system, const char *client_address, const char *server_address, struct auth_session_info_transport *session_info, struct pipes_struct **_p, int *perrno) { struct netr_SamInfo3 *info3; struct auth_user_info_dc *auth_user_info_dc; struct pipes_struct *p; NTSTATUS status; bool ok; p = talloc_zero(mem_ctx, struct pipes_struct); if (!p) { *perrno = ENOMEM; return -1; } p->syntax = id; p->transport = transport; p->ncalrpc_as_system = ncalrpc_as_system; p->allow_bind = true; p->mem_ctx = talloc_named(p, 0, "pipe %s %p", pipe_name, p); if (!p->mem_ctx) { TALLOC_FREE(p); *perrno = ENOMEM; return -1; } ok = init_pipe_handles(p, &id); if (!ok) { DEBUG(1, ("Failed to init handles\n")); TALLOC_FREE(p); *perrno = EINVAL; return -1; } data_blob_free(&p->in_data.data); data_blob_free(&p->in_data.pdu); p->endian = RPC_LITTLE_ENDIAN; /* Fake up an auth_user_info_dc for now, to make an info3, to make the session_info structure */ auth_user_info_dc = talloc_zero(p, struct auth_user_info_dc); if (!auth_user_info_dc) { TALLOC_FREE(p); *perrno = ENOMEM; return -1; } auth_user_info_dc->num_sids = session_info->security_token->num_sids; auth_user_info_dc->sids = session_info->security_token->sids; auth_user_info_dc->info = session_info->info; auth_user_info_dc->user_session_key = session_info->session_key; /* This creates the input structure that make_server_info_info3 is looking for */ status = auth_convert_user_info_dc_saminfo3(p, auth_user_info_dc, &info3); if (!NT_STATUS_IS_OK(status)) { DEBUG(1, ("Failed to convert auth_user_info_dc into netr_SamInfo3\n")); TALLOC_FREE(p); *perrno = EINVAL; return -1; } status = make_server_info_info3(p, info3->base.account_name.string, info3->base.domain.string, &p->session_info, info3); if (!NT_STATUS_IS_OK(status)) { DEBUG(1, ("Failed to init server info\n")); TALLOC_FREE(p); *perrno = EINVAL; return -1; } /* * Some internal functions need a local token to determine access to * resoutrces. */ status = create_local_token(p->session_info); if (!NT_STATUS_IS_OK(status)) { DEBUG(1, ("Failed to init local auth token\n")); TALLOC_FREE(p); *perrno = EINVAL; return -1; } /* Now override the session_info->security_token with the exact * security_token we were given from the other side, * regardless of what we just calculated */ p->session_info->security_token = talloc_move(p->session_info, &session_info->security_token); /* Also set the session key to the correct value */ p->session_info->user_session_key = session_info->session_key; p->session_info->user_session_key.data = talloc_move(p->session_info, &session_info->session_key.data); p->client_id = talloc_zero(p, struct client_address); if (!p->client_id) { TALLOC_FREE(p); *perrno = ENOMEM; return -1; } strlcpy(p->client_id->addr, client_address, sizeof(p->client_id->addr)); p->client_id->name = talloc_strdup(p->client_id, client_address); if (p->client_id->name == NULL) { TALLOC_FREE(p); *perrno = ENOMEM; return -1; } if (server_address != NULL) { p->server_id = talloc_zero(p, struct client_address); if (p->client_id == NULL) { TALLOC_FREE(p); *perrno = ENOMEM; return -1; } strlcpy(p->server_id->addr, server_address, sizeof(p->server_id->addr)); p->server_id->name = talloc_strdup(p->server_id, server_address); if (p->server_id->name == NULL) { TALLOC_FREE(p); *perrno = ENOMEM; return -1; } }