s3:mdssvc: fix service startup in deamon mode
authorRalph Boehme <slow@samba.org>
Tue, 20 Aug 2019 15:00:49 +0000 (17:00 +0200)
committerRalph Boehme <slow@samba.org>
Wed, 9 Oct 2019 14:35:29 +0000 (14:35 +0000)
Changes:

* Don't initialize the RPC service by calling setup_rpc_module() in the parent
  mdssd. This is not needed in the parent, only in the worker childs.

* In the worker childs call setup_rpc_module() instead of init_rpc_module()
  which ensures rpc_mdssvc_init() is called with the mdssvc callback which is
  needed to initialize mdssvc via mdssvc_init_cb() -> init_service_mdssvc()

* Finally rpc_setup_mdssvc() is adjusted to be a noop if mdssvc is configured to
  as external and when called by the main parent smbd via dcesrv_ep_setup() ->
  setup_rpc_modules()

I've manually tested all 4 combinations of external=yes|no X module=yes|no with
the new mdfind command.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
source3/rpc_server/mdssd.c
source3/rpc_server/mdssvc/srv_mdssvc_nt.c

index 06643664f2ed98dfe62386710c37d1fb1f954bbc..6f2635c65196eebf4bd6c37bf7d38a8e1367df71 100644 (file)
@@ -222,7 +222,7 @@ static bool mdssd_child_init(struct tevent_context *ev_ctx,
        messaging_register(msg_ctx, ev_ctx,
                           MSG_PREFORK_PARENT_EVENT, parent_ping);
 
-       ok = init_rpc_module("mdssvc", NULL);
+       ok = setup_rpc_module(ev_ctx, msg_ctx, "mdssvc");
        if (!ok) {
                DBG_ERR("Failed to initialize mdssvc module\n");
                return false;
@@ -695,11 +695,6 @@ void start_mdssd(struct tevent_context *ev_ctx,
        messaging_register(msg_ctx, ev_ctx,
                           MSG_PREFORK_CHILD_EVENT, child_ping);
 
-       ok = setup_rpc_module(ev_ctx, msg_ctx, "mdssvc");
-       if (!ok) {
-               exit(1);
-       }
-
        ok = mdssd_setup_children_monitor(ev_ctx, msg_ctx);
        if (!ok) {
                exit(1);
index 345e05be912ab95c534c741cd8db4ff85d20637a..0977c12e98d387c5729f17cde1f1c01dff3b68d2 100644 (file)
@@ -29,6 +29,7 @@
 #include "libcli/security/dom_sid.h"
 #include "gen_ndr/auth.h"
 #include "mdssvc.h"
+#include "smbd/globals.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_RPC_SRV
@@ -65,6 +66,11 @@ static bool rpc_setup_mdssvc(struct tevent_context *ev_ctx,
        enum rpc_daemon_type_e mdssvc_type = rpc_mdssd_daemon();
        bool external = service_mode != RPC_SERVICE_MODE_EMBEDDED ||
                        mdssvc_type != RPC_DAEMON_EMBEDDED;
+       bool in_mdssd = external && am_parent == NULL;
+
+       if (external && !in_mdssd) {
+               return true;
+       }
 
        mdssvc_cb.init         = mdssvc_init_cb;
        mdssvc_cb.shutdown     = mdssvc_shutdown_cb;