r7633: this patch started as an attempt to make the dcerpc code use a given
authorAndrew Tridgell <tridge@samba.org>
Thu, 16 Jun 2005 11:36:09 +0000 (11:36 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:18:15 +0000 (13:18 -0500)
event_context for the socket_connect() call, so that when things that
use dcerpc are running alongside anything else it doesn't block the
whole process during a connect.

Then of course I needed to change any code that created a dcerpc
connection (such as the auth code) to also take an event context, and
anything that called that and so on .... thus the size of the patch.

There were 3 places where I punted:

  - abartlet wanted me to add a gensec_set_event_context() call
    instead of adding it to the gensec init calls. Andrew, my
    apologies for not doing this. I didn't do it as adding a new
    parameter allowed me to catch all the callers with the
    compiler. Now that its done, we could go back and use
    gensec_set_event_context()

  - the ejs code calls auth initialisation, which means it should pass
    in the event context from the web server. I punted on that. Needs fixing.

  - I used a NULL event context in dcom_get_pipe(). This is equivalent
    to what we did already, but should be fixed to use a callers event
    context. Jelmer, can you think of a clean way to do that?

I also cleaned up a couple of things:

 - libnet_context_destroy() makes no sense. I removed it.

 - removed some unused vars in various places

65 files changed:
source/auth/auth.c
source/auth/auth.h
source/auth/auth_domain.c
source/auth/gensec/gensec.c
source/auth/gensec/gensec.h
source/auth/ntlmssp/ntlmssp_server.c
source/client/client.c
source/client/smbspool.c
source/gtk/tools/gepdump.c
source/gtk/tools/gregedit.c
source/gtk/tools/gwcrontab.c
source/gtk/tools/gwsam.c
source/ldap_server/ldap_bind.c
source/lib/com/com.h
source/lib/com/dcom/main.c
source/lib/com/main.c
source/lib/registry/reg_backend_rpc.c
source/lib/registry/tools/regdiff.c
source/lib/registry/tools/regpatch.c
source/lib/registry/tools/regshell.c
source/lib/registry/tools/regtree.c
source/libcli/cliconnect.c
source/libcli/composite/connect.c
source/libcli/composite/sesssetup.c
source/libcli/ldap/ldap_bind.c
source/libcli/raw/clitree.c
source/libcli/util/clilsa.c
source/libnet/libnet.c
source/libnet/libnet.h
source/libnet/libnet_rpc.c
source/libnet/libnet_vampire.c
source/librpc/rpc/dcerpc.c
source/librpc/rpc/dcerpc.h
source/librpc/rpc/dcerpc_auth.c
source/librpc/rpc/dcerpc_schannel.c
source/librpc/rpc/dcerpc_smb.c
source/librpc/rpc/dcerpc_sock.c
source/librpc/rpc/dcerpc_util.c
source/rpc_server/dcesrv_auth.c
source/rpc_server/netlogon/dcerpc_netlogon.c
source/rpc_server/remote/dcesrv_remote.c
source/scripting/ejs/smbcalls.c
source/scripting/ejs/smbcalls_cli.c
source/smb_server/negprot.c
source/smb_server/sesssetup.c
source/torture/auth/ntlmssp.c
source/torture/com/simple.c
source/torture/gentest.c
source/torture/libnet/libnet_user.c
source/torture/locktest.c
source/torture/locktest2.c
source/torture/masktest.c
source/torture/rpc/mgmt.c
source/torture/rpc/samlogon.c
source/torture/rpc/samsync.c
source/torture/rpc/scanner.c
source/torture/rpc/schannel.c
source/torture/rpc/xplogin.c
source/torture/torture.c
source/utils/net/net_join.c
source/utils/net/net_password.c
source/utils/net/net_time.c
source/utils/net/net_user.c
source/utils/net/net_vampire.c
source/utils/ntlm_auth.c

index 674e9a7f461eb6d379b217e5448526461ca3cf98..dab1912d8e03878e56fffca5accc9126482f9fee 100644 (file)
@@ -22,6 +22,7 @@
 #include "includes.h"
 #include "dlinklist.h"
 #include "auth/auth.h"
+#include "lib/events/events.h"
 
 /***************************************************************************
  Set a fixed challenge
@@ -199,7 +200,9 @@ NTSTATUS auth_check_password(struct auth_context *auth_ctx,
 /***************************************************************************
  Make a auth_info struct for the auth subsystem
 ***************************************************************************/
-NTSTATUS auth_context_create(TALLOC_CTX *mem_ctx, const char **methods, struct auth_context **auth_ctx) 
+NTSTATUS auth_context_create(TALLOC_CTX *mem_ctx, const char **methods, 
+                            struct auth_context **auth_ctx,
+                            struct event_context *ev) 
 {
        int i;
        struct auth_context *ctx;
@@ -215,6 +218,16 @@ NTSTATUS auth_context_create(TALLOC_CTX *mem_ctx, const char **methods, struct a
        ctx->challenge.may_be_modified  = False;
        ctx->challenge.data             = data_blob(NULL, 0);
        ctx->methods                    = NULL;
+       
+       if (ev == NULL) {
+               ev = event_context_init(ctx);
+               if (ev == NULL) {
+                       talloc_free(ctx);
+                       return NT_STATUS_NO_MEMORY;
+               }
+       }
+
+       ctx->event_ctx = ev;
 
        for (i=0; methods[i] ; i++) {
                struct auth_method_context *method;
index d1f8caa2a01a70b39bd8caff5863f3ab13d11fe0..b4f08b285912d1ec229f8154ae14b34fb5ad8553 100644 (file)
@@ -144,6 +144,9 @@ struct auth_context {
 
        /* methods, in the order they should be called */
        struct auth_method_context *methods;
+
+       /* the event context to use for calls that can block */
+       struct event_context *event_ctx;
 };
 
 /* this structure is used by backends to determine the size of some critical types */
index 041135e4d42007231be006e974a1fcfe4879f78a..339cc185312509bf67d2a0696693e2de5d23418d 100644 (file)
@@ -84,7 +84,7 @@ static NTSTATUS domain_check_password(struct auth_method_context *ctx,
        status = dcerpc_pipe_connect_b(mem_ctx, &p, b, 
                                       DCERPC_NETLOGON_UUID,
                                       DCERPC_NETLOGON_VERSION,
-                                      credentials);
+                                      credentials, ctx->auth_ctx->event_ctx);
 
        if (!NT_STATUS_IS_OK(status)) {
                return status;
index 1608f21114006fcec0cb7f8a54c4bd0166a1b144..d9c264cdd8819db2692c125b2e8b5db10f4891cf 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "includes.h"
 #include "auth/auth.h"
+#include "lib/events/events.h"
 
 /* the list of currently registered GENSEC backends */
 const static struct gensec_security_ops **generic_security_ops;
@@ -228,12 +229,12 @@ const char **gensec_security_oids(TALLOC_CTX *mem_ctx, const char *skip)
   @param gensec_security Returned GENSEC context pointer.
   @note  The mem_ctx is only a parent and may be NULL.
 */
-static NTSTATUS gensec_start(TALLOC_CTX *mem_ctx, struct gensec_security **gensec_security) 
+static NTSTATUS gensec_start(TALLOC_CTX *mem_ctx, 
+                            struct gensec_security **gensec_security,
+                            struct event_context *ev) 
 {
        (*gensec_security) = talloc(mem_ctx, struct gensec_security);
-       if (!(*gensec_security)) {
-               return NT_STATUS_NO_MEMORY;
-       }
+       NT_STATUS_HAVE_NO_MEMORY(*gensec_security);
 
        (*gensec_security)->ops = NULL;
 
@@ -241,6 +242,17 @@ static NTSTATUS gensec_start(TALLOC_CTX *mem_ctx, struct gensec_security **gense
 
        (*gensec_security)->subcontext = False;
        (*gensec_security)->want_features = 0;
+       
+       if (ev == NULL) {
+               ev = event_context_init(*gensec_security);
+               if (ev == NULL) {
+                       talloc_free(*gensec_security);
+                       return NT_STATUS_NO_MEMORY;
+               }
+       }
+
+       (*gensec_security)->event_ctx = ev;
+
        return NT_STATUS_OK;
 }
 
@@ -257,15 +269,14 @@ NTSTATUS gensec_subcontext_start(TALLOC_CTX *mem_ctx,
                                 struct gensec_security **gensec_security)
 {
        (*gensec_security) = talloc(mem_ctx, struct gensec_security);
-       if (!(*gensec_security)) {
-               return NT_STATUS_NO_MEMORY;
-       }
+       NT_STATUS_HAVE_NO_MEMORY(*gensec_security);
 
        (**gensec_security) = *parent;
        (*gensec_security)->ops = NULL;
        (*gensec_security)->private_data = NULL;
 
        (*gensec_security)->subcontext = True;
+       (*gensec_security)->event_ctx = parent->event_ctx;
 
        return NT_STATUS_OK;
 }
@@ -276,10 +287,12 @@ NTSTATUS gensec_subcontext_start(TALLOC_CTX *mem_ctx,
   @param gensec_security Returned GENSEC context pointer.
   @note  The mem_ctx is only a parent and may be NULL.
 */
-NTSTATUS gensec_client_start(TALLOC_CTX *mem_ctx, struct gensec_security **gensec_security)
+NTSTATUS gensec_client_start(TALLOC_CTX *mem_ctx, 
+                            struct gensec_security **gensec_security,
+                            struct event_context *ev)
 {
        NTSTATUS status;
-       status = gensec_start(mem_ctx, gensec_security);
+       status = gensec_start(mem_ctx, gensec_security, ev);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }
@@ -295,10 +308,12 @@ NTSTATUS gensec_client_start(TALLOC_CTX *mem_ctx, struct gensec_security **gense
   @param gensec_security Returned GENSEC context pointer.
   @note  The mem_ctx is only a parent and may be NULL.
 */
-NTSTATUS gensec_server_start(TALLOC_CTX *mem_ctx, struct gensec_security **gensec_security)
+NTSTATUS gensec_server_start(TALLOC_CTX *mem_ctx, 
+                            struct gensec_security **gensec_security,
+                            struct event_context *ev)
 {
        NTSTATUS status;
-       status = gensec_start(mem_ctx, gensec_security);
+       status = gensec_start(mem_ctx, gensec_security, ev);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }
index be6731abfa9d45c7ebd5f38619644868ed1e57d0..2951e13dd91c65d36f044faf934423af097af373 100644 (file)
@@ -109,6 +109,7 @@ struct gensec_security {
        enum gensec_role gensec_role;
        BOOL subcontext;
        uint32_t want_features;
+       struct event_context *event_ctx;
 };
 
 /* this structure is used by backends to determine the size of some critical types */
index ab214578dd4849799e1c82840b57767e46ca4488..e50fe58305d95de1b8c88b00ed5b778692a22b14 100644 (file)
@@ -800,7 +800,9 @@ NTSTATUS gensec_ntlmssp_server_start(struct gensec_security *gensec_security)
                gensec_ntlmssp_state->neg_flags |= NTLMSSP_NEGOTIATE_SEAL;
        }
 
-       nt_status = auth_context_create(gensec_ntlmssp_state, lp_auth_methods(), &gensec_ntlmssp_state->auth_context);
+       nt_status = auth_context_create(gensec_ntlmssp_state, lp_auth_methods(), 
+                                       &gensec_ntlmssp_state->auth_context,
+                                       gensec_security->event_ctx);
        NT_STATUS_NOT_OK_RETURN(nt_status);
 
        gensec_ntlmssp_state->get_challenge = auth_ntlmssp_get_challenge;
index afdab5928c26af436860d10a589796fbeafcfbbc..a24fd7bfd368652fb3dd814d0002190d821f3a17 100644 (file)
@@ -2730,7 +2730,7 @@ static BOOL browse_host(const char *query_host)
        status = dcerpc_pipe_connect(mem_ctx, &p, binding, 
                                     DCERPC_SRVSVC_UUID, 
                                     DCERPC_SRVSVC_VERSION,
-                                    cmdline_credentials);
+                                    cmdline_credentials, NULL);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("Failed to connect to %s - %s\n", 
                         binding, nt_errstr(status));
@@ -3220,7 +3220,7 @@ static struct smbcli_state *do_connect(const char *server, const char *share, st
        }
        
        status = smbcli_full_connection(NULL, &c, server,
-                                       share, NULL, cred);
+                                       share, NULL, cred, NULL);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("Connection to \\\\%s\\%s failed - %s\n", 
                         server, share, nt_errstr(status));
index 41cb4c9bf30a53b48502d299e955f7230b470cfe..2e7afc5ec4ecc5890a31d0c7968f0e58564b7e70 100644 (file)
@@ -280,7 +280,7 @@ smb_connect(const char *workgroup,          /* I - Workgroup */
   myname = get_myname();  
        
   nt_status = smbcli_full_connection(NULL, &c, myname, server, 0, share, NULL,
-                                    username, workgroup, password);
+                                    username, workgroup, password, NULL);
   
   free(myname);
   if (!NT_STATUS_IS_OK(nt_status)) {
index 4dacd2937c3bb93cf475526c23605d525b9e9fa3..23d95152f48e43da02d0cce8cdeeef51286464e5 100644 (file)
@@ -197,7 +197,7 @@ static void on_connect_clicked(GtkButton *btn, gpointer         user_data)
 
        status = dcerpc_pipe_connect(talloc_autofree_context(), &epmapper_pipe, bs, 
                                     DCERPC_EPMAPPER_UUID, DCERPC_EPMAPPER_VERSION, 
-                                    credentials);
+                                    credentials, NULL);
 
        if (NT_STATUS_IS_ERR(status)) {
                gtk_show_ntstatus(mainwin, "Error connecting to endpoint mapper", status);
index 72dd9ae929f1127061ef26f0e61d06444ad83af7..27ae925746cb1a98e26afdd56b90c3ad02fa91e9 100644 (file)
@@ -412,8 +412,9 @@ static void on_open_remote_activate(GtkMenuItem *menuitem, gpointer user_data)
        cli_credentials_set_gtk_callbacks(creds);
 
        error = reg_open_remote(&registry, 
-                       creds,
-                       gtk_rpc_binding_dialog_get_binding_string(GTK_RPC_BINDING_DIALOG(rpcwin), mem_ctx));
+                               creds,
+                               gtk_rpc_binding_dialog_get_binding_string(GTK_RPC_BINDING_DIALOG(rpcwin), mem_ctx),
+                               NULL);
 
        if(!W_ERROR_IS_OK(error)) {
                gtk_show_werror(mainwin, "Error while opening remote registry", error);
index eba8b54ac01f36b36bf3ca75904aa6589d09d75b..5b79eafa0aeaf8fcb6d278c9b6a58c81440d1d5d 100644 (file)
@@ -109,7 +109,7 @@ static void on_connect_activate(GtkMenuItem *menuitem, gpointer user_data)
                                       gtk_rpc_binding_dialog_get_binding(d, mem_ctx),
                                       DCERPC_ATSVC_UUID,
                                       DCERPC_ATSVC_VERSION,
-                                      credentials);
+                                      credentials, NULL);
 
        if(!NT_STATUS_IS_OK(status)) {
                gtk_show_ntstatus(mainwin, "Error while connecting to at service", status);
index cf82ddb7678b05bfd4e0328e12aefe65b92d826e..8606cc398f548a5ed42dbd46b17afbcd0cc9a142 100644 (file)
@@ -131,7 +131,7 @@ static void connect_sam(void)
        /* If connected, get list of jobs */
        status = dcerpc_pipe_connect_b(mem_ctx, &sam_pipe,
                                       gtk_rpc_binding_dialog_get_binding(d, mem_ctx),
-                                      DCERPC_SAMR_UUID, DCERPC_SAMR_VERSION, cred );
+                                      DCERPC_SAMR_UUID, DCERPC_SAMR_VERSION, cred, NULL);
 
        if(!NT_STATUS_IS_OK(status)) {
                gtk_show_ntstatus(mainwin, "While connecting to SAMR interface", status);
index 3c51dc2ba56493e85e1f8c52db184be1c000c443..7b416c9726f9d3682acffe00d6484daf604e9bad 100644 (file)
@@ -22,6 +22,7 @@
 #include "ldap_server/ldap_server.h"
 #include "auth/auth.h"
 #include "libcli/ldap/ldap.h"
+#include "smbd/service_stream.h"
 
 static NTSTATUS ldapsrv_BindSimple(struct ldapsrv_call *call)
 {
@@ -63,7 +64,8 @@ static NTSTATUS ldapsrv_BindSASL(struct ldapsrv_call *call)
        if (!call->conn->gensec) {
                call->conn->session_info = NULL;
 
-               status = gensec_server_start(call->conn, &call->conn->gensec);
+               status = gensec_server_start(call->conn, &call->conn->gensec,
+                                            call->conn->connection->event.ctx);
                if (!NT_STATUS_IS_OK(status)) {
                        DEBUG(1, ("Failed to start GENSEC server code: %s\n", nt_errstr(status)));
                        return status;
index 97841e14c389ded1efb5958fdc12b66450069c03..0a26a568b0abedbcd272cf9d9832e1970db77782 100644 (file)
@@ -26,6 +26,7 @@ struct IUnknown_vtable;
 struct com_context 
 {
        struct dcom_client_context *dcom;
+       struct event_context *event_ctx;
 };
 
 typedef struct IUnknown *(*get_class_object_function) (const struct GUID *clsid);
index 08a928cda6b83da67b45194aee144c071a07db12..bc47cb7c688324567d5c3844483516d4a4213652 100644 (file)
@@ -84,7 +84,7 @@ static NTSTATUS dcom_connect_host(struct com_context *ctx, struct dcerpc_pipe **
                return dcerpc_pipe_connect(ctx, p, "ncalrpc", 
                                           DCERPC_IREMOTEACTIVATION_UUID, 
                                           DCERPC_IREMOTEACTIVATION_VERSION,
-                                          ctx->dcom->credentials);
+                                          ctx->dcom->credentials, ctx->event_ctx);
        }
 
        /* Allow server name to contain a binding string */
@@ -92,7 +92,7 @@ static NTSTATUS dcom_connect_host(struct com_context *ctx, struct dcerpc_pipe **
                status = dcerpc_pipe_connect_b(ctx, p, bd, 
                                               DCERPC_IREMOTEACTIVATION_UUID, 
                                               DCERPC_IREMOTEACTIVATION_VERSION, 
-                                                  ctx->dcom->credentials);
+                                              ctx->dcom->credentials, ctx->event_ctx);
 
                talloc_free(mem_ctx);
                return status;
@@ -109,7 +109,7 @@ static NTSTATUS dcom_connect_host(struct com_context *ctx, struct dcerpc_pipe **
                status = dcerpc_pipe_connect(ctx, p, binding, 
                                             DCERPC_IREMOTEACTIVATION_UUID, 
                                             DCERPC_IREMOTEACTIVATION_VERSION, 
-                                                ctx->dcom->credentials);
+                                            ctx->dcom->credentials, ctx->event_ctx);
 
                if (NT_STATUS_IS_OK(status)) {
                        talloc_free(mem_ctx);
@@ -256,7 +256,7 @@ WERROR dcom_get_class_object(struct com_context *ctx, struct GUID *clsid, const
        return WERR_OK;
 }
 
-NTSTATUS dcom_get_pipe (struct IUnknown *iface, struct dcerpc_pipe **pp)
+NTSTATUS dcom_get_pipe(struct IUnknown *iface, struct dcerpc_pipe **pp)
 {
        struct dcerpc_binding *binding;
        struct GUID iid;
@@ -301,9 +301,13 @@ NTSTATUS dcom_get_pipe (struct IUnknown *iface, struct dcerpc_pipe **pp)
                if (!NT_STATUS_IS_OK(status)) {
                        DEBUG(1, ("Error parsing string binding"));
                } else {
+                       /* TODO: jelmer, please look at this. The
+                          "NULL" here should be a real event
+                          context */
                        status = dcerpc_pipe_connect_b(NULL, &p, binding, 
                                                       uuid, 0.0, 
-                                                      iface->ctx->dcom->credentials);
+                                                      iface->ctx->dcom->credentials,
+                                                      NULL);
                }
                talloc_free(binding);
                i++;
index 378c3738b9b40f8208e3879093f3f424b76ed4f9..210e8ba79c39d3060e35c9349bedbb1cde0077a7 100644 (file)
 #include "includes.h"
 #include "dlinklist.h"
 #include "lib/com/com.h"
+#include "lib/events/events.h"
 #include "librpc/gen_ndr/com_dcom.h"
 
-WERROR com_init(struct com_context **ctx)
+WERROR com_init(struct com_context **ctx, struct event_context *event_ctx)
 {
        *ctx = talloc(NULL, struct com_context);
+       if (event_ctx == NULL) {
+               event_ctx = event_context_init(*ctx);
+       }
+       (*ctx)->event_ctx = event_ctx;
        return WERR_OK;
 }
 
index 88cce2584e4cc36112d17f164a70a2c9d868ae2b..3c38b5d312e8ce75a1f43b50df1f8365edd4fb3c 100644 (file)
@@ -362,7 +362,8 @@ static struct hive_operations reg_backend_rpc = {
        .num_values = rpc_num_values,
 };
 
-WERROR reg_open_remote (struct registry_context **ctx, struct cli_credentials *credentials, const char *location)
+WERROR reg_open_remote(struct registry_context **ctx, struct cli_credentials *credentials, 
+                      const char *location, struct event_context *ev)
 {
        NTSTATUS status;
        struct dcerpc_pipe *p;
@@ -378,7 +379,7 @@ WERROR reg_open_remote (struct registry_context **ctx, struct cli_credentials *c
                                     &p, location, 
                                     DCERPC_WINREG_UUID,
                                     DCERPC_WINREG_VERSION,
-                                    credentials);
+                                    credentials, ev);
        (*ctx)->backend_data = p;
 
        if(NT_STATUS_IS_ERR(status)) {
index f86c0ae3834c8474647ac0ae26fe7ce147ac8713..a9d189c03321c610b756920dbb574100e7da598b 100644 (file)
@@ -144,8 +144,10 @@ static void writediff(struct registry_key *oldkey, struct registry_key *newkey,
                        break;
                case 'R':
                        if (!h1 && !from_null) 
-                               error = reg_open_remote(&h1, cmdline_credentials, poptGetOptArg(pc));
-                       else if (!h2) error = reg_open_remote(&h2, cmdline_credentials, poptGetOptArg(pc));
+                               error = reg_open_remote(&h1, cmdline_credentials, 
+                                                       poptGetOptArg(pc), NULL);
+                       else if (!h2) error = reg_open_remote(&h2, cmdline_credentials, 
+                                                             poptGetOptArg(pc), NULL);
                        break;
                }
 
index 02ef4d46555d38c05d198ddaed47f1b95f19c2e7..3ada9f66e257505d625f03589f0752156ef9269f 100644 (file)
@@ -763,7 +763,7 @@ static int nt_apply_reg_command_file(struct registry_context *r, const char *cmd
        }
 
        if (remote) {
-               error = reg_open_remote (&h, cmdline_credentials, remote);
+               error = reg_open_remote (&h, cmdline_credentials, remote, NULL);
        } else {
                error = reg_open_local (&h);
        }
index 0c53f737b8e104b51466d5e8081557d88a3575de..108cc173364b210c764b2e99e92e7aa61993ef56 100644 (file)
@@ -390,7 +390,7 @@ static char **reg_completion(const char *text, int start, int end)
        }
 
        if (remote) {
-               error = reg_open_remote (&h, cmdline_credentials, remote); 
+               error = reg_open_remote (&h, cmdline_credentials, remote, NULL); 
        } else if (backend) {
                error = reg_open_hive(NULL, backend, poptGetArg(pc), NULL, &curkey);
        } else {
index f18467b523750d64555d4895d833f38df764e4c6..2385123b7fccbb82c0d0b4325bef2602cc8cb115 100644 (file)
@@ -99,7 +99,7 @@ static void print_tree(int l, struct registry_key *p, int fullpath, int novals)
        }
 
        if (remote) {
-               error = reg_open_remote(&h, cmdline_credentials, remote);
+               error = reg_open_remote(&h, cmdline_credentials, remote, NULL);
        } else if (backend) {
            error = reg_open_hive(NULL, backend, poptGetArg(pc), NULL, &root);
        } else {
index a866e269704d98c719663c2647fd72ce6212074e..0009151429837729bd5ff24d178b686b2e27498a 100644 (file)
@@ -134,7 +134,8 @@ NTSTATUS smbcli_full_connection(TALLOC_CTX *parent_ctx,
                                const char *host,
                                const char *sharename,
                                const char *devtype,
-                               struct cli_credentials *credentials)
+                               struct cli_credentials *credentials,
+                               struct event_context *ev)
 {
        struct smbcli_tree *tree;
        NTSTATUS status;
@@ -143,7 +144,7 @@ NTSTATUS smbcli_full_connection(TALLOC_CTX *parent_ctx,
 
        status = smbcli_tree_full_connection(parent_ctx,
                                             &tree, host, 0, sharename, devtype,
-                                            credentials);
+                                            credentials, ev);
        if (!NT_STATUS_IS_OK(status)) {
                goto done;
        }
index 9e33a2f7db8b55f58f31f87269824a8a668cb81f..fb439172d0dfcbccb77d84cea9544375a1fe27fd 100644 (file)
@@ -382,8 +382,9 @@ NTSTATUS smb_composite_connect_recv(struct composite_context *c, TALLOC_CTX *mem
 /*
   sync version of smb_composite_connect 
 */
-NTSTATUS smb_composite_connect(struct smb_composite_connect *io, TALLOC_CTX *mem_ctx)
+NTSTATUS smb_composite_connect(struct smb_composite_connect *io, TALLOC_CTX *mem_ctx,
+                              struct event_context *ev)
 {
-       struct composite_context *c = smb_composite_connect_send(io, NULL);
+       struct composite_context *c = smb_composite_connect_send(io, ev);
        return smb_composite_connect_recv(c, mem_ctx);
 }
index ab46c198ef3254ee760a063494b2c459e23ed613..2736d91262feabd992c54ee450a55a08b8569f09 100644 (file)
@@ -263,7 +263,7 @@ static struct smbcli_request *session_setup_spnego(struct composite_context *c,
 
        smbcli_temp_set_signing(session->transport);
 
-       status = gensec_client_start(session, &session->gensec);
+       status = gensec_client_start(session, &session->gensec, c->event_ctx);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(1, ("Failed to start GENSEC client mode: %s\n", nt_errstr(status)));
                return NULL;
index 11a6997fb25a6b1c028fe90d6f57a1beabb6fd2d..ea977982612b252accd3e23372ee7fb9e3678679 100644 (file)
@@ -144,7 +144,7 @@ NTSTATUS ldap_bind_sasl(struct ldap_connection *conn, struct cli_credentials *cr
        DATA_BLOB input = data_blob(NULL, 0);
        DATA_BLOB output = data_blob(NULL, 0);
 
-       status = gensec_client_start(conn, &conn->gensec);
+       status = gensec_client_start(conn, &conn->gensec, NULL);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0, ("Failed to start GENSEC engine (%s)\n", nt_errstr(status)));
                goto failed;
index 87c2dbba7c03f1838caee1b4493b9a5d7f089a84..76cb1a43fe17b1d9a1ff4b676073a694ed8f8daf 100644 (file)
@@ -166,7 +166,8 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx,
                                     struct smbcli_tree **ret_tree, 
                                     const char *dest_host, int port,
                                     const char *service, const char *service_type,
-                                    struct cli_credentials *credentials)
+                                    struct cli_credentials *credentials,
+                                    struct event_context *ev)
 {
        struct smb_composite_connect io;
        NTSTATUS status;
@@ -179,7 +180,7 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx,
        io.in.credentials = credentials;
        io.in.workgroup = lp_workgroup();
        
-       status = smb_composite_connect(&io, parent_ctx);
+       status = smb_composite_connect(&io, parent_ctx, ev);
        if (NT_STATUS_IS_OK(status)) {
                *ret_tree = io.out.tree;
        }
index 0c0c64c0b42a3d545ec9ac6a214551f35adde702..ad2006756b582555d5ee9d348c2852dd7b97a522 100644 (file)
@@ -76,7 +76,7 @@ static NTSTATUS smblsa_connect(struct smbcli_state *cli)
        }
        lsa->ipc_tree->tid = tcon.tconx.out.tid;
 
-       lsa->pipe = dcerpc_pipe_init(lsa);
+       lsa->pipe = dcerpc_pipe_init(lsa, cli->transport->socket->event.ctx);
        if (lsa->pipe == NULL) {
                talloc_free(lsa);
                return NT_STATUS_NO_MEMORY;
index 56b55426c0a4a9f776af8efa199248067d08bf89..5d66005a27a599f93de11b50434c01bb78d86deb 100644 (file)
 
 #include "includes.h"
 #include "libnet/libnet.h"
+#include "lib/events/events.h"
 
-struct libnet_context *libnet_context_init(void)
+struct libnet_context *libnet_context_init(struct event_context *ev)
 {
-       TALLOC_CTX *mem_ctx;
        struct libnet_context *ctx;
 
-       mem_ctx = talloc_init("libnet_context");
-
-       ctx = talloc(mem_ctx, struct libnet_context);
+       ctx = talloc(NULL, struct libnet_context);
        if (!ctx) {
                return NULL;
        }
 
-       ctx->mem_ctx = mem_ctx;
+       if (ev == NULL) {
+               ev = event_context_init(ctx);
+               if (ev == NULL) {
+                       talloc_free(ctx);
+                       return NULL;
+               }
+       }
+       ctx->event_ctx = ev;
 
        return ctx;
 }
 
-void libnet_context_destroy(struct libnet_context **libnetctx)
-{
-       talloc_free((*libnetctx)->mem_ctx);
-
-       (*libnetctx) = NULL;
-}
index b26ce72ba6ea6b6f3584cbe3080bd211e2364bee..092d09599f5f7f394a4a533ca83a926afe741064 100644 (file)
@@ -19,8 +19,6 @@
 */
 
 struct libnet_context {
-       TALLOC_CTX *mem_ctx;
-
        /* here we need:
         * a client env context
         * a user env context
@@ -33,6 +31,8 @@ struct libnet_context {
        /* opened handles */
        struct policy_handle domain_handle;
        struct policy_handle user_handle;
+
+       struct event_context *event_ctx;
 };
 
 
index 30f77843619889a55dbe5721742daad30e85665d..9ed398b3af889ec96f9900aba6d085252d737a7d 100644 (file)
@@ -100,7 +100,7 @@ static NTSTATUS libnet_rpc_connect_standard(struct libnet_context *ctx, TALLOC_C
                                     binding,
                                     r->standard.in.dcerpc_iface_uuid,
                                     r->standard.in.dcerpc_iface_version,
-                                    ctx->cred);
+                                    ctx->cred, ctx->event_ctx);
 
        if (!NT_STATUS_IS_OK(status)) {
                r->standard.out.error_string = talloc_asprintf(mem_ctx, 
index 69bacb7951203821df7e2ab2a6d386fb81d61147..79f07c05f35ac2a0903703933cd20c9c84609636 100644 (file)
@@ -221,7 +221,7 @@ static NTSTATUS libnet_SamSync_netlogon(struct libnet_context *ctx, TALLOC_CTX *
        nt_status = dcerpc_pipe_connect_b(mem_ctx, &p, b, 
                                          DCERPC_NETLOGON_UUID,
                                          DCERPC_NETLOGON_VERSION,
-                                         machine_account);
+                                         machine_account, ctx->event_ctx);
 
        if (!NT_STATUS_IS_OK(nt_status)) {
                return nt_status;
index fa7fe728d44365f811c07efc9d2d9fdd634c7fbc..1f4e72639efdf693368716f88bd1df544c2f3383 100644 (file)
@@ -67,8 +67,11 @@ static int dcerpc_connection_destructor(void *ptr)
 }
 
 
-/* initialise a dcerpc connection. */
-struct dcerpc_connection *dcerpc_connection_init(TALLOC_CTX *mem_ctx)
+/* initialise a dcerpc connection. 
+   the event context is optional
+*/
+struct dcerpc_connection *dcerpc_connection_init(TALLOC_CTX *mem_ctx, 
+                                                struct event_context *ev)
 {
        struct dcerpc_connection *c;
 
@@ -77,6 +80,15 @@ struct dcerpc_connection *dcerpc_connection_init(TALLOC_CTX *mem_ctx)
                return NULL;
        }
 
+       if (ev == NULL) {
+               ev = event_context_init(c);
+               if (ev == NULL) {
+                       talloc_free(c);
+                       return NULL;
+               }
+       }
+
+       c->event_ctx = ev;
        c->call_id = 1;
        c->security_state.auth_info = NULL;
        c->security_state.session_key = dcerpc_generic_session_key;
@@ -93,7 +105,7 @@ struct dcerpc_connection *dcerpc_connection_init(TALLOC_CTX *mem_ctx)
 }
 
 /* initialise a dcerpc pipe. */
-struct dcerpc_pipe *dcerpc_pipe_init(TALLOC_CTX *mem_ctx)
+struct dcerpc_pipe *dcerpc_pipe_init(TALLOC_CTX *mem_ctx, struct event_context *ev)
 {
        struct dcerpc_pipe *p;
 
@@ -102,7 +114,7 @@ struct dcerpc_pipe *dcerpc_pipe_init(TALLOC_CTX *mem_ctx)
                return NULL;
        }
 
-       p->conn = dcerpc_connection_init(p);
+       p->conn = dcerpc_connection_init(p, ev);
        if (p->conn == NULL) {
                talloc_free(p);
                return NULL;
@@ -559,13 +571,12 @@ static NTSTATUS full_request(struct dcerpc_connection *c,
                return status;
        }
 
-       event_add_timed(c->transport.event_context(c), state, 
+       event_add_timed(c->event_ctx, state, 
                        timeval_current_ofs(DCERPC_REQUEST_TIMEOUT, 0), 
                        dcerpc_full_timeout_handler, state);
 
        while (NT_STATUS_IS_OK(state->status) && state->reply_blob) {
-               struct event_context *ctx = c->transport.event_context(c);
-               if (event_loop_once(ctx) != 0) {
+               if (event_loop_once(c->event_ctx) != 0) {
                        return NT_STATUS_CONNECTION_DISCONNECTED;
                }
        }
@@ -850,7 +861,7 @@ static void dcerpc_request_recv_data(struct dcerpc_connection *c,
   handle timeouts of individual dcerpc requests
 */
 static void dcerpc_timeout_handler(struct event_context *ev, struct timed_event *te, 
-                                     struct timeval t, void *private)
+                                  struct timeval t, void *private)
 {
        struct rpc_request *req = talloc_get_type(private, struct rpc_request);
 
@@ -985,7 +996,7 @@ struct rpc_request *dcerpc_request_send(struct dcerpc_pipe *p,
 */
 struct event_context *dcerpc_event_context(struct dcerpc_pipe *p)
 {
-       return p->conn->transport.event_context(p->conn);
+       return p->conn->event_ctx;
 }
 
 
index 2f64c0ef3407cb6e96a48b9285c1747c59c3742f..3b1cc20bca812b350e322f4490eea37b6691ded5 100644 (file)
@@ -48,6 +48,7 @@ struct dcerpc_connection {
        uint_t flags;
        struct dcerpc_security security_state;
        const char *binding_string;
+       struct event_context *event_ctx;
 
        struct dcerpc_transport {
                enum dcerpc_transport_t transport;
@@ -63,9 +64,6 @@ struct dcerpc_connection {
                /* send a read request to the server */
                NTSTATUS (*send_read)(struct dcerpc_connection *);
 
-               /* get an event context for the connection */
-               struct event_context *(*event_context)(struct dcerpc_connection *);
-
                /* a callback to the dcerpc code when a full fragment
                   has been received */
                void (*recv_data)(struct dcerpc_connection *, DATA_BLOB *, NTSTATUS status);
index ae0a89910ea3ac595fe25a5f531d5d5c4825065e..7aa563cb9d12478e731e0c50065a3f4d0d175956 100644 (file)
@@ -51,7 +51,8 @@ NTSTATUS dcerpc_bind_auth(struct dcerpc_pipe *p, uint8_t auth_type, uint8_t auth
        DATA_BLOB null_data_blob = data_blob(NULL, 0);
 
        if (!p->conn->security_state.generic_state) {
-               status = gensec_client_start(p, &p->conn->security_state.generic_state);
+               status = gensec_client_start(p, &p->conn->security_state.generic_state,
+                                            p->conn->event_ctx);
                if (!NT_STATUS_IS_OK(status)) goto done;
 
                status = gensec_start_mech_by_authtype(p->conn->security_state.generic_state, 
@@ -153,7 +154,8 @@ NTSTATUS dcerpc_bind_auth_password(struct dcerpc_pipe *p,
                p->conn->flags |= DCERPC_CONNECT;
        }
 
-       status = gensec_client_start(p, &p->conn->security_state.generic_state);
+       status = gensec_client_start(p, &p->conn->security_state.generic_state,
+                                    p->conn->event_ctx);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(1, ("Failed to start GENSEC client mode: %s\n", nt_errstr(status)));
                return status;
index cc6cbe7b4685209fc7c525f3f6f591e8923ebeb7..1b83b2ec0b1f2e7ea8d6deecb41e5918605dc669 100644 (file)
@@ -64,7 +64,9 @@ static NTSTATUS dcerpc_schannel_key(TALLOC_CTX *tmp_ctx,
        }
 
        /* Make binding string for netlogon, not the other pipe */
-       status = dcerpc_epm_map_binding(tmp_ctx, b, DCERPC_NETLOGON_UUID, DCERPC_NETLOGON_VERSION);
+       status = dcerpc_epm_map_binding(tmp_ctx, b, 
+                                       DCERPC_NETLOGON_UUID, DCERPC_NETLOGON_VERSION,
+                                       p->conn->event_ctx);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0,("Failed to map DCERPC/TCP NCACN_NP pipe for '%s' - %s\n", 
                         DCERPC_NETLOGON_UUID, nt_errstr(status)));
index 1a5a31c330fb69f1a6aab02a55d3b553579f6638..9096168b6449029ab0cd51933b94f52af02ab77b 100644 (file)
@@ -309,18 +309,6 @@ static NTSTATUS smb_send_request(struct dcerpc_connection *c, DATA_BLOB *blob, B
        return NT_STATUS_OK;
 }
 
-/* 
-   return the event context for the pipe, so the caller can wait
-   for events asynchronously
-*/
-static struct event_context *smb_event_context(struct dcerpc_connection *c)
-{
-       struct smb_private *smb = c->transport.private;
-
-       return smb->tree->session->transport->socket->event.ctx;
-}
-
-
 /* 
    shutdown SMB pipe connection
 */
@@ -426,7 +414,6 @@ NTSTATUS dcerpc_pipe_open_smb(struct dcerpc_connection *c,
 
        c->transport.send_request = smb_send_request;
        c->transport.send_read = send_read_request;
-       c->transport.event_context = smb_event_context;
        c->transport.recv_data = NULL;
        
        /* Over-ride the default session key with the SMB session key */
index 90013e9778db314363207dc1b947af3e6459b7bc..8bfba008a2f883ef47e014c22d09d463c0f230ca 100644 (file)
@@ -36,7 +36,6 @@ struct sock_blob {
 
 /* transport private information used by general socket pipe transports */
 struct sock_private {
-       struct event_context *event_ctx;
        struct fd_event *fde;
        struct socket_context *sock;
        char *server_name;
@@ -259,16 +258,6 @@ static NTSTATUS sock_send_request(struct dcerpc_connection *p, DATA_BLOB *data,
        return NT_STATUS_OK;
 }
 
-/* 
-   return the event context so the caller can process asynchronously
-*/
-static struct event_context *sock_event_context(struct dcerpc_connection *p)
-{
-       struct sock_private *sock = p->transport.private;
-
-       return sock->event_ctx;
-}
-
 /* 
    shutdown sock pipe connection
 */
@@ -331,7 +320,6 @@ static NTSTATUS dcerpc_pipe_open_socket(struct dcerpc_connection *c,
 
        c->transport.send_request = sock_send_request;
        c->transport.send_read = sock_send_read;
-       c->transport.event_context = sock_event_context;
        c->transport.recv_data = NULL;
 
        c->transport.shutdown_pipe = sock_shutdown_pipe;
@@ -339,13 +327,12 @@ static NTSTATUS dcerpc_pipe_open_socket(struct dcerpc_connection *c,
        
        sock->sock = socket_ctx;
        sock->server_name = strupper_talloc(sock, server);
-       sock->event_ctx = event_context_init(sock);
        sock->pending_send = NULL;
        sock->recv.received = 0;
        sock->recv.data = data_blob(NULL, 0);
        sock->recv.pending_count = 0;
 
-       sock->fde = event_add_fd(sock->event_ctx, sock, socket_get_fd(sock->sock), 
+       sock->fde = event_add_fd(c->event_ctx, sock, socket_get_fd(sock->sock), 
                                 0, sock_io_handler, c);
 
        c->transport.private = sock;
index 8ae7814c2658e5d69f860603df2dd5f516a9e0a3..d4a0ad28743c43dcb1f97ea0b7b72fc3ff28d0fa 100644 (file)
@@ -792,7 +792,7 @@ NTSTATUS dcerpc_binding_build_tower(TALLOC_CTX *mem_ctx, struct dcerpc_binding *
 }
 
 NTSTATUS dcerpc_epm_map_binding(TALLOC_CTX *mem_ctx, struct dcerpc_binding *binding,
-                               const char *uuid, uint_t version)
+                               const char *uuid, uint_t version, struct event_context *ev)
 {
        struct dcerpc_pipe *p;
        NTSTATUS status;
@@ -850,7 +850,7 @@ NTSTATUS dcerpc_epm_map_binding(TALLOC_CTX *mem_ctx, struct dcerpc_binding *bind
                                       epmapper_binding,
                                       DCERPC_EPMAPPER_UUID,
                                       DCERPC_EPMAPPER_VERSION,
-                                      anon_creds);
+                                      anon_creds, ev);
 
        if (!NT_STATUS_IS_OK(status)) {
                return status;
@@ -994,12 +994,12 @@ static NTSTATUS dcerpc_pipe_connect_ncacn_np(TALLOC_CTX *tmp_ctx,
                status = smbcli_full_connection(p->conn, &cli, 
                                                binding->host, 
                                                "IPC$", NULL, 
-                                               anon_creds);
+                                               anon_creds, p->conn->event_ctx);
        } else {
                status = smbcli_full_connection(p->conn, &cli, 
                                                binding->host, 
                                                "IPC$", NULL,
-                                               credentials);
+                                               credentials, p->conn->event_ctx);
        }
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0,("Failed to connect to %s - %s\n", binding->host, nt_errstr(status)));
@@ -1008,7 +1008,9 @@ static NTSTATUS dcerpc_pipe_connect_ncacn_np(TALLOC_CTX *tmp_ctx,
 
        /* Look up identifier using the epmapper */
        if (!binding->endpoint) {
-               status = dcerpc_epm_map_binding(tmp_ctx, binding, pipe_uuid, pipe_version);
+               status = dcerpc_epm_map_binding(tmp_ctx, binding, 
+                                               pipe_uuid, pipe_version, 
+                                               p->conn->event_ctx);
                if (!NT_STATUS_IS_OK(status)) {
                        DEBUG(0,("Failed to map DCERPC/TCP NCACN_NP pipe for '%s' - %s\n", 
                                 pipe_uuid, nt_errstr(status)));
@@ -1040,7 +1042,9 @@ static NTSTATUS dcerpc_pipe_connect_ncalrpc(TALLOC_CTX *tmp_ctx,
 
        /* Look up identifier using the epmapper */
        if (!binding->endpoint) {
-               status = dcerpc_epm_map_binding(tmp_ctx, binding, pipe_uuid, pipe_version);
+               status = dcerpc_epm_map_binding(tmp_ctx, binding, 
+                                               pipe_uuid, pipe_version, 
+                                               p->conn->event_ctx);
                if (!NT_STATUS_IS_OK(status)) {
                        DEBUG(0,("Failed to map DCERPC/TCP NCALRPC identifier for '%s' - %s\n", 
                                 pipe_uuid, nt_errstr(status)));
@@ -1100,7 +1104,8 @@ static NTSTATUS dcerpc_pipe_connect_ncacn_ip_tcp(TALLOC_CTX *tmp_ctx,
 
        if (!binding->endpoint) {
                status = dcerpc_epm_map_binding(tmp_ctx, binding, 
-                                               pipe_uuid, pipe_version);
+                                               pipe_uuid, pipe_version, 
+                                               p->conn->event_ctx);
                if (!NT_STATUS_IS_OK(status)) {
                        DEBUG(0,("Failed to map DCERPC/TCP port for '%s' - %s\n", 
                                 pipe_uuid, nt_errstr(status)));
@@ -1129,7 +1134,8 @@ NTSTATUS dcerpc_pipe_connect_b(TALLOC_CTX *parent_ctx,
                               struct dcerpc_binding *binding,
                               const char *pipe_uuid, 
                               uint32_t pipe_version,
-                              struct cli_credentials *credentials)
+                              struct cli_credentials *credentials,
+                              struct event_context *ev)
 {
        NTSTATUS status = NT_STATUS_INVALID_PARAMETER;
        struct dcerpc_pipe *p; 
@@ -1138,7 +1144,7 @@ NTSTATUS dcerpc_pipe_connect_b(TALLOC_CTX *parent_ctx,
 
        (*pp) = NULL;
 
-       p = dcerpc_pipe_init(parent_ctx);
+       p = dcerpc_pipe_init(parent_ctx, ev);
        if (p == NULL) {
                return NT_STATUS_NO_MEMORY;
        }
@@ -1189,7 +1195,8 @@ NTSTATUS dcerpc_pipe_connect(TALLOC_CTX *parent_ctx,
                             const char *binding,
                             const char *pipe_uuid, 
                             uint32_t pipe_version,
-                            struct cli_credentials *credentials)
+                            struct cli_credentials *credentials,
+                            struct event_context *ev)
 {
        struct dcerpc_binding *b;
        NTSTATUS status;
@@ -1210,7 +1217,8 @@ NTSTATUS dcerpc_pipe_connect(TALLOC_CTX *parent_ctx,
        DEBUG(3,("Using binding %s\n", dcerpc_binding_string(tmp_ctx, b)));
 
        status = dcerpc_pipe_connect_b(tmp_ctx,
-                                      pp, b, pipe_uuid, pipe_version, credentials);
+                                      pp, b, pipe_uuid, pipe_version, 
+                                      credentials, ev);
 
        if (NT_STATUS_IS_OK(status)) {
                *pp = talloc_reference(parent_ctx, *pp);
@@ -1235,7 +1243,7 @@ NTSTATUS dcerpc_secondary_connection(struct dcerpc_pipe *p, struct dcerpc_pipe *
        struct smbcli_tree *tree;
        NTSTATUS status = NT_STATUS_INVALID_PARAMETER;
 
-       (*p2) = dcerpc_pipe_init(p);
+       (*p2) = dcerpc_pipe_init(p, p->conn->event_ctx);
        if (*p2 == NULL) {
                return NT_STATUS_NO_MEMORY;
        }
index 67eda312fd3f5de357c1e8ee37e9156548a4d966..f8b17701de945f874d4e7f2692c3642f80369db2 100644 (file)
@@ -54,7 +54,7 @@ BOOL dcesrv_auth_bind(struct dcesrv_call_state *call)
                return False;
        }
 
-       status = gensec_server_start(dce_conn, &auth->gensec_security);
+       status = gensec_server_start(dce_conn, &auth->gensec_security, call->event_ctx);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(1, ("Failed to start GENSEC server code: %s\n", nt_errstr(status)));
                return False;
index 6c32ac8b2c2c722e069ac3768f3866659ef78703..bd20deedb9306ee50437b502b1cf0159ad65c35a 100644 (file)
@@ -460,7 +460,8 @@ static NTSTATUS netr_LogonSamLogonEx(struct dcesrv_call_state *dce_call, TALLOC_
                }
 
                /* TODO: we need to deny anonymous access here */
-               nt_status = auth_context_create(mem_ctx, lp_auth_methods(), &auth_context);
+               nt_status = auth_context_create(mem_ctx, lp_auth_methods(), &auth_context,
+                                               dce_call->event_ctx);
                NT_STATUS_NOT_OK_RETURN(nt_status);
 
                nt_status = auth_get_challenge(auth_context, &chal);
@@ -479,7 +480,8 @@ static NTSTATUS netr_LogonSamLogonEx(struct dcesrv_call_state *dce_call, TALLOC_
        case 2:
        case 6:
                /* TODO: we need to deny anonymous access here */
-               nt_status = auth_context_create(mem_ctx, lp_auth_methods(), &auth_context);
+               nt_status = auth_context_create(mem_ctx, lp_auth_methods(), &auth_context,
+                                               dce_call->event_ctx);
                NT_STATUS_NOT_OK_RETURN(nt_status);
 
                nt_status = auth_context_set_challenge(auth_context, r->in.logon.network->challenge, "netr_LogonSamLogonWithFlags");
index 825adddfee2f09f75aa3d207639dde9bc89bc5e9..3c5caac1180f60f0f8c3d6265ada954f1e7cccfd 100644 (file)
@@ -53,7 +53,7 @@ static NTSTATUS remote_op_bind(struct dcesrv_call_state *dce_call, const struct
        status = dcerpc_pipe_connect(private, 
                                     &(private->c_pipe), binding, 
                                     iface->uuid, iface->if_version, 
-                                    credentials);
+                                    credentials, dce_call->event_ctx);
 
        talloc_free(credentials);
        if (!NT_STATUS_IS_OK(status)) {
index 1b5737db29785ca8e9b96e4887922384d10c7f12..6444ec63ccf8ee149f33e1c3e2caf18beb161563 100644 (file)
@@ -81,7 +81,10 @@ static int ejs_systemAuth(TALLOC_CTX *tmp_ctx, struct MprVar *auth, const char *
        NTSTATUS nt_status;
        DATA_BLOB pw_blob;
 
-       nt_status = auth_context_create(tmp_ctx, auth_unix, &auth_context);
+       /*
+         darn, we need some way to get the right event_context here
+       */
+       nt_status = auth_context_create(tmp_ctx, auth_unix, &auth_context, NULL);
        if (!NT_STATUS_IS_OK(nt_status)) {
                mprSetPropertyValue(auth, "result", mprCreateBoolVar(False));
                mprSetPropertyValue(auth, "report", mprCreateStringVar("Auth System Failure", 1));
index fa147ca2999ca15ac620bfc397c12d716599eca0..f144fd61e511baa31f1cf1b2534480879b839dce 100644 (file)
@@ -232,7 +232,7 @@ static int ejs_cli_tree_connect(MprVarHandle eid, int argc, MprVar **argv)
        union smb_tcon tcon;
        TALLOC_CTX *mem_ctx;
        NTSTATUS status;
-       char *password = "";
+       const char *password = "";
 
        /* Argument parsing */
 
index 0a33b105cd884a3cd6b96002c1e9aa1e31836630..31f31272e0f7dc9fab03b2e4a6cc8a37b2dbac65 100644 (file)
@@ -38,7 +38,9 @@ static NTSTATUS get_challenge(struct smbsrv_connection *smb_conn, uint8_t buff[8
 
        DEBUG(10, ("get challenge: creating negprot_global_auth_context\n"));
 
-       nt_status = auth_context_create(smb_conn, lp_auth_methods(), &smb_conn->negotiate.auth_context);
+       nt_status = auth_context_create(smb_conn, lp_auth_methods(), 
+                                       &smb_conn->negotiate.auth_context,
+                                       smb_conn->connection->event.ctx);
        if (!NT_STATUS_IS_OK(nt_status)) {
                DEBUG(0, ("auth_context_create() returned %s", nt_errstr(nt_status)));
                return nt_status;
@@ -327,7 +329,9 @@ static void reply_nt1(struct smbsrv_request *req, uint16_t choice)
                struct gensec_security *gensec_security;
                DATA_BLOB null_data_blob = data_blob(NULL, 0);
                DATA_BLOB blob;
-               NTSTATUS nt_status = gensec_server_start(req->smb_conn, &gensec_security);
+               NTSTATUS nt_status = gensec_server_start(req->smb_conn, 
+                                                        &gensec_security,
+                                                        req->smb_conn->connection->event.ctx);
                
                if (req->smb_conn->negotiate.auth_context) {
                        smbsrv_terminate_connection(req->smb_conn, "reply_nt1: is this a secondary negprot?  auth_context is non-NULL!\n");
index 4e87aa6de6dcb915e2c2219284336cd567e593d3..a7005e39c50a29aa7b96ccd02161a7852d5915f5 100644 (file)
@@ -149,7 +149,9 @@ static NTSTATUS sesssetup_nt1(struct smbsrv_request *req, union smb_sesssetup *s
                }
 
                /* TODO: should we use just "anonymous" here? */
-               status = auth_context_create(req->smb_conn, lp_auth_methods(), &auth_context);
+               status = auth_context_create(req->smb_conn, lp_auth_methods(), 
+                                            &auth_context, 
+                                            req->smb_conn->connection->event.ctx);
                if (!NT_STATUS_IS_OK(status)) {
                        talloc_free(mem_ctx);
                        return status;
@@ -268,7 +270,8 @@ static NTSTATUS sesssetup_spnego(struct smbsrv_request *req, union smb_sesssetup
                gensec_ctx = smb_sess->gensec_ctx;
                status = gensec_update(gensec_ctx, req, sess->spnego.in.secblob, &sess->spnego.out.secblob);
        } else {
-               status = gensec_server_start(req->smb_conn, &gensec_ctx);
+               status = gensec_server_start(req->smb_conn, &gensec_ctx,
+                                            req->smb_conn->connection->event.ctx);
                if (!NT_STATUS_IS_OK(status)) {
                        DEBUG(1, ("Failed to start GENSEC server code: %s\n", nt_errstr(status)));
                        return status;
index 48deb4e73a87a2b685d732251e55e1013d2dd6f7..578acb44410fe4f0d751f0bfcc8ae5c6aa7ed26c 100644 (file)
@@ -31,7 +31,7 @@ BOOL torture_ntlmssp_self_check(void)
        DATA_BLOB sig, expected_sig;
        NTSTATUS status;
 
-       status = gensec_client_start(NULL, &gensec_security);
+       status = gensec_client_start(NULL, &gensec_security, NULL);
 
        if (!NT_STATUS_IS_OK(status)) {
                return False;
@@ -83,7 +83,7 @@ BOOL torture_ntlmssp_self_check(void)
 
        talloc_free(gensec_security);
 
-       status = gensec_client_start(NULL, &gensec_security);
+       status = gensec_client_start(NULL, &gensec_security, NULL);
 
        if (!NT_STATUS_IS_OK(status)) {
                printf("Failed to start GENSEC for NTLMSSP\n");
index 25800896dbf0ecff08f6f1cd01d2c257aa73cc34..12ff6bee3cb07dd998562c652883b097e0939e9e 100644 (file)
@@ -38,7 +38,7 @@ static BOOL test_readwrite(TALLOC_CTX *mem_ctx, const char *host)
        char test_data[5];
        int i;
 
-       com_init(&ctx);
+       com_init(&ctx, NULL);
        dcom_client_init(ctx, cmdline_credentials);
 
        GUID_from_string(COM_ISTREAM_UUID, &IID[0]);
index 1baad252904751ea4ac5b19e117e858b1bc8b99b..a9d162b5407aea107ba51bb8ff98ed59f6daec88 100644 (file)
@@ -183,7 +183,7 @@ static BOOL connect_servers(void)
                        status = smbcli_full_connection(NULL, &servers[i].cli[j],
                                                        servers[i].server_name, 
                                                        servers[i].share_name, NULL, 
-                                                       servers[i].credentials);
+                                                       servers[i].credentials, NULL);
                        if (!NT_STATUS_IS_OK(status)) {
                                printf("Failed to connect to \\\\%s\\%s - %s\n",
                                       servers[i].server_name, servers[i].share_name,
index 93cd5400972e723c23895be29415b59927288d63..2e5dc96448f4e7a6eff985e832d0eab9b0daf516 100644 (file)
@@ -106,7 +106,7 @@ BOOL torture_createuser(void)
        mem_ctx = talloc_init("test_createuser");
        binding = lp_parm_string(-1, "torture", "binding");
 
-       ctx = libnet_context_init();
+       ctx = libnet_context_init(NULL);
        ctx->cred = cmdline_credentials;
 
        req.in.user_name = TEST_USERNAME;
index 583ce8762406e582bd5f7bbf847ce9780023f96b..4b4e9d3bd338c02fc6f48e658cc299a284720e49 100644 (file)
@@ -122,7 +122,7 @@ static struct smbcli_state *connect_one(char *share, int snum)
                status = smbcli_full_connection(NULL, &c, 
                                                server, 
                                                share, NULL,
-                                               servers[snum]);
+                                               servers[snum], NULL);
                if (!NT_STATUS_IS_OK(status)) {
                        sleep(2);
                }
index aef45396eb610caf26b89dbec33fa761e1017d9d..4bd99cd5d083d89e7603051fca7dfba1a96e531e 100644 (file)
@@ -165,7 +165,7 @@ static struct smbcli_state *connect_one(char *share)
 
        nt_status = smbcli_full_connection(NULL, 
                                           &c, myname, server_n, 0, share, NULL,
-                                          username, lp_workgroup(), password);
+                                          username, lp_workgroup(), password, NULL);
        if (!NT_STATUS_IS_OK(nt_status)) {
                DEBUG(0, ("smbcli_full_connection failed with error %s\n", nt_errstr(nt_status)));
                return NULL;
index 1536ddafd8b92d1911fcfd848d06f25e72bcb5d8..4ad280eac7f38a0b280cb187fc7a253a6e09f251 100644 (file)
@@ -82,7 +82,7 @@ static struct smbcli_state *connect_one(char *share)
        status = smbcli_full_connection(NULL, &c,
                                        server, 
                                        share, NULL,
-                                       credentials);
+                                       credentials, NULL);
 
        if (!NT_STATUS_IS_OK(status)) {
                return NULL;
index be9cf649d3af3ef0fdb58bd112eb1e8ad00ecbea..7dfa67ce9502369e24ecbd17e941d1a77f47c72a 100644 (file)
@@ -212,7 +212,7 @@ BOOL torture_rpc_mgmt(void)
                if (b->transport == NCACN_IP_TCP) {
                        status = dcerpc_epm_map_binding(loop_ctx, b, 
                                                        l->table->uuid,
-                                                       l->table->if_version);
+                                                       l->table->if_version, NULL);
                        if (!NT_STATUS_IS_OK(status)) {
                                talloc_free(loop_ctx);
                                printf("Failed to map port for uuid %s\n", l->table->uuid);
index 12b7ea92b18e9473d1294567093243c8f57c749b..37b9025194550ca3102e2403228162d8bc84b075 100644 (file)
@@ -1363,7 +1363,7 @@ BOOL torture_rpc_samlogon(void)
        status = dcerpc_pipe_connect_b(mem_ctx, &p, b, 
                                       DCERPC_NETLOGON_UUID,
                                       DCERPC_NETLOGON_VERSION,
-                                      credentials);
+                                      credentials, NULL);
 
        if (!NT_STATUS_IS_OK(status)) {
                printf("RPC pipe connect as domain member failed: %s\n", nt_errstr(status));
index 4690b18ead841aa2d596f1a4cb100ea0b7f9cbf6..652fef15c3bf9ec2cba1731d9941373d52e2abb2 100644 (file)
@@ -1505,7 +1505,7 @@ BOOL torture_rpc_samsync(void)
                                       &samsync_state->p, b, 
                                       DCERPC_NETLOGON_UUID,
                                       DCERPC_NETLOGON_VERSION,
-                                      credentials);
+                                      credentials, NULL);
        
        if (!NT_STATUS_IS_OK(status)) {
                printf("Failed to connect to server as a BDC: %s\n", nt_errstr(status));
@@ -1545,7 +1545,7 @@ BOOL torture_rpc_samsync(void)
                                       b_netlogon_wksta, 
                                       DCERPC_NETLOGON_UUID,
                                       DCERPC_NETLOGON_VERSION,
-                                      credentials_wksta);
+                                      credentials_wksta, NULL);
 
        if (!NT_STATUS_IS_OK(status)) {
                printf("Failed to connect to server as a Workstation: %s\n", nt_errstr(status));
index d7a5d03271e1cde453076a96a98b04780f5ae658..9741273c64b9cb50e5b1b73d06d21a02c01d9d72 100644 (file)
@@ -168,7 +168,7 @@ BOOL torture_rpc_scanner(void)
                if (b->transport == NCACN_IP_TCP) {
                        status = dcerpc_epm_map_binding(mem_ctx, b, 
                                                         l->table->uuid,
-                                                        l->table->if_version);
+                                                        l->table->if_version, NULL);
                        if (!NT_STATUS_IS_OK(status)) {
                                talloc_free(loop_ctx);
                                printf("Failed to map port for uuid %s\n", l->table->uuid);
index 75f91981062bd664d7f72397f899b96c22123814..e87f950b624d2ddebb00e3111ca48f95579f60ef 100644 (file)
@@ -171,7 +171,7 @@ static BOOL test_schannel(TALLOC_CTX *mem_ctx,
                                       &p, b, 
                                       DCERPC_SAMR_UUID,
                                       DCERPC_SAMR_VERSION,
-                                      credentials);
+                                      credentials, NULL);
        if (!NT_STATUS_IS_OK(status)) {
                printf("Failed to connect with schannel: %s\n", nt_errstr(status));
                goto failed;
@@ -193,7 +193,7 @@ static BOOL test_schannel(TALLOC_CTX *mem_ctx,
 
        /* Swap the binding details from SAMR to NETLOGON */
        status = dcerpc_epm_map_binding(test_ctx, b, DCERPC_NETLOGON_UUID,
-                                       DCERPC_NETLOGON_VERSION);
+                                       DCERPC_NETLOGON_VERSION, NULL);
        if (!NT_STATUS_IS_OK(status)) {
                goto failed;
        }
index 3a5a2f5844ff68ced4e9f82cc9ab031e25bfb017..c841267d9739886df12b61a1786044344b11d35f 100644 (file)
@@ -208,7 +208,8 @@ static NTSTATUS connect_to_pipe(struct dcerpc_pipe **pp,
 
        /* Look up identifier using the epmapper */
        if (!b->endpoint) {
-               status = dcerpc_epm_map_binding(tmp_ctx, b, pipe_uuid, pipe_version);
+               status = dcerpc_epm_map_binding(tmp_ctx, b, pipe_uuid, pipe_version,
+                                               NULL);
                if (!NT_STATUS_IS_OK(status)) {
                        DEBUG(0,("Failed to map DCERPC/TCP NCACN_NP pipe for '%s' - %s\n", 
                                 pipe_uuid, nt_errstr(status)));
index a2ca9fc72f781b2cfd5d8e4885294ff7ea54b52e..c96f8621424ec462f2a50d1a1d67dddc12dcea01 100644 (file)
@@ -82,7 +82,7 @@ BOOL torture_open_connection_share(struct smbcli_state **c,
        status = smbcli_full_connection(NULL,
                                        c, hostname, 
                                        sharename, NULL,
-                                       cmdline_credentials);
+                                       cmdline_credentials, NULL);
        if (!NT_STATUS_IS_OK(status)) {
                printf("Failed to open connection - %s\n", nt_errstr(status));
                return False;
@@ -133,7 +133,7 @@ NTSTATUS torture_rpc_connection(TALLOC_CTX *parent_ctx,
 
        status = dcerpc_pipe_connect(parent_ctx, 
                                     p, binding, pipe_uuid, pipe_version,
-                                    cmdline_credentials);
+                                    cmdline_credentials, NULL);
  
         return status;
 }
@@ -167,7 +167,7 @@ NTSTATUS torture_rpc_connection_transport(TALLOC_CTX *parent_ctx,
        b->transport = transport;
 
        status = dcerpc_pipe_connect_b(mem_ctx, p, b, pipe_uuid, pipe_version,
-                                                                  cmdline_credentials);
+                                      cmdline_credentials, NULL);
                                           
        if (NT_STATUS_IS_OK(status)) {
                *p = talloc_reference(parent_ctx, *p);
@@ -612,7 +612,7 @@ static BOOL run_tcon_devtype_test(void)
        status = smbcli_full_connection(NULL,
                                        &cli1, host, 
                                        share, NULL,
-                                       cmdline_credentials);
+                                       cmdline_credentials, NULL);
 
        if (!NT_STATUS_IS_OK(status)) {
                printf("could not open connection\n");
index 717a9364a5b97c0ddedf5c159a559436f63d8ab2..7f9ab0c6351dac030ec94a4431e37850af7a9ac4 100644 (file)
@@ -57,7 +57,7 @@ int net_join(struct net_context *ctx, int argc, const char **argv)
 
        domain_name = tmp;
 
-       libnetctx = libnet_context_init();
+       libnetctx = libnet_context_init(NULL);
        if (!libnetctx) {
                return -1;      
        }
@@ -78,7 +78,7 @@ int net_join(struct net_context *ctx, int argc, const char **argv)
                return -1;
        }
 
-       libnet_context_destroy(&libnetctx);
+       talloc_free(libnetctx);
 
        return 0;
 }
index 68fe9223a121424c0b3cdf27e79655f0d5a83a5c..1912beeb41b3b03479a13fc3bf0b532961e464fb 100644 (file)
@@ -53,7 +53,7 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a
                new_password = getpass(password_prompt);
        }
 
-       libnetctx = libnet_context_init();
+       libnetctx = libnet_context_init(NULL);
        if (!libnetctx) {
                return -1;      
        }
@@ -73,7 +73,7 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a
                return -1;
        }
 
-       libnet_context_destroy(&libnetctx);
+       talloc_free(libnetctx);
 
        return 0;
 }
@@ -128,7 +128,7 @@ static int net_password_set(struct net_context *ctx, int argc, const char **argv
                new_password = getpass(password_prompt);
        }
 
-       libnetctx = libnet_context_init();
+       libnetctx = libnet_context_init(NULL);
        if (!libnetctx) {
                return -1;      
        }
@@ -147,7 +147,7 @@ static int net_password_set(struct net_context *ctx, int argc, const char **argv
                return -1;
        }
 
-       libnet_context_destroy(&libnetctx);
+       talloc_free(libnetctx);
 
        return 0;
 }
index 507cfd5f6d6f709c04a4bcb8e1126785b97ac5ed..8bdef1f7620cca51277a08f706d387cb30722ee1 100644 (file)
@@ -43,7 +43,7 @@ int net_time(struct net_context *ctx, int argc, const char **argv)
                return net_time_usage(ctx, argc, argv);
        }
 
-       libnetctx = libnet_context_init();
+       libnetctx = libnet_context_init(NULL);
        if (!libnetctx) {
                return -1;      
        }
@@ -66,7 +66,7 @@ int net_time(struct net_context *ctx, int argc, const char **argv)
 
        printf("%s\n",timestr);
 
-       libnet_context_destroy(&libnetctx);
+       talloc_free(libnetctx);
 
        return 0;
 }
index b1bf85d6f2b3db0d8e3b2ecfb78ea67b5efc8fee..dabb4a0d61df473274f47dcf56cf8e6f4c40bc36 100644 (file)
@@ -44,7 +44,7 @@ static int net_user_add(struct net_context *ctx, int argc, const char **argv)
        }
 
        /* libnet context init and its params */
-       lnet_ctx = libnet_context_init();
+       lnet_ctx = libnet_context_init(NULL);
        if (!lnet_ctx) return -1;
 
        lnet_ctx->cred = ctx->credentials;
@@ -61,7 +61,7 @@ static int net_user_add(struct net_context *ctx, int argc, const char **argv)
                return -1;
        }
        
-       libnet_context_destroy(&lnet_ctx);
+       talloc_free(lnet_ctx);
        return 0;
 }
 
index 5a17544e82ec8519c1a1791759441454b5340807..e60fd85a7de627e44929476c751c66a96c856c68 100644 (file)
@@ -31,7 +31,7 @@ int net_samdump(struct net_context *ctx, int argc, const char **argv)
        struct libnet_context *libnetctx;
        union libnet_SamDump r;
 
-       libnetctx = libnet_context_init();
+       libnetctx = libnet_context_init(NULL);
        if (!libnetctx) {
                return -1;      
        }
@@ -50,7 +50,7 @@ int net_samdump(struct net_context *ctx, int argc, const char **argv)
                return -1;
        }
 
-       libnet_context_destroy(&libnetctx);
+       talloc_free(libnetctx);
 
        return 0;
 }
index 8e858e2970db94ddd6412abb369508a0ee34ea77..3a94d82c0ca21958a597d95bef75fb5e99221ef4 100644 (file)
@@ -341,8 +341,9 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode,
                case GSS_SPNEGO_CLIENT:
                case NTLMSSP_CLIENT_1:
                        /* setup the client side */
-                       
-                       if (!NT_STATUS_IS_OK(gensec_client_start(NULL, gensec_state))) {
+
+                       nt_status = gensec_client_start(NULL, gensec_state, NULL);
+                       if (!NT_STATUS_IS_OK(nt_status)) {
                                exit(1);
                        }
 
@@ -367,7 +368,7 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode,
                        break;
                case GSS_SPNEGO_SERVER:
                case SQUID_2_5_NTLMSSP:
-                       if (!NT_STATUS_IS_OK(gensec_server_start(NULL, gensec_state))) {
+                       if (!NT_STATUS_IS_OK(gensec_server_start(NULL, gensec_state, NULL))) {
                                exit(1);
                        }
                        break;