]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:rpc_server: Add a function to create the endpoints sockets
authorSamuel Cabrero <scabrero@suse.de>
Wed, 27 Feb 2019 13:21:01 +0000 (14:21 +0100)
committerSamuel Cabrero <scabrero@sn-devel-184>
Fri, 20 Mar 2020 15:36:33 +0000 (15:36 +0000)
The pidl-generated initialization function for each endpoint server will
register the RPC interface in all endpoints defined in the idl file.

The interface registration code will create the endpoint if it does not
exists (as an endpoint can serve multiple interfaces) and will add it to
the endpoint list exiting in the dcesrv_context.

This commit adds a generic dcesrv_create_endpoint_sockets function which
will be preforking external daemons to create the sockets regardless the
endpoint transport. This function will only create the sockets, the
external preforking daemon is who will start listening.

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source3/rpc_server/rpc_service_setup.c
source3/rpc_server/rpc_service_setup.h

index 23c284697633039d327c2f1f28c66c175e254b10..529ba952870c62130faadeab1c339c92a0c1cf6b 100644 (file)
@@ -115,6 +115,77 @@ NTSTATUS rpc_setup_embedded(struct tevent_context *ev_ctx,
        return NT_STATUS_OK;
 }
 
+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 dcerpc_binding_vector *bvec,
+                                       struct pf_listen_fd *listen_fds,
+                                       int *listen_fds_size)
+{
+       enum dcerpc_transport_t transport =
+               dcerpc_binding_get_transport(e->ep_description);
+       char *binding = NULL;
+       NTSTATUS status;
+
+       binding = dcerpc_binding_string(dce_ctx, e->ep_description);
+       if (binding == NULL) {
+               return NT_STATUS_NO_MEMORY;
+       }
+
+       DBG_DEBUG("Creating endpoint '%s'\n", binding);
+
+       switch (transport) {
+       case NCALRPC:
+               /* TODO */
+               status = NT_STATUS_OK;
+               break;
+
+       case NCACN_IP_TCP:
+               /* TODO */
+               status = NT_STATUS_OK;
+               break;
+
+       case NCACN_NP:
+               /* TODO */
+               status = NT_STATUS_OK;
+               break;
+
+       default:
+               status = NT_STATUS_NOT_SUPPORTED;
+               break;
+       }
+
+       /* 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);
+       if (binding == NULL) {
+               return NT_STATUS_NO_MEMORY;
+       }
+
+       if (!NT_STATUS_IS_OK(status)) {
+               struct dcesrv_if_list *iface = NULL;
+               DBG_ERR("Failed to create '%s' sockets for ", binding);
+               for (iface = e->interface_list; iface; iface = iface->next) {
+                       DEBUGADD(DBGLVL_ERR, ("'%s' ", iface->iface->name));
+               }
+               DEBUGADD(DBGLVL_ERR, (": %s\n", nt_errstr(status)));
+               return status;
+       } else {
+               struct dcesrv_if_list *iface = NULL;
+               DBG_INFO("Successfully listening on '%s' for ", binding);
+               for (iface = e->interface_list; iface; iface = iface->next) {
+                       DEBUGADD(DBGLVL_INFO, ("'%s' ", iface->iface->name));
+               }
+               DEBUGADD(DBGLVL_INFO, ("\n"));
+       }
+
+       TALLOC_FREE(binding);
+
+       return status;
+}
+
 NTSTATUS dcesrv_setup_endpoint_sockets(struct tevent_context *ev_ctx,
                                       struct messaging_context *msg_ctx,
                                       struct dcesrv_context *dce_ctx,
index 08bca1d49559b16ddb0279248e6961985e54eeac..b9bf52564c903ccd5485ba36975cc8b269b2e357 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "rpc_server/rpc_server.h"
 
+struct pf_listen_fd;
 struct dcerpc_binding_vector;
 
 NTSTATUS dcesrv_init(TALLOC_CTX *mem_ctx,
@@ -39,6 +40,14 @@ NTSTATUS dcesrv_setup_endpoint_sockets(struct tevent_context *ev_ctx,
                                       dcerpc_ncacn_termination_fn term_fn,
                                       void *term_data);
 
+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 dcerpc_binding_vector *bvec,
+                                       struct pf_listen_fd *listen_fds,
+                                       int *listen_fds_size);
+
 NTSTATUS rpc_setup_embedded(struct tevent_context *ev_ctx,
                            struct messaging_context *msg_ctx,
                            const struct ndr_interface_table *t,