]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:rpc_server: Init registered ep servers in external fssd daemon
authorSamuel Cabrero <scabrero@suse.de>
Tue, 26 Feb 2019 16:59:38 +0000 (17:59 +0100)
committerSamuel Cabrero <scabrero@sn-devel-184>
Fri, 20 Mar 2020 15:36:33 +0000 (15:36 +0000)
Initialize and shutdown the endpoint servers registed by the fssd
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/fss/srv_fss_agent.c
source3/rpc_server/fssd.c

index 1177828c9305d1050484967fb563681fbcaa066f..ba1c01a7b1e9873b95870e78e61557ba658db625 100644 (file)
@@ -27,7 +27,9 @@
 #include "../lib/smbconf/smbconf.h"
 #include "smbd/proto.h"
 #include "lib/smbconf/smbconf_init.h"
+#include "librpc/rpc/dcesrv_core.h"
 #include "librpc/gen_ndr/srv_fsrvp.h"
+#include "rpc_server/rpc_server.h"
 #include "srv_fss_private.h"
 #include "srv_fss_agent.h"
 
@@ -1711,5 +1713,43 @@ uint32_t _fss_PrepareShadowCopySet(struct pipes_struct *p,
        return 0;
 }
 
+static NTSTATUS FileServerVssAgent__op_init_server(
+               struct dcesrv_context *dce_ctx,
+               const struct dcesrv_endpoint_server *ep_server);
+
+static NTSTATUS FileServerVssAgent__op_shutdown_server(
+               struct dcesrv_context *dce_ctx,
+               const struct dcesrv_endpoint_server *ep_server);
+
+#define DCESRV_INTERFACE_FILESERVERVSSAGENT_INIT_SERVER \
+       fileservervssagent_init_server
+
+#define DCESRV_INTERFACE_FILESERVERVSSAGENT_SHUTDOWN_SERVER \
+       fileservervssagent_shutdown_server
+
+
+static NTSTATUS fileservervssagent_shutdown_server(
+               struct dcesrv_context *dce_ctx,
+               const struct dcesrv_endpoint_server *ep_server)
+{
+       srv_fssa_cleanup();
+       return FileServerVssAgent__op_shutdown_server(dce_ctx, ep_server);
+}
+
+static NTSTATUS fileservervssagent_init_server(
+               struct dcesrv_context *dce_ctx,
+               const struct dcesrv_endpoint_server *ep_server)
+{
+       NTSTATUS status;
+       struct messaging_context *msg_ctx = global_messaging_context();
+
+       status = srv_fssa_start(msg_ctx);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
+
+       return FileServerVssAgent__op_init_server(dce_ctx, ep_server);
+}
+
 /* include the generated boilerplate */
 #include "librpc/gen_ndr/ndr_fsrvp_scompat.c"
index 283e456df55335918c13cc8ef926821083c4da29..27d2df05b6fd08ff62b61ecae1f30ae8a5deb811 100644 (file)
@@ -130,36 +130,15 @@ static void fssd_setup_sig_hup_handler(struct tevent_context *ev_ctx,
        }
 }
 
-static bool fss_shutdown_cb(void *ptr)
-{
-       srv_fssa_cleanup();
-       return true;
-}
-
-static bool fss_init_cb(void *ptr)
-{
-       NTSTATUS status;
-        struct messaging_context *msg_ctx;
-
-       msg_ctx = talloc_get_type_abort(ptr, struct messaging_context);
-       status = srv_fssa_start(msg_ctx);
-       return NT_STATUS_IS_OK(status);
-}
-
 void start_fssd(struct tevent_context *ev_ctx,
                struct messaging_context *msg_ctx,
                struct dcesrv_context *dce_ctx)
 {
-       struct rpc_srv_callbacks fss_cb;
        NTSTATUS status;
        pid_t pid;
        int rc;
        const struct dcesrv_endpoint_server *ep_server = NULL;
 
-       fss_cb.init = fss_init_cb;
-       fss_cb.shutdown = fss_shutdown_cb;
-       fss_cb.private_data = msg_ctx;
-
        DEBUG(1, ("Forking File Server Shadow-copy Daemon\n"));
 
        pid = fork();
@@ -217,10 +196,12 @@ void start_fssd(struct tevent_context *ev_ctx,
                exit(1);
        }
 
-       status = rpc_FileServerVssAgent_init(&fss_cb);
+       DBG_INFO("Initializing DCE/RPC registered endpoint servers\n");
+
+       status = dcesrv_init_ep_server(dce_ctx, "FileServerVssAgent");
        if (!NT_STATUS_IS_OK(status)) {
-               DEBUG(0, ("Failed to register fssd rpc interface! (%s)\n",
-                         nt_errstr(status)));
+               DBG_ERR("Failed to init DCE/RPC endpoint server: %s\n",
+                       nt_errstr(status));
                exit(1);
        }