s3:rpc_server: Init registered ep servers in external epmd daemon
authorSamuel Cabrero <scabrero@suse.de>
Tue, 26 Feb 2019 16:15:37 +0000 (17:15 +0100)
committerSamuel Cabrero <scabrero@sn-devel-184>
Fri, 20 Mar 2020 15:36:32 +0000 (15:36 +0000)
Initialize and shutdown the endpoint servers registed by the endpoint
mapper daemon. The pidl-generated init function will register the
api_struct for backward compatibility until completely removed.

The common server exit routine will shutdown all registered endpoint
servers, and the pidl-generated shutdown function will unregister the
api_struct.

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source3/rpc_server/epmapper/srv_epmapper.c
source3/rpc_server/epmd.c
source3/smbd/server_exit.c

index 26aa095cf32a57758c8eeb54a5fb17d2135546b8..a2373c063fde9ecc26f4cf4dc82ab77d3e44a9b7 100644 (file)
@@ -27,6 +27,9 @@
 #include "srv_epmapper.h"
 #include "auth.h"
 
+#include "librpc/rpc/dcesrv_core.h"
+#include "librpc/gen_ndr/ndr_epmapper_scompat.h"
+
 typedef uint32_t error_status_t;
 
 /* An endpoint combined with an interface description */
@@ -1211,6 +1214,20 @@ error_status_t _epm_MapAuth(struct pipes_struct *p,
        return EPMAPPER_STATUS_CANT_PERFORM_OP;
 }
 
+static NTSTATUS epmapper__op_shutdown_server(struct dcesrv_context *dce_ctx,
+                       const struct dcesrv_endpoint_server *ep_server);
+
+#define DCESRV_INTERFACE_EPMAPPER_SHUTDOWN_SERVER \
+       epmapper_shutdown_server
+
+static NTSTATUS epmapper_shutdown_server(struct dcesrv_context *dce_ctx,
+               const struct dcesrv_endpoint_server *ep_server)
+{
+       srv_epmapper_cleanup();
+
+       return epmapper__op_shutdown_server(dce_ctx, ep_server);
+}
+
 /* include the generated boilerplate */
 #include "librpc/gen_ndr/ndr_epmapper_scompat.c"
 
index 334a433cdca0567023ed33fc60c15ae77e9b6e1a..952ad4f29e5868f47fdd60cb28536fea2ada977f 100644 (file)
@@ -130,26 +130,15 @@ static void epmd_setup_sig_hup_handler(struct tevent_context *ev_ctx,
        }
 }
 
-static bool epmapper_shutdown_cb(void *ptr) {
-       srv_epmapper_cleanup();
-
-       return true;
-}
-
 void start_epmd(struct tevent_context *ev_ctx,
                struct messaging_context *msg_ctx,
                struct dcesrv_context *dce_ctx)
 {
-       struct rpc_srv_callbacks epmapper_cb;
        NTSTATUS status;
        pid_t pid;
        int rc;
        const struct dcesrv_endpoint_server *ep_server = NULL;
 
-       epmapper_cb.init = NULL;
-       epmapper_cb.shutdown = epmapper_shutdown_cb;
-       epmapper_cb.private_data = NULL;
-
        DEBUG(1, ("Forking Endpoint Mapper Daemon\n"));
 
        pid = fork();
@@ -206,10 +195,12 @@ void start_epmd(struct tevent_context *ev_ctx,
                exit(1);
        }
 
-       status = rpc_epmapper_init(&epmapper_cb);
+       DBG_INFO("Initializing DCE/RPC registered endpoint servers\n");
+
+       status = dcesrv_init_ep_server(dce_ctx, "epmapper");
        if (!NT_STATUS_IS_OK(status)) {
-               DEBUG(0, ("Failed to register epmd rpc interface! (%s)\n",
-                         nt_errstr(status)));
+               DBG_ERR("Failed to init DCE/RPC endpoint server: %s\n",
+                       nt_errstr(status));
                exit(1);
        }
 
index 76be0f8294f0985ec541b2945b93d0f1df7364f1..90f6644a432990ee73fee5b7c0eaeadc45eb02fd 100644 (file)
@@ -220,8 +220,6 @@ static void exit_server_common(enum server_exit_reason how,
 
                rpc_FileServerVssAgent_shutdown();
 
-               rpc_epmapper_shutdown();
-
                global_dcesrv_context_free();
        }