smbd/winbindd: Do an early check if ctdbd is functional
[mat/samba.git] / source3 / winbindd / winbindd.c
index 31280c216b86e4784e73ff6a245f40888d61fa62..b8b9c21170f56f332e9e2e1b88dfa2a4dc29235c 100644 (file)
@@ -37,6 +37,7 @@
 #include "auth.h"
 #include "messages.h"
 #include "../lib/util/pidfile.h"
+#include "ctdbd_conn.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_WINBIND
@@ -1464,6 +1465,17 @@ int main(int argc, char **argv, char **envp)
                exit(1);
        }
 
+       if (lp_clustering()) {
+               NTSTATUS status;
+
+               status = ctdbd_probe();
+               if (!NT_STATUS_IS_OK(status)) {
+                       DEBUG(0, ("clustering=yes but ctdbd connect failed: "
+                                 "%s\n", nt_errstr(status)));
+                       exit(1);
+               }
+       }
+
        /* Initialise messaging system */
 
        if (winbind_messaging_context() == NULL) {