From: Volker Lendecke Date: Thu, 31 Dec 2020 13:49:26 +0000 (+0100) Subject: rpc_server: Add dcesrv_create_endpoint_list_fd_listen_fds() X-Git-Tag: samba-4.14.0rc1~126 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ca9674855284633f5d4a13ef8b79174054fdbfd3;p=thirdparty%2Fsamba.git rpc_server: Add dcesrv_create_endpoint_list_fd_listen_fds() This encapsulates the loop in the three standalone rpc daemons walking the endpoints in a dcesrv_context. Signed-off-by: Volker Lendecke Reviewed-by: Samuel Cabrero --- diff --git a/source3/rpc_server/rpc_service_setup.c b/source3/rpc_server/rpc_service_setup.c index 0a81bc7bbf5..a05c6db1fb8 100644 --- a/source3/rpc_server/rpc_service_setup.c +++ b/source3/rpc_server/rpc_service_setup.c @@ -167,6 +167,83 @@ NTSTATUS dcesrv_create_endpoint_sockets(struct tevent_context *ev_ctx, return status; } +NTSTATUS dcesrv_create_endpoint_list_pf_listen_fds( + struct tevent_context *ev_ctx, + struct messaging_context *msg_ctx, + struct dcesrv_context *dce_ctx, + struct dcesrv_endpoint *e, + TALLOC_CTX *mem_ctx, + size_t *pnum_fds, + struct pf_listen_fd **pfds) +{ + struct pf_listen_fd *fds = NULL; + size_t num_fds = 0; + NTSTATUS status; + + for (; e != NULL; e = e->next) { + int *ep_fds = NULL; + struct pf_listen_fd *tmp = NULL; + size_t i, num_ep_fds; + + status = dcesrv_create_endpoint_sockets( + ev_ctx, + msg_ctx, + dce_ctx, + e, + mem_ctx, + &num_ep_fds, + &ep_fds); + if (!NT_STATUS_IS_OK(status)) { + char *ep_string = dcerpc_binding_string( + dce_ctx, e->ep_description); + DBG_ERR("Failed to create endpoint '%s': %s\n", + ep_string, nt_errstr(status)); + TALLOC_FREE(ep_string); + goto fail; + } + + if (num_fds + num_ep_fds < num_fds) { + /* overflow */ + status = NT_STATUS_INTEGER_OVERFLOW; + goto fail; + } + + tmp = talloc_realloc( + mem_ctx, + fds, + struct pf_listen_fd, + num_fds + num_ep_fds); + if (tmp == NULL) { + status = NT_STATUS_NO_MEMORY; + goto fail; + } + fds = tmp; + + for (i=0; i