s4:s3compat Change when we start up s3compat
authorAndrew Bartlett <abartlet@samba.org>
Thu, 13 May 2010 07:04:52 +0000 (17:04 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 3 Jun 2010 01:14:06 +0000 (11:14 +1000)
This allows the s3compat code to run things that need an event
context, and also changes us to use a slightly safer way to cross into
s3compat from winbind.

Andrew Bartlett

source4/s3compat/s3_winbind.c
source4/smbd/server.c

index 8691782734a24818f56bd88ff4a1c5a5f87670ef..be2ce250263fc8f179d7ebc5446ffb67957c57b4 100644 (file)
@@ -23,6 +23,7 @@
 #include "includes.h"
 #include "winbind/wb_server.h"
 #include "smbd/service_task.h"
+#include "smbd/process_model.h"
 
 #include "s3compat_wrapper.h"
 #include "s3replace.h"
 
 _PUBLIC_ void s3compat_winbind_task_init(struct task_server *task) 
 {
-        winbind_prepare_task(task, task->model_ops);
+       if (lp_parm_bool(task->lp_ctx, NULL, "s3compat", "gdb-winbind", false)) {
+               char *cmd = talloc_asprintf(task, "xterm -e \"gdb --pid %u\"&", getpid());
+               system(cmd);
+               sleep(2);
+       }
+
+       winbind_prepare_task(task, task->model_ops);
        s3compat_set_tevent_ctx(task->event_ctx);
        s3compat_set_lp_ctx(task->lp_ctx);
        s3compat_set_msg_ctx(task->msg_ctx);
        s3compat_initialise_winbindd(lp_configfile(task->lp_ctx));
 }
 
+_PUBLIC_ void s3compat_winbind_accept(struct stream_connection *conn)
+{
+       struct wbsrv_listen_socket *wbsrv_socket = talloc_get_type(conn->private_data,
+                                                                  struct wbsrv_listen_socket);
+       s3compat_winbindd_accepted_new_connection(socket_get_fd(conn->socket),
+                                                 wbsrv_socket->privileged);
+       return;
+}
index 5a3a2903bb69d25066c4c2e8c207390b7c74d1f1..337eb214349f6f817fcd2a2d2fced7798ae573eb 100644 (file)
@@ -42,6 +42,7 @@
 #include "cluster/cluster.h"
 #include "dynconfig/dynconfig.h"
 #include "s3compat/s3compat.h"
+#include "s3compat/s3compat_globals.h"
 
 /*
   recursively delete a directory tree
@@ -374,10 +375,6 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[
        DEBUG(0,("%s version %s started.\n", binary_name, SAMBA_VERSION_STRING));
        DEBUGADD(0,("Copyright Andrew Tridgell and the Samba Team 1992-2010\n"));
 
-#ifdef ENABLE_S3COMPAT
-       s3compat_initialise(lp_configfile(cmdline_lp_ctx), opt_interactive);
-#endif
-
        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"));
                DEBUGADD(0,("sizeof(uint16_t) = %u, sizeof(uint32_t) %u, sizeof(uint64_t) = %u\n",
@@ -437,6 +434,11 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[
        /* setup this as the default context */
        s4_event_context_set_default(event_ctx);
 
+#ifdef ENABLE_S3COMPAT
+       s3compat_set_tevent_ctx(event_ctx);
+       s3compat_initialise(lp_configfile(cmdline_lp_ctx), opt_interactive);
+#endif
+
        if (event_ctx == NULL) {
                DEBUG(0,("Initializing event context failed\n"));
                return 1;