s4:lib/tevent: rename structs
[kamenim/samba.git] / source4 / smbd / server.c
index dd63ca1ecabd5901a514bed36aba67eb986624d0..c1683a48dcf77eca25bc89ca63ab2043c358dad2 100644 (file)
@@ -28,7 +28,6 @@
 #include "lib/cmdline/popt_common.h"
 #include "system/dir.h"
 #include "system/filesys.h"
-#include "build.h"
 #include "ldb/include/ldb.h"
 #include "registry/registry.h"
 #include "ntvfs/ntvfs.h"
@@ -38,7 +37,6 @@
 #include "smbd/service.h"
 #include "param/secrets.h"
 #include "smbd/pidfile.h"
-#include "cluster/ctdb/ctdb_cluster.h"
 #include "param/param.h"
 
 /*
@@ -150,7 +148,7 @@ static void setup_signals(void)
 /*
   handle io on stdin
 */
-static void server_stdin_handler(struct event_context *event_ctx, struct fd_event *fde, 
+static void server_stdin_handler(struct tevent_context *event_ctx, struct tevent_fd *fde, 
                                 uint16_t flags, void *private)
 {
        const char *binary_name = (const char *)private;
@@ -169,8 +167,8 @@ static void server_stdin_handler(struct event_context *event_ctx, struct fd_even
 /*
   die if the user selected maximum runtime is exceeded
 */
-_NORETURN_ static void max_runtime_handler(struct event_context *ev, 
-                                          struct timed_event *te, 
+_NORETURN_ static void max_runtime_handler(struct tevent_context *ev, 
+                                          struct tevent_timer *te, 
                                           struct timeval t, void *private)
 {
        const char *binary_name = (const char *)private;
@@ -187,9 +185,24 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[
        bool opt_interactive = false;
        int opt;
        poptContext pc;
+       extern NTSTATUS server_service_wrepl_init(void);
+       extern NTSTATUS server_service_kdc_init(void);
+       extern NTSTATUS server_service_ldap_init(void);
+       extern NTSTATUS server_service_web_init(void);
+       extern NTSTATUS server_service_ldap_init(void);
+       extern NTSTATUS server_service_winbind_init(void);
+       extern NTSTATUS server_service_nbtd_init(void);
+       extern NTSTATUS server_service_auth_init(void);
+       extern NTSTATUS server_service_cldapd_init(void);
+       extern NTSTATUS server_service_smb_init(void);
+       extern NTSTATUS server_service_drepl_init(void);
+       extern NTSTATUS server_service_rpc_init(void);
+       extern NTSTATUS server_service_ntp_signd_init(void);
+       extern NTSTATUS server_service_samba3_smb_init(void);
        init_module_fn static_init[] = { STATIC_service_MODULES };
        init_module_fn *shared_init;
-       struct event_context *event_ctx;
+       struct tevent_context *event_ctx;
+       uint16_t stdin_event_flags;
        NTSTATUS status;
        const char *model = "standard";
        int max_runtime = 0;
@@ -253,7 +266,7 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[
        umask(0);
 
        DEBUG(0,("%s version %s started.\n", binary_name, SAMBA_VERSION_STRING));
-       DEBUGADD(0,("Copyright Andrew Tridgell and the Samba Team 1992-2007\n"));
+       DEBUGADD(0,("Copyright Andrew Tridgell and the Samba Team 1992-2008\n"));
 
        if (sizeof(uint16_t) < 2 || sizeof(uint32_t) < 4 || sizeof(uint64_t) < 8) {
                DEBUG(0,("ERROR: Samba is not configured correctly for the word size on your machine\n"));
@@ -278,12 +291,10 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[
        /* Do *not* remove this, until you have removed
         * passdb/secrets.c, and proved that Samba still builds... */
        /* Setup the SECRETS subsystem */
-       if (!secrets_init(cmdline_lp_ctx)) {
+       if (secrets_init(talloc_autofree_context(), cmdline_lp_ctx) == NULL) {
                exit(1);
        }
 
-       share_init();
-
        gensec_init(cmdline_lp_ctx); /* FIXME: */
 
        ntptr_init(cmdline_lp_ctx);     /* FIXME: maybe run this in the initialization function 
@@ -303,26 +314,28 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[
        
        /* the event context is the top level structure in smbd. Everything else
           should hang off that */
-       event_ctx = event_context_init(talloc_autofree_context());
+       event_ctx = s4_event_context_init(talloc_autofree_context());
 
        if (event_ctx == NULL) {
                DEBUG(0,("Initializing event context failed\n"));
                return 1;
        }
 
-       /* initialise clustering if needed */
-       cluster_ctdb_init(cmdline_lp_ctx, event_ctx, model);
-
        if (opt_interactive) {
-               /* catch EOF on stdin */
-#ifdef SIGTTIN
-               signal(SIGTTIN, SIG_IGN);
-#endif
-               event_add_fd(event_ctx, event_ctx, 0, EVENT_FD_READ, 
-                            server_stdin_handler,
-                            discard_const(binary_name));
+               /* terminate when stdin goes away */
+               stdin_event_flags = EVENT_FD_READ;
+       } else {
+               /* stay alive forever */
+               stdin_event_flags = 0;
        }
 
+       /* catch EOF on stdin */
+#ifdef SIGTTIN
+       signal(SIGTTIN, SIG_IGN);
+#endif
+       event_add_fd(event_ctx, event_ctx, 0, stdin_event_flags,
+                    server_stdin_handler,
+                    discard_const(binary_name));
 
        if (max_runtime) {
                event_add_timed(event_ctx, event_ctx,