mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
rpc_server: Lift ph_listen_fd logic one level
Push filling in struct pf_listen_fd into the daemons using dcesrv_create_endpoint_sockets(). Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Samuel Cabrero <scabrero@samba.org>
This commit is contained in:
parent
a00e3e8af3
commit
9c9b0fd616
@ -593,12 +593,16 @@ static NTSTATUS spoolssd_create_sockets(struct tevent_context *ev_ctx,
|
||||
DBG_INFO("Initializing DCE/RPC connection endpoints\n");
|
||||
|
||||
for (e = dce_ctx->endpoint_list; e; e = e->next) {
|
||||
int *fds = NULL;
|
||||
size_t j, num_fds;
|
||||
|
||||
status = dcesrv_create_endpoint_sockets(ev_ctx,
|
||||
msg_ctx,
|
||||
dce_ctx,
|
||||
e,
|
||||
listen_fd,
|
||||
listen_fd_size);
|
||||
dce_ctx,
|
||||
&num_fds,
|
||||
&fds);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
char *ep_string = dcerpc_binding_string(
|
||||
dce_ctx, e->ep_description);
|
||||
@ -607,6 +611,12 @@ static NTSTATUS spoolssd_create_sockets(struct tevent_context *ev_ctx,
|
||||
TALLOC_FREE(ep_string);
|
||||
goto done;
|
||||
}
|
||||
for (j=0; j<num_fds; j++) {
|
||||
listen_fd[*listen_fd_size].fd = fds[j];
|
||||
listen_fd[*listen_fd_size].fd_data = e;
|
||||
(*listen_fd_size)++;
|
||||
}
|
||||
TALLOC_FREE(fds);
|
||||
}
|
||||
|
||||
for (i = 0; i < *listen_fd_size; i++) {
|
||||
|
@ -558,12 +558,16 @@ static NTSTATUS lsasd_create_sockets(struct tevent_context *ev_ctx,
|
||||
DBG_INFO("Initializing DCE/RPC connection endpoints\n");
|
||||
|
||||
for (e = dce_ctx->endpoint_list; e; e = e->next) {
|
||||
int *fds = NULL;
|
||||
size_t j, num_fds;
|
||||
|
||||
status = dcesrv_create_endpoint_sockets(ev_ctx,
|
||||
msg_ctx,
|
||||
dce_ctx,
|
||||
e,
|
||||
listen_fd,
|
||||
listen_fd_size);
|
||||
dce_ctx,
|
||||
&num_fds,
|
||||
&fds);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
char *ep_string = dcerpc_binding_string(
|
||||
dce_ctx, e->ep_description);
|
||||
@ -572,6 +576,12 @@ static NTSTATUS lsasd_create_sockets(struct tevent_context *ev_ctx,
|
||||
TALLOC_FREE(ep_string);
|
||||
goto done;
|
||||
}
|
||||
for (j=0; j<num_fds; j++) {
|
||||
listen_fd[*listen_fd_size].fd = fds[j];
|
||||
listen_fd[*listen_fd_size].fd_data = e;
|
||||
(*listen_fd_size)++;
|
||||
}
|
||||
TALLOC_FREE(fds);
|
||||
}
|
||||
|
||||
for (i = 0; i < *listen_fd_size; i++) {
|
||||
|
@ -508,12 +508,16 @@ static NTSTATUS mdssd_create_sockets(struct tevent_context *ev_ctx,
|
||||
DBG_INFO("Initializing DCE/RPC connection endpoints\n");
|
||||
|
||||
for (e = dce_ctx->endpoint_list; e; e = e->next) {
|
||||
int *fds = NULL;
|
||||
size_t j, num_fds;
|
||||
|
||||
status = dcesrv_create_endpoint_sockets(ev_ctx,
|
||||
msg_ctx,
|
||||
dce_ctx,
|
||||
e,
|
||||
listen_fd,
|
||||
listen_fd_size);
|
||||
dce_ctx,
|
||||
&num_fds,
|
||||
&fds);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
char *ep_string = dcerpc_binding_string(
|
||||
dce_ctx, e->ep_description);
|
||||
@ -522,6 +526,12 @@ static NTSTATUS mdssd_create_sockets(struct tevent_context *ev_ctx,
|
||||
TALLOC_FREE(ep_string);
|
||||
goto done;
|
||||
}
|
||||
for (j=0; j<num_fds; j++) {
|
||||
listen_fd[*listen_fd_size].fd = fds[j];
|
||||
listen_fd[*listen_fd_size].fd_data = e;
|
||||
(*listen_fd_size)++;
|
||||
}
|
||||
TALLOC_FREE(fds);
|
||||
}
|
||||
|
||||
for (i = 0; i < *listen_fd_size; i++) {
|
||||
|
@ -89,57 +89,45 @@ NTSTATUS dcesrv_create_endpoint_sockets(struct tevent_context *ev_ctx,
|
||||
struct messaging_context *msg_ctx,
|
||||
struct dcesrv_context *dce_ctx,
|
||||
struct dcesrv_endpoint *e,
|
||||
struct pf_listen_fd *listen_fds,
|
||||
int *listen_fds_size)
|
||||
TALLOC_CTX *mem_ctx,
|
||||
size_t *pnum_fds,
|
||||
int **pfds)
|
||||
{
|
||||
enum dcerpc_transport_t transport =
|
||||
dcerpc_binding_get_transport(e->ep_description);
|
||||
char *binding = NULL;
|
||||
int *fds = NULL;
|
||||
size_t num_fds;
|
||||
NTSTATUS status;
|
||||
int out_fd;
|
||||
|
||||
binding = dcerpc_binding_string(dce_ctx, e->ep_description);
|
||||
binding = dcerpc_binding_string(mem_ctx, e->ep_description);
|
||||
if (binding == NULL) {
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
DBG_DEBUG("Creating endpoint '%s'\n", binding);
|
||||
TALLOC_FREE(binding);
|
||||
|
||||
fds = talloc(mem_ctx, int);
|
||||
if (fds == NULL) {
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
num_fds = 1;
|
||||
|
||||
switch (transport) {
|
||||
case NCALRPC:
|
||||
status = dcesrv_create_ncalrpc_socket(e, &out_fd);
|
||||
if (NT_STATUS_IS_OK(status)) {
|
||||
listen_fds[*listen_fds_size].fd = out_fd;
|
||||
listen_fds[*listen_fds_size].fd_data = e;
|
||||
(*listen_fds_size)++;
|
||||
}
|
||||
status = dcesrv_create_ncalrpc_socket(e, fds);
|
||||
break;
|
||||
|
||||
case NCACN_IP_TCP: {
|
||||
int *fds = NULL;
|
||||
size_t num_fds;
|
||||
TALLOC_FREE(fds);
|
||||
|
||||
status = dcesrv_create_ncacn_ip_tcp_sockets(
|
||||
e, talloc_tos(), &num_fds, &fds);
|
||||
if (NT_STATUS_IS_OK(status)) {
|
||||
size_t i;
|
||||
for (i=0; i<num_fds; i++) {
|
||||
listen_fds[*listen_fds_size].fd = fds[i];
|
||||
listen_fds[*listen_fds_size].fd_data = e;
|
||||
(*listen_fds_size)++;
|
||||
}
|
||||
}
|
||||
TALLOC_FREE(fds);
|
||||
break;
|
||||
}
|
||||
|
||||
case NCACN_NP:
|
||||
status = dcesrv_create_ncacn_np_socket(e, &out_fd);
|
||||
if (NT_STATUS_IS_OK(status)) {
|
||||
listen_fds[*listen_fds_size].fd = out_fd;
|
||||
listen_fds[*listen_fds_size].fd_data = e;
|
||||
(*listen_fds_size)++;
|
||||
}
|
||||
status = dcesrv_create_ncacn_np_socket(e, fds);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -149,8 +137,7 @@ NTSTATUS dcesrv_create_endpoint_sockets(struct tevent_context *ev_ctx,
|
||||
|
||||
/* Build binding string again as the endpoint may have changed by
|
||||
* dcesrv_create_<transport>_socket functions */
|
||||
TALLOC_FREE(binding);
|
||||
binding = dcerpc_binding_string(dce_ctx, e->ep_description);
|
||||
binding = dcerpc_binding_string(mem_ctx, e->ep_description);
|
||||
if (binding == NULL) {
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
@ -174,6 +161,9 @@ NTSTATUS dcesrv_create_endpoint_sockets(struct tevent_context *ev_ctx,
|
||||
|
||||
TALLOC_FREE(binding);
|
||||
|
||||
*pnum_fds = num_fds;
|
||||
*pfds = fds;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -42,8 +42,9 @@ NTSTATUS dcesrv_create_endpoint_sockets(struct tevent_context *ev_ctx,
|
||||
struct messaging_context *msg_ctx,
|
||||
struct dcesrv_context *dce_ctx,
|
||||
struct dcesrv_endpoint *e,
|
||||
struct pf_listen_fd *listen_fds,
|
||||
int *listen_fds_size);
|
||||
TALLOC_CTX *mem_ctx,
|
||||
size_t *pnum_fds,
|
||||
int **pfds);
|
||||
|
||||
NTSTATUS rpc_setup_embedded(struct tevent_context *ev_ctx,
|
||||
struct messaging_context *msg_ctx,
|
||||
|
Loading…
Reference in New Issue
Block a user