From: Volker Lendecke Date: Thu, 31 Dec 2020 09:47:03 +0000 (+0100) Subject: rpc_server: Lift ph_listen_fd logic one level X-Git-Tag: samba-4.14.0rc1~127 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9c9b0fd61605c67ecfa7ae63d062fa711d705a47;p=thirdparty%2Fsamba.git 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 Reviewed-by: Samuel Cabrero --- diff --git a/source3/printing/spoolssd.c b/source3/printing/spoolssd.c index e56ebabd28f..dc2b85912a9 100644 --- a/source3/printing/spoolssd.c +++ b/source3/printing/spoolssd.c @@ -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; jendpoint_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; jendpoint_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; jep_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_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; } diff --git a/source3/rpc_server/rpc_service_setup.h b/source3/rpc_server/rpc_service_setup.h index b444c0fa583..856fce0dab2 100644 --- a/source3/rpc_server/rpc_service_setup.h +++ b/source3/rpc_server/rpc_service_setup.h @@ -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,