s3-winbindd: Register winbindd with irpc
authorAndrew Bartlett <abartlet@samba.org>
Tue, 6 May 2014 01:39:12 +0000 (13:39 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 11 Jun 2014 08:18:26 +0000 (10:18 +0200)
Change-Id: Ie3c7109fef6982d95e8cad06870334565352e329
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source3/winbindd/winbindd.c
source3/winbindd/winbindd_proto.h
source3/wscript_build

index a1647c947fab0c4d396e4e9afc2a54965e10bfc2..8a2c09e5158e3c9a815da7c32c26eb40ea07719a 100644 (file)
@@ -39,6 +39,9 @@
 #include "messages.h"
 #include "../lib/util/pidfile.h"
 #include "util_cluster.h"
+#include "source4/lib/messaging/irpc.h"
+#include "source4/lib/messaging/messaging.h"
+#include "lib/param/param.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_WINBIND
@@ -89,6 +92,33 @@ struct messaging_context *winbind_messaging_context(void)
        return msg;
 }
 
+struct imessaging_context *winbind_imessaging_context(void)
+{
+       static struct imessaging_context *msg = NULL;
+       struct loadparm_context *lp_ctx;
+
+       if (msg != NULL) {
+               return msg;
+       }
+
+       lp_ctx = loadparm_init_s3(NULL, loadparm_s3_helpers());
+       if (lp_ctx == NULL) {
+               smb_panic("Could not load smb.conf to init winbindd's imessaging context.\n");
+       }
+
+       /*
+        * Note we MUST use the NULL context here, not the autofree context,
+        * to avoid side effects in forked children exiting.
+        */
+       msg = imessaging_init(NULL, lp_ctx, procid_self(), winbind_event_context(), false);
+       talloc_unlink(NULL, lp_ctx);
+
+       if (msg == NULL) {
+               smb_panic("Could not init winbindd's messaging context.\n");
+       }
+       return msg;
+}
+
 /* Reload configuration */
 
 static bool reload_services_file(const char *lfile)
@@ -1588,6 +1618,8 @@ int main(int argc, const char **argv)
                exit_daemon("Winbindd failed to setup listeners", EPIPE);
        }
 
+       irpc_add_name(winbind_imessaging_context(), "winbind_server");
+
        TALLOC_FREE(frame);
 
        if (!interactive) {
index 65553f70ed232798398b3aa9ac490176cb8d788b..642aadd440d7349b905596a458cde6a332a266d3 100644 (file)
@@ -27,6 +27,7 @@
 
 /* The following definitions come from winbindd/winbindd.c  */
 struct messaging_context *winbind_messaging_context(void);
+struct imessaging_context *winbind_imessaging_context(void);
 void request_error(struct winbindd_cli_state *state);
 void request_ok(struct winbindd_cli_state *state);
 bool winbindd_setup_sig_term_handler(bool parent);
index b1a25d325ed8815687ce1bf9665178d6951fca1c..806a49712c28c6f5cebb7681c76c897f0ae23ab1 100755 (executable)
@@ -970,6 +970,7 @@ bld.SAMBA3_BINARY('winbindd/winbindd',
                  RPC_SERVER
                  WB_REQTRANS
                  TDB_VALIDATE
+                 MESSAGING
                  ''',
                  enabled=bld.env.build_winbind,
                  install_path='${SBINDIR}')