mirror of
https://github.com/samba-team/samba.git
synced 2025-02-26 21:57:41 +03:00
s3:rpc_server: Store dcesrv context and endpoint in ncacn_conn
Signed-off-by: Samuel Cabrero <scabrero@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
06a913a269
commit
d4e6764b22
@ -131,8 +131,8 @@ NTSTATUS make_internal_rpc_pipe_socketpair(
|
|||||||
status = dcerpc_ncacn_conn_init(npa,
|
status = dcerpc_ncacn_conn_init(npa,
|
||||||
ev_ctx,
|
ev_ctx,
|
||||||
msg_ctx,
|
msg_ctx,
|
||||||
NCACN_NP,
|
dce_ctx,
|
||||||
pipe_name,
|
endpoint,
|
||||||
NULL, /* termination fn */
|
NULL, /* termination fn */
|
||||||
NULL, /* termination data */
|
NULL, /* termination data */
|
||||||
&ncacn_conn);
|
&ncacn_conn);
|
||||||
|
@ -739,8 +739,8 @@ static int dcerpc_ncacn_conn_destructor(struct dcerpc_ncacn_conn *ncacn_conn)
|
|||||||
NTSTATUS dcerpc_ncacn_conn_init(TALLOC_CTX *mem_ctx,
|
NTSTATUS dcerpc_ncacn_conn_init(TALLOC_CTX *mem_ctx,
|
||||||
struct tevent_context *ev_ctx,
|
struct tevent_context *ev_ctx,
|
||||||
struct messaging_context *msg_ctx,
|
struct messaging_context *msg_ctx,
|
||||||
enum dcerpc_transport_t transport,
|
struct dcesrv_context *dce_ctx,
|
||||||
const char *name,
|
struct dcesrv_endpoint *endpoint,
|
||||||
dcerpc_ncacn_termination_fn term_fn,
|
dcerpc_ncacn_termination_fn term_fn,
|
||||||
void *termination_data,
|
void *termination_data,
|
||||||
struct dcerpc_ncacn_conn **out)
|
struct dcerpc_ncacn_conn **out)
|
||||||
@ -753,19 +753,13 @@ NTSTATUS dcerpc_ncacn_conn_init(TALLOC_CTX *mem_ctx,
|
|||||||
}
|
}
|
||||||
talloc_set_destructor(ncacn_conn, dcerpc_ncacn_conn_destructor);
|
talloc_set_destructor(ncacn_conn, dcerpc_ncacn_conn_destructor);
|
||||||
|
|
||||||
ncacn_conn->transport = transport;
|
|
||||||
ncacn_conn->ev_ctx = ev_ctx;
|
ncacn_conn->ev_ctx = ev_ctx;
|
||||||
ncacn_conn->msg_ctx = msg_ctx;
|
ncacn_conn->msg_ctx = msg_ctx;
|
||||||
|
ncacn_conn->dce_ctx = dce_ctx;
|
||||||
|
ncacn_conn->endpoint = endpoint;
|
||||||
ncacn_conn->sock = -1;
|
ncacn_conn->sock = -1;
|
||||||
ncacn_conn->termination_fn = term_fn;
|
ncacn_conn->termination_fn = term_fn;
|
||||||
ncacn_conn->termination_data = termination_data;
|
ncacn_conn->termination_data = termination_data;
|
||||||
if (name != NULL) {
|
|
||||||
ncacn_conn->name = talloc_strdup(ncacn_conn, name);
|
|
||||||
if (ncacn_conn->name == NULL) {
|
|
||||||
talloc_free(ncacn_conn);
|
|
||||||
return NT_STATUS_NO_MEMORY;;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*out = ncacn_conn;
|
*out = ncacn_conn;
|
||||||
|
|
||||||
@ -791,9 +785,6 @@ void dcerpc_ncacn_accept(struct tevent_context *ev_ctx,
|
|||||||
{
|
{
|
||||||
enum dcerpc_transport_t transport =
|
enum dcerpc_transport_t transport =
|
||||||
dcerpc_binding_get_transport(e->ep_description);
|
dcerpc_binding_get_transport(e->ep_description);
|
||||||
const char *endpoint =
|
|
||||||
dcerpc_binding_get_string_option(e->ep_description,
|
|
||||||
"endpoint");
|
|
||||||
struct dcerpc_ncacn_conn *ncacn_conn;
|
struct dcerpc_ncacn_conn *ncacn_conn;
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
int rc;
|
int rc;
|
||||||
@ -803,8 +794,8 @@ void dcerpc_ncacn_accept(struct tevent_context *ev_ctx,
|
|||||||
status = dcerpc_ncacn_conn_init(ev_ctx,
|
status = dcerpc_ncacn_conn_init(ev_ctx,
|
||||||
ev_ctx,
|
ev_ctx,
|
||||||
msg_ctx,
|
msg_ctx,
|
||||||
transport,
|
dce_ctx,
|
||||||
endpoint,
|
e,
|
||||||
termination_fn,
|
termination_fn,
|
||||||
termination_data,
|
termination_data,
|
||||||
&ncacn_conn);
|
&ncacn_conn);
|
||||||
@ -941,8 +932,12 @@ static void dcesrv_ncacn_accept_step2(struct dcerpc_ncacn_conn *ncacn_conn)
|
|||||||
gid_t gid;
|
gid_t gid;
|
||||||
int rc;
|
int rc;
|
||||||
int sys_errno;
|
int sys_errno;
|
||||||
|
enum dcerpc_transport_t transport = dcerpc_binding_get_transport(
|
||||||
|
ncacn_conn->endpoint->ep_description);
|
||||||
|
const char *endpoint = dcerpc_binding_get_string_option(
|
||||||
|
ncacn_conn->endpoint->ep_description, "endpoint");
|
||||||
|
|
||||||
switch (ncacn_conn->transport) {
|
switch (transport) {
|
||||||
case NCACN_IP_TCP:
|
case NCACN_IP_TCP:
|
||||||
pipe_name = tsocket_address_string(ncacn_conn->remote_client_addr,
|
pipe_name = tsocket_address_string(ncacn_conn->remote_client_addr,
|
||||||
ncacn_conn);
|
ncacn_conn);
|
||||||
@ -985,8 +980,7 @@ static void dcesrv_ncacn_accept_step2(struct dcerpc_ncacn_conn *ncacn_conn)
|
|||||||
|
|
||||||
FALL_THROUGH;
|
FALL_THROUGH;
|
||||||
case NCACN_NP:
|
case NCACN_NP:
|
||||||
pipe_name = talloc_strdup(ncacn_conn,
|
pipe_name = talloc_strdup(ncacn_conn, endpoint);
|
||||||
ncacn_conn->name);
|
|
||||||
if (pipe_name == NULL) {
|
if (pipe_name == NULL) {
|
||||||
DBG_ERR("No memory\n");
|
DBG_ERR("No memory\n");
|
||||||
ncacn_terminate_connection(ncacn_conn, "No memory");
|
ncacn_terminate_connection(ncacn_conn, "No memory");
|
||||||
@ -994,8 +988,7 @@ static void dcesrv_ncacn_accept_step2(struct dcerpc_ncacn_conn *ncacn_conn)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
DBG_ERR("unknown dcerpc transport: %u!\n",
|
DBG_ERR("unknown dcerpc transport: %u!\n", transport);
|
||||||
ncacn_conn->transport);
|
|
||||||
ncacn_terminate_connection(ncacn_conn,
|
ncacn_terminate_connection(ncacn_conn,
|
||||||
"Unknown DCE/RPC transport");
|
"Unknown DCE/RPC transport");
|
||||||
return;
|
return;
|
||||||
@ -1018,7 +1011,7 @@ static void dcesrv_ncacn_accept_step2(struct dcerpc_ncacn_conn *ncacn_conn)
|
|||||||
rc = make_server_pipes_struct(ncacn_conn,
|
rc = make_server_pipes_struct(ncacn_conn,
|
||||||
ncacn_conn->msg_ctx,
|
ncacn_conn->msg_ctx,
|
||||||
pipe_name,
|
pipe_name,
|
||||||
ncacn_conn->transport,
|
transport,
|
||||||
ncacn_conn->remote_client_addr,
|
ncacn_conn->remote_client_addr,
|
||||||
ncacn_conn->local_server_addr,
|
ncacn_conn->local_server_addr,
|
||||||
&ncacn_conn->session_info,
|
&ncacn_conn->session_info,
|
||||||
@ -1067,6 +1060,8 @@ void dcerpc_ncacn_packet_process(struct tevent_req *subreq)
|
|||||||
size_t i;
|
size_t i;
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
bool ok;
|
bool ok;
|
||||||
|
enum dcerpc_transport_t transport = dcerpc_binding_get_transport(
|
||||||
|
ncacn_conn->endpoint->ep_description);
|
||||||
|
|
||||||
status = dcerpc_read_ncacn_packet_recv(subreq, ncacn_conn, &pkt, &recv_buffer);
|
status = dcerpc_read_ncacn_packet_recv(subreq, ncacn_conn, &pkt, &recv_buffer);
|
||||||
TALLOC_FREE(subreq);
|
TALLOC_FREE(subreq);
|
||||||
@ -1174,7 +1169,7 @@ void dcerpc_ncacn_packet_process(struct tevent_req *subreq)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (ncacn_conn->transport) {
|
switch (transport) {
|
||||||
case NCACN_NP:
|
case NCACN_NP:
|
||||||
/* If sending packets over named pipe proxy we need to send
|
/* If sending packets over named pipe proxy we need to send
|
||||||
* each fragment on its own to be a message
|
* each fragment on its own to be a message
|
||||||
@ -1245,6 +1240,8 @@ static void dcerpc_ncacn_packet_done(struct tevent_req *subreq)
|
|||||||
NTSTATUS status = NT_STATUS_OK;
|
NTSTATUS status = NT_STATUS_OK;
|
||||||
int sys_errno;
|
int sys_errno;
|
||||||
int rc;
|
int rc;
|
||||||
|
enum dcerpc_transport_t transport = dcerpc_binding_get_transport(
|
||||||
|
ncacn_conn->endpoint->ep_description);
|
||||||
|
|
||||||
rc = tstream_writev_queue_recv(subreq, &sys_errno);
|
rc = tstream_writev_queue_recv(subreq, &sys_errno);
|
||||||
TALLOC_FREE(subreq);
|
TALLOC_FREE(subreq);
|
||||||
@ -1254,7 +1251,7 @@ static void dcerpc_ncacn_packet_done(struct tevent_req *subreq)
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ncacn_conn->transport == NCACN_NP &&
|
if (transport == NCACN_NP &&
|
||||||
tevent_queue_length(ncacn_conn->send_queue) > 0) {
|
tevent_queue_length(ncacn_conn->send_queue) > 0) {
|
||||||
/* More fragments to send before reading a new packet */
|
/* More fragments to send before reading a new packet */
|
||||||
return;
|
return;
|
||||||
|
@ -31,9 +31,6 @@ struct cli_credentials;
|
|||||||
typedef void (*dcerpc_ncacn_termination_fn)(struct pipes_struct *, void *);
|
typedef void (*dcerpc_ncacn_termination_fn)(struct pipes_struct *, void *);
|
||||||
|
|
||||||
struct dcerpc_ncacn_conn {
|
struct dcerpc_ncacn_conn {
|
||||||
enum dcerpc_transport_t transport;
|
|
||||||
|
|
||||||
const char *name;
|
|
||||||
int sock;
|
int sock;
|
||||||
|
|
||||||
struct pipes_struct *p;
|
struct pipes_struct *p;
|
||||||
@ -42,6 +39,8 @@ struct dcerpc_ncacn_conn {
|
|||||||
|
|
||||||
struct tevent_context *ev_ctx;
|
struct tevent_context *ev_ctx;
|
||||||
struct messaging_context *msg_ctx;
|
struct messaging_context *msg_ctx;
|
||||||
|
struct dcesrv_context *dce_ctx;
|
||||||
|
struct dcesrv_endpoint *endpoint;
|
||||||
|
|
||||||
struct tstream_context *tstream;
|
struct tstream_context *tstream;
|
||||||
struct tevent_queue *send_queue;
|
struct tevent_queue *send_queue;
|
||||||
@ -59,8 +58,8 @@ struct dcerpc_ncacn_conn {
|
|||||||
NTSTATUS dcerpc_ncacn_conn_init(TALLOC_CTX *mem_ctx,
|
NTSTATUS dcerpc_ncacn_conn_init(TALLOC_CTX *mem_ctx,
|
||||||
struct tevent_context *ev_ctx,
|
struct tevent_context *ev_ctx,
|
||||||
struct messaging_context *msg_ctx,
|
struct messaging_context *msg_ctx,
|
||||||
enum dcerpc_transport_t transport,
|
struct dcesrv_context *dce_ctx,
|
||||||
const char *name,
|
struct dcesrv_endpoint *endpoint,
|
||||||
dcerpc_ncacn_termination_fn term_fn,
|
dcerpc_ncacn_termination_fn term_fn,
|
||||||
void *termination_data,
|
void *termination_data,
|
||||||
struct dcerpc_ncacn_conn **out);
|
struct dcerpc_ncacn_conn **out);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user