s3:rpc_server: make it possible to build mdssvc as a shared module
authorRalph Boehme <slow@samba.org>
Tue, 6 Oct 2015 11:45:33 +0000 (13:45 +0200)
committerRalph Boehme <slow@samba.org>
Sun, 21 Feb 2016 21:28:41 +0000 (22:28 +0100)
Allow building mdssvc RPC service as shared module:

  --with-shared-modules=rpc_mdssvc_module

The default is to build it static.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Ralph B√∂hme <slow@samba.org>
Autobuild-Date(master): Sun Feb 21 22:28:41 CET 2016 on sn-devel-144

source3/rpc_server/mdssd.c
source3/rpc_server/mdssvc/srv_mdssvc_nt.c
source3/rpc_server/rpc_service_setup.c
source3/rpc_server/wscript_build
source3/wscript

index f76d13eda33e509a9f3bf707a9f1fba4781dd4a0..e4c12cdea4676c135171ec38ee685b01075ca5ae 100644 (file)
@@ -34,6 +34,7 @@
 #include "rpc_server/rpc_server.h"
 #include "rpc_server/rpc_ep_register.h"
 #include "rpc_server/rpc_sock_helper.h"
+#include "rpc_server/rpc_modules.h"
 
 #include "librpc/gen_ndr/srv_mdssvc.h"
 #include "rpc_server/mdssvc/srv_mdssvc_nt.h"
@@ -91,7 +92,7 @@ static void mdssd_sig_term_handler(struct tevent_context *ev,
                                   void *siginfo,
                                   void *private_data)
 {
-       rpc_mdssvc_shutdown();
+       shutdown_rpc_module("mdssvc");
 
        DEBUG(0, ("termination signal\n"));
        exit(0);
@@ -228,10 +229,9 @@ static bool mdssd_child_init(struct tevent_context *ev_ctx,
        messaging_register(msg_ctx, ev_ctx,
                           MSG_PREFORK_PARENT_EVENT, parent_ping);
 
-       status = rpc_mdssvc_init(NULL);
-       if (!NT_STATUS_IS_OK(status)) {
-               DEBUG(0, ("Failed to intialize RPC: %s\n",
-                         nt_errstr(status)));
+       ok = init_rpc_module("mdssvc", NULL);
+       if (!ok) {
+               DBG_ERR("Failed to de-intialize RPC\n");
                return false;
        }
 
@@ -608,27 +608,6 @@ done:
        return ok;
 }
 
-static bool mdssvc_init_cb(void *ptr)
-{
-       struct messaging_context *msg_ctx =
-               talloc_get_type_abort(ptr, struct messaging_context);
-       bool ok;
-
-       ok = init_service_mdssvc(msg_ctx);
-       if (!ok) {
-               return false;
-       }
-
-       return true;
-}
-
-static bool mdssvc_shutdown_cb(void *ptr)
-{
-       shutdown_service_mdssvc();
-
-       return true;
-}
-
 void start_mdssd(struct tevent_context *ev_ctx,
                 struct messaging_context *msg_ctx)
 {
@@ -638,7 +617,6 @@ void start_mdssd(struct tevent_context *ev_ctx,
        pid_t pid;
        int rc;
        bool ok;
-       struct rpc_srv_callbacks mdssvc_cb;
 
        DEBUG(1, ("Forking Metadata Service Daemon\n"));
 
@@ -720,12 +698,8 @@ void start_mdssd(struct tevent_context *ev_ctx,
        messaging_register(msg_ctx, ev_ctx,
                           MSG_PREFORK_CHILD_EVENT, child_ping);
 
-       mdssvc_cb.init         = mdssvc_init_cb;
-       mdssvc_cb.shutdown     = mdssvc_shutdown_cb;
-       mdssvc_cb.private_data = msg_ctx;
-
-       status = rpc_mdssvc_init(&mdssvc_cb);
-       if (!NT_STATUS_IS_OK(status)) {
+       ok = setup_rpc_module(ev_ctx, msg_ctx, "mdssvc");
+       if (!ok) {
                exit(1);
        }
 
index cb0d759be1b9fd438dc0f44da9bd4ed17a92b0c8..37b13e79a0bbee8af8975bfe114efd3646eccb72 100644 (file)
@@ -19,6 +19,9 @@
 
 #include "includes.h"
 #include "ntdomain.h"
+#include "rpc_server/rpc_service_setup.h"
+#include "rpc_server/rpc_config.h"
+#include "rpc_server/rpc_modules.h"
 #include "rpc_server/mdssvc/srv_mdssvc_nt.h"
 #include "../librpc/gen_ndr/srv_mdssvc.h"
 #include "libcli/security/security_token.h"
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_RPC_SRV
 
+static bool mdssvc_init_cb(void *ptr)
+{
+       struct messaging_context *msg_ctx =
+               talloc_get_type_abort(ptr, struct messaging_context);
+       bool ok;
+
+       ok = init_service_mdssvc(msg_ctx);
+       if (!ok) {
+               return false;
+       }
+
+       return true;
+}
+
+static bool mdssvc_shutdown_cb(void *ptr)
+{
+       shutdown_service_mdssvc();
+
+       return true;
+}
+
+static bool rpc_setup_mdssvc(struct tevent_context *ev_ctx,
+                            struct messaging_context *msg_ctx)
+{
+       const struct ndr_interface_table *t = &ndr_table_mdssvc;
+       const char *pipe_name = "mdssvc";
+       struct rpc_srv_callbacks mdssvc_cb;
+       NTSTATUS status;
+       enum rpc_service_mode_e service_mode = rpc_service_mode(t->name);
+       enum rpc_daemon_type_e mdssvc_type = rpc_mdssd_daemon();
+
+       mdssvc_cb.init         = mdssvc_init_cb;
+       mdssvc_cb.shutdown     = mdssvc_shutdown_cb;
+       mdssvc_cb.private_data = msg_ctx;
+
+       status = rpc_mdssvc_init(&mdssvc_cb);
+       if (!NT_STATUS_IS_OK(status)) {
+               return false;
+       }
+
+       if (service_mode != RPC_SERVICE_MODE_EMBEDDED
+           || mdssvc_type != RPC_DAEMON_EMBEDDED) {
+               return true;
+       }
+
+       return rpc_setup_embedded(ev_ctx, msg_ctx, t, pipe_name);
+}
+
+static struct rpc_module_fns rpc_module_mdssvc_fns = {
+       .setup = rpc_setup_mdssvc,
+       .init = rpc_mdssvc_init,
+       .shutdown = rpc_mdssvc_shutdown,
+};
+
+static_decl_rpc;
+NTSTATUS rpc_mdssvc_module_init(void)
+{
+       DBG_DEBUG("Registering mdsvc RPC service\n");
+
+       return register_rpc_module(&rpc_module_mdssvc_fns, "mdssvc");
+}
+
+
 bool init_service_mdssvc(struct messaging_context *msg_ctx)
 {
        return mds_init(msg_ctx);
index 3a4c0b08844e8c9b3cf5b56970cc44f4f52520db..e1625ee165c3e48b9cc0dcb03eee2da7862952c3 100644 (file)
 #include "../librpc/gen_ndr/srv_spoolss.h"
 #include "../librpc/gen_ndr/srv_svcctl.h"
 #include "../librpc/gen_ndr/srv_wkssvc.h"
-#include "../librpc/gen_ndr/srv_mdssvc.h"
 
 #include "printing/nt_printing_migrate_internal.h"
 #include "rpc_server/eventlog/srv_eventlog_reg.h"
 #include "rpc_server/svcctl/srv_svcctl_reg.h"
 #include "rpc_server/spoolss/srv_spoolss_nt.h"
 #include "rpc_server/svcctl/srv_svcctl_nt.h"
-#include "rpc_server/mdssvc/srv_mdssvc_nt.h"
 
 #include "librpc/rpc/dcerpc_ep.h"
 #include "rpc_server/rpc_sock_helper.h"
@@ -448,56 +446,6 @@ static bool rpc_setup_initshutdown(struct tevent_context *ev_ctx,
        return rpc_setup_embedded(ev_ctx, msg_ctx, t, NULL);
 }
 
-#ifdef WITH_SPOTLIGHT
-static bool mdssvc_init_cb(void *ptr)
-{
-       struct messaging_context *msg_ctx =
-               talloc_get_type_abort(ptr, struct messaging_context);
-       bool ok;
-
-       ok = init_service_mdssvc(msg_ctx);
-       if (!ok) {
-               return false;
-       }
-
-       return true;
-}
-
-static bool mdssvc_shutdown_cb(void *ptr)
-{
-       shutdown_service_mdssvc();
-
-       return true;
-}
-
-static bool rpc_setup_mdssvc(struct tevent_context *ev_ctx,
-                            struct messaging_context *msg_ctx)
-{
-       const struct ndr_interface_table *t = &ndr_table_mdssvc;
-       const char *pipe_name = "mdssvc";
-       struct rpc_srv_callbacks mdssvc_cb;
-       NTSTATUS status;
-       enum rpc_service_mode_e service_mode = rpc_service_mode(t->name);
-       enum rpc_daemon_type_e mdssvc_type = rpc_mdssd_daemon();
-
-       if (service_mode != RPC_SERVICE_MODE_EMBEDDED
-           || mdssvc_type != RPC_DAEMON_EMBEDDED) {
-               return true;
-       }
-
-       mdssvc_cb.init         = mdssvc_init_cb;
-       mdssvc_cb.shutdown     = mdssvc_shutdown_cb;
-       mdssvc_cb.private_data = msg_ctx;
-
-       status = rpc_mdssvc_init(&mdssvc_cb);
-       if (!NT_STATUS_IS_OK(status)) {
-               return false;
-       }
-
-       return rpc_setup_embedded(ev_ctx, msg_ctx, t, pipe_name);
-}
-#endif
-
 bool dcesrv_ep_setup(struct tevent_context *ev_ctx,
                     struct messaging_context *msg_ctx)
 {
@@ -582,13 +530,6 @@ bool dcesrv_ep_setup(struct tevent_context *ev_ctx,
                goto done;
        }
 
-#ifdef WITH_SPOTLIGHT
-       ok = rpc_setup_mdssvc(ev_ctx, msg_ctx);
-       if (!ok) {
-               goto done;
-       }
-#endif
-
        /* Initialize static subsystems */
        static_init_rpc;
 
index ae4c0613c1f0decba4cccd89a2bc8ce9fd43c29a..1d0facb47c70292b758682dfd511ecce153e6a63 100755 (executable)
@@ -128,17 +128,21 @@ bld.SAMBA3_SUBSYSTEM('RPC_WKSSVC',
                     ../../librpc/gen_ndr/srv_wkssvc.c''',
                     deps='LIBNET')
 
-bld.SAMBA3_SUBSYSTEM('RPC_MDSSVC',
-                    source='''mdssvc/mdssvc.c
-                    mdssvc/dalloc.c
-                    mdssvc/marshalling.c
-                    mdssvc/sparql_mapping.c
-                    mdssvc/sparql_parser.c
-                    mdssvc/sparql_lexer.c
-                    mdssvc/srv_mdssvc_nt.c
-                    ../../librpc/gen_ndr/srv_mdssvc.c''',
-                    deps='samba-util ' + bld.env['libtracker'],
-                    enabled=bld.env.with_spotlight)
+bld.SAMBA3_MODULE('rpc_mdssvc_module',
+                  subsystem='rpc',
+                  allow_undefined_symbols=True,
+                  source='''mdssvc/mdssvc.c
+                  mdssvc/dalloc.c
+                  mdssvc/marshalling.c
+                  mdssvc/sparql_mapping.c
+                  mdssvc/sparql_parser.c
+                  mdssvc/sparql_lexer.c
+                  mdssvc/srv_mdssvc_nt.c
+                  ../../librpc/gen_ndr/srv_mdssvc.c''',
+                  init_function='',
+                  deps='samba-util ' + bld.env['libtracker'],
+                  internal_module=bld.SAMBA3_IS_STATIC_MODULE('rpc_mdssvc_module'),
+                  enabled=bld.SAMBA3_IS_ENABLED_MODULE('rpc_mdssvc_module'))
 
 # RPC_SERVICE
 bld.SAMBA3_SUBSYSTEM('RPC_SERVER_REGISTER',
@@ -168,7 +172,6 @@ bld.SAMBA3_SUBSYSTEM('RPC_SERVICE',
                     RPC_SERVER
                     RPC_EPMAPPER
                    RPC_FSS_AGENT
-                    RPC_MDSSVC
                     ''')
 
 # RPC_DAEMONS
@@ -189,6 +192,6 @@ bld.SAMBA3_SUBSYSTEM('FSSD',
                     deps='samba-util')
 
 bld.SAMBA3_SUBSYSTEM('MDSSD',
-                    source='mdssd.c',
+                    source='mdssd.c rpc_modules.c',
                     deps='RPC_SOCK_HELPER samba-util',
                     enabled=bld.env.with_spotlight)
index b65e3eb0cb7aaa6b2bb6e75daba0cda9b24073a1..c6504c64171c2f765953cb7e9ce5c7154f45b434 100644 (file)
@@ -1562,6 +1562,7 @@ main() {
         if not conf.env.with_spotlight:
             conf.fatal("Spotlight support requested but tracker-sparql library missing")
         Logs.info("building with Spotlight support")
+        default_static_modules.extend(TO_LIST('rpc_mdssvc_module'))
 
     forced_static_modules.extend(TO_LIST('auth_domain auth_builtin auth_sam auth_winbind'))
     default_static_modules.extend(TO_LIST('''pdb_smbpasswd pdb_tdbsam pdb_wbc_sam