Exemple #1
0
/* Creates a pipes_struct and initializes it with the information
 * sent from the client */
int make_server_pipes_struct(TALLOC_CTX *mem_ctx,
			     struct messaging_context *msg_ctx,
			     const char *pipe_name,
			     enum dcerpc_transport_t transport,
			     const struct tsocket_address *local_address,
			     const struct tsocket_address *remote_address,
			     struct auth_session_info *session_info,
			     struct pipes_struct **_p,
			     int *perrno)
{
	struct pipes_struct *p;
	int ret;

	ret = make_base_pipes_struct(mem_ctx, msg_ctx, pipe_name,
				     transport, RPC_LITTLE_ENDIAN,
				     remote_address, local_address, &p);
	if (ret) {
		*perrno = ret;
		return -1;
	}

	if (session_info->unix_token && session_info->unix_info && session_info->security_token) {
		/* Don't call create_local_token(), we already have the full details here */
		p->session_info = talloc_steal(p, session_info);

	} else {
		DEBUG(0, ("Supplied session_info in make_server_pipes_struct was incomplete!"));
		*perrno = EINVAL;
		return -1;
	}

	*_p = p;
	return 0;
}
Exemple #2
0
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;
}
Exemple #3
0
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;
}
Exemple #4
0
/* Creates a pipes_struct and initializes it with the information
 * sent from the client */
static int make_server_pipes_struct(TALLOC_CTX *mem_ctx,
				    struct messaging_context *msg_ctx,
				    const char *pipe_name,
				    enum dcerpc_transport_t transport,
				    bool ncalrpc_as_system,
				    const struct tsocket_address *local_address,
				    const struct tsocket_address *remote_address,
				    struct auth_session_info *session_info,
				    struct pipes_struct **_p,
				    int *perrno)
{
	struct pipes_struct *p;
	NTSTATUS status;
	int ret;

	ret = make_base_pipes_struct(mem_ctx, msg_ctx, pipe_name,
				     transport, RPC_LITTLE_ENDIAN,
				     ncalrpc_as_system,
				     remote_address, local_address, &p);
	if (ret) {
		*perrno = ret;
		return -1;
	}

	if (session_info->unix_token && session_info->unix_info && session_info->security_token) {
		/* Don't call create_local_token(), we already have the full details here */
		p->session_info = talloc_steal(p, session_info);

	} else {
		struct auth_user_info_dc *auth_user_info_dc;
		struct auth_serversupplied_info *server_info;
		struct netr_SamInfo3 *info3;

		/* 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.logon_domain.string,
						&server_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
		 * resources.
		 */
		status = create_local_token(p, server_info, &session_info->session_key, info3->base.account_name.string,
					    &p->session_info);
		talloc_free(server_info);
		if (!NT_STATUS_IS_OK(status)) {
			DEBUG(1, ("Failed to init local auth token\n"));
			TALLOC_FREE(p);
			*perrno = EINVAL;
			return -1;
		}
	}

	*_p = p;
	return 0;
}