From af237084ecd4f9928c6c282b9c5c73598d5c73d6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 16 Jun 2005 11:36:09 +0000 Subject: r7633: this patch started as an attempt to make the dcerpc code use a given 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 (This used to be commit 3a3025485bdb8f600ab528c0b4b4eef0c65e3fc9) --- source4/auth/auth.c | 15 ++++++++++- source4/auth/auth.h | 3 +++ source4/auth/auth_domain.c | 2 +- source4/auth/gensec/gensec.c | 37 +++++++++++++++++++-------- source4/auth/gensec/gensec.h | 1 + source4/auth/ntlmssp/ntlmssp_server.c | 4 ++- source4/client/client.c | 4 +-- source4/client/smbspool.c | 2 +- source4/gtk/tools/gepdump.c | 2 +- source4/gtk/tools/gregedit.c | 5 ++-- source4/gtk/tools/gwcrontab.c | 2 +- source4/gtk/tools/gwsam.c | 2 +- source4/ldap_server/ldap_bind.c | 4 ++- source4/lib/com/com.h | 1 + source4/lib/com/dcom/main.c | 14 ++++++---- source4/lib/com/main.c | 7 ++++- source4/lib/registry/reg_backend_rpc.c | 5 ++-- source4/lib/registry/tools/regdiff.c | 6 +++-- source4/lib/registry/tools/regpatch.c | 2 +- source4/lib/registry/tools/regshell.c | 2 +- source4/lib/registry/tools/regtree.c | 2 +- source4/libcli/cliconnect.c | 5 ++-- source4/libcli/composite/connect.c | 5 ++-- source4/libcli/composite/sesssetup.c | 2 +- source4/libcli/ldap/ldap_bind.c | 2 +- source4/libcli/raw/clitree.c | 5 ++-- source4/libcli/util/clilsa.c | 2 +- source4/libnet/libnet.c | 23 ++++++++--------- source4/libnet/libnet.h | 4 +-- source4/libnet/libnet_rpc.c | 2 +- source4/libnet/libnet_vampire.c | 2 +- source4/librpc/rpc/dcerpc.c | 29 ++++++++++++++------- source4/librpc/rpc/dcerpc.h | 4 +-- source4/librpc/rpc/dcerpc_auth.c | 6 +++-- source4/librpc/rpc/dcerpc_schannel.c | 4 ++- source4/librpc/rpc/dcerpc_smb.c | 13 ---------- source4/librpc/rpc/dcerpc_sock.c | 15 +---------- source4/librpc/rpc/dcerpc_util.c | 32 ++++++++++++++--------- source4/rpc_server/dcesrv_auth.c | 2 +- source4/rpc_server/netlogon/dcerpc_netlogon.c | 6 +++-- source4/rpc_server/remote/dcesrv_remote.c | 2 +- source4/scripting/ejs/smbcalls.c | 5 +++- source4/scripting/ejs/smbcalls_cli.c | 2 +- source4/smb_server/negprot.c | 8 ++++-- source4/smb_server/sesssetup.c | 7 +++-- source4/torture/auth/ntlmssp.c | 4 +-- source4/torture/com/simple.c | 2 +- source4/torture/gentest.c | 2 +- source4/torture/libnet/libnet_user.c | 2 +- source4/torture/locktest.c | 2 +- source4/torture/locktest2.c | 2 +- source4/torture/masktest.c | 2 +- source4/torture/rpc/mgmt.c | 2 +- source4/torture/rpc/samlogon.c | 2 +- source4/torture/rpc/samsync.c | 4 +-- source4/torture/rpc/scanner.c | 2 +- source4/torture/rpc/schannel.c | 4 +-- source4/torture/rpc/xplogin.c | 3 ++- source4/torture/torture.c | 8 +++--- source4/utils/net/net_join.c | 4 +-- source4/utils/net/net_password.c | 8 +++--- source4/utils/net/net_time.c | 4 +-- source4/utils/net/net_user.c | 4 +-- source4/utils/net/net_vampire.c | 4 +-- source4/utils/ntlm_auth.c | 7 ++--- 65 files changed, 221 insertions(+), 160 deletions(-) diff --git a/source4/auth/auth.c b/source4/auth/auth.c index 674e9a7f46..dab1912d8e 100644 --- a/source4/auth/auth.c +++ b/source4/auth/auth.c @@ -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; diff --git a/source4/auth/auth.h b/source4/auth/auth.h index d1f8caa2a0..b4f08b2859 100644 --- a/source4/auth/auth.h +++ b/source4/auth/auth.h @@ -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 */ diff --git a/source4/auth/auth_domain.c b/source4/auth/auth_domain.c index 041135e4d4..339cc18531 100644 --- a/source4/auth/auth_domain.c +++ b/source4/auth/auth_domain.c @@ -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; diff --git a/source4/auth/gensec/gensec.c b/source4/auth/gensec/gensec.c index 1608f21114..d9c264cdd8 100644 --- a/source4/auth/gensec/gensec.c +++ b/source4/auth/gensec/gensec.c @@ -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; } diff --git a/source4/auth/gensec/gensec.h b/source4/auth/gensec/gensec.h index be6731abfa..2951e13dd9 100644 --- a/source4/auth/gensec/gensec.h +++ b/source4/auth/gensec/gensec.h @@ -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 */ diff --git a/source4/auth/ntlmssp/ntlmssp_server.c b/source4/auth/ntlmssp/ntlmssp_server.c index ab214578dd..e50fe58305 100644 --- a/source4/auth/ntlmssp/ntlmssp_server.c +++ b/source4/auth/ntlmssp/ntlmssp_server.c @@ -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; diff --git a/source4/client/client.c b/source4/client/client.c index afdab5928c..a24fd7bfd3 100644 --- a/source4/client/client.c +++ b/source4/client/client.c @@ -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)); diff --git a/source4/client/smbspool.c b/source4/client/smbspool.c index 41cb4c9bf3..2e7afc5ec4 100644 --- a/source4/client/smbspool.c +++ b/source4/client/smbspool.c @@ -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)) { diff --git a/source4/gtk/tools/gepdump.c b/source4/gtk/tools/gepdump.c index 4dacd2937c..23d95152f4 100644 --- a/source4/gtk/tools/gepdump.c +++ b/source4/gtk/tools/gepdump.c @@ -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); diff --git a/source4/gtk/tools/gregedit.c b/source4/gtk/tools/gregedit.c index 72dd9ae929..27ae925746 100644 --- a/source4/gtk/tools/gregedit.c +++ b/source4/gtk/tools/gregedit.c @@ -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(®istry, - 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); diff --git a/source4/gtk/tools/gwcrontab.c b/source4/gtk/tools/gwcrontab.c index eba8b54ac0..5b79eafa0a 100644 --- a/source4/gtk/tools/gwcrontab.c +++ b/source4/gtk/tools/gwcrontab.c @@ -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); diff --git a/source4/gtk/tools/gwsam.c b/source4/gtk/tools/gwsam.c index cf82ddb767..8606cc398f 100644 --- a/source4/gtk/tools/gwsam.c +++ b/source4/gtk/tools/gwsam.c @@ -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); diff --git a/source4/ldap_server/ldap_bind.c b/source4/ldap_server/ldap_bind.c index 3c51dc2ba5..7b416c9726 100644 --- a/source4/ldap_server/ldap_bind.c +++ b/source4/ldap_server/ldap_bind.c @@ -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; diff --git a/source4/lib/com/com.h b/source4/lib/com/com.h index 97841e14c3..0a26a568b0 100644 --- a/source4/lib/com/com.h +++ b/source4/lib/com/com.h @@ -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); diff --git a/source4/lib/com/dcom/main.c b/source4/lib/com/dcom/main.c index 08a928cda6..bc47cb7c68 100644 --- a/source4/lib/com/dcom/main.c +++ b/source4/lib/com/dcom/main.c @@ -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++; diff --git a/source4/lib/com/main.c b/source4/lib/com/main.c index 378c3738b9..210e8ba79c 100644 --- a/source4/lib/com/main.c +++ b/source4/lib/com/main.c @@ -21,11 +21,16 @@ #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; } diff --git a/source4/lib/registry/reg_backend_rpc.c b/source4/lib/registry/reg_backend_rpc.c index 88cce2584e..3c38b5d312 100644 --- a/source4/lib/registry/reg_backend_rpc.c +++ b/source4/lib/registry/reg_backend_rpc.c @@ -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)) { diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c index f86c0ae383..a9d189c033 100644 --- a/source4/lib/registry/tools/regdiff.c +++ b/source4/lib/registry/tools/regdiff.c @@ -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; } diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 02ef4d4655..3ada9f66e2 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -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); } diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 0c53f737b8..108cc17336 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -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 { diff --git a/source4/lib/registry/tools/regtree.c b/source4/lib/registry/tools/regtree.c index f18467b523..2385123b7f 100644 --- a/source4/lib/registry/tools/regtree.c +++ b/source4/lib/registry/tools/regtree.c @@ -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 { diff --git a/source4/libcli/cliconnect.c b/source4/libcli/cliconnect.c index a866e26970..0009151429 100644 --- a/source4/libcli/cliconnect.c +++ b/source4/libcli/cliconnect.c @@ -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; } diff --git a/source4/libcli/composite/connect.c b/source4/libcli/composite/connect.c index 9e33a2f7db..fb439172d0 100644 --- a/source4/libcli/composite/connect.c +++ b/source4/libcli/composite/connect.c @@ -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); } diff --git a/source4/libcli/composite/sesssetup.c b/source4/libcli/composite/sesssetup.c index ab46c198ef..2736d91262 100644 --- a/source4/libcli/composite/sesssetup.c +++ b/source4/libcli/composite/sesssetup.c @@ -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; diff --git a/source4/libcli/ldap/ldap_bind.c b/source4/libcli/ldap/ldap_bind.c index 11a6997fb2..ea97798261 100644 --- a/source4/libcli/ldap/ldap_bind.c +++ b/source4/libcli/ldap/ldap_bind.c @@ -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; diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index 87c2dbba7c..76cb1a43fe 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -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; } diff --git a/source4/libcli/util/clilsa.c b/source4/libcli/util/clilsa.c index 0c0c64c0b4..ad2006756b 100644 --- a/source4/libcli/util/clilsa.c +++ b/source4/libcli/util/clilsa.c @@ -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; diff --git a/source4/libnet/libnet.c b/source4/libnet/libnet.c index 56b55426c0..5d66005a27 100644 --- a/source4/libnet/libnet.c +++ b/source4/libnet/libnet.c @@ -20,27 +20,26 @@ #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; -} diff --git a/source4/libnet/libnet.h b/source4/libnet/libnet.h index b26ce72ba6..092d09599f 100644 --- a/source4/libnet/libnet.h +++ b/source4/libnet/libnet.h @@ -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; }; diff --git a/source4/libnet/libnet_rpc.c b/source4/libnet/libnet_rpc.c index 30f7784361..9ed398b3af 100644 --- a/source4/libnet/libnet_rpc.c +++ b/source4/libnet/libnet_rpc.c @@ -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, diff --git a/source4/libnet/libnet_vampire.c b/source4/libnet/libnet_vampire.c index 69bacb7951..79f07c05f3 100644 --- a/source4/libnet/libnet_vampire.c +++ b/source4/libnet/libnet_vampire.c @@ -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; diff --git a/source4/librpc/rpc/dcerpc.c b/source4/librpc/rpc/dcerpc.c index fa7fe728d4..1f4e72639e 100644 --- a/source4/librpc/rpc/dcerpc.c +++ b/source4/librpc/rpc/dcerpc.c @@ -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; } diff --git a/source4/librpc/rpc/dcerpc.h b/source4/librpc/rpc/dcerpc.h index 2f64c0ef34..3b1cc20bca 100644 --- a/source4/librpc/rpc/dcerpc.h +++ b/source4/librpc/rpc/dcerpc.h @@ -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); diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index ae0a89910e..7aa563cb9d 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -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; diff --git a/source4/librpc/rpc/dcerpc_schannel.c b/source4/librpc/rpc/dcerpc_schannel.c index cc6cbe7b46..1b83b2ec0b 100644 --- a/source4/librpc/rpc/dcerpc_schannel.c +++ b/source4/librpc/rpc/dcerpc_schannel.c @@ -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))); diff --git a/source4/librpc/rpc/dcerpc_smb.c b/source4/librpc/rpc/dcerpc_smb.c index 1a5a31c330..9096168b64 100644 --- a/source4/librpc/rpc/dcerpc_smb.c +++ b/source4/librpc/rpc/dcerpc_smb.c @@ -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 */ diff --git a/source4/librpc/rpc/dcerpc_sock.c b/source4/librpc/rpc/dcerpc_sock.c index 90013e9778..8bfba008a2 100644 --- a/source4/librpc/rpc/dcerpc_sock.c +++ b/source4/librpc/rpc/dcerpc_sock.c @@ -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; diff --git a/source4/librpc/rpc/dcerpc_util.c b/source4/librpc/rpc/dcerpc_util.c index 8ae7814c26..d4a0ad2874 100644 --- a/source4/librpc/rpc/dcerpc_util.c +++ b/source4/librpc/rpc/dcerpc_util.c @@ -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; } diff --git a/source4/rpc_server/dcesrv_auth.c b/source4/rpc_server/dcesrv_auth.c index 67eda312fd..f8b17701de 100644 --- a/source4/rpc_server/dcesrv_auth.c +++ b/source4/rpc_server/dcesrv_auth.c @@ -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; diff --git a/source4/rpc_server/netlogon/dcerpc_netlogon.c b/source4/rpc_server/netlogon/dcerpc_netlogon.c index 6c32ac8b2c..bd20deedb9 100644 --- a/source4/rpc_server/netlogon/dcerpc_netlogon.c +++ b/source4/rpc_server/netlogon/dcerpc_netlogon.c @@ -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"); diff --git a/source4/rpc_server/remote/dcesrv_remote.c b/source4/rpc_server/remote/dcesrv_remote.c index 825adddfee..3c5caac118 100644 --- a/source4/rpc_server/remote/dcesrv_remote.c +++ b/source4/rpc_server/remote/dcesrv_remote.c @@ -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)) { diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 1b5737db29..6444ec63cc 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -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)); diff --git a/source4/scripting/ejs/smbcalls_cli.c b/source4/scripting/ejs/smbcalls_cli.c index fa147ca299..f144fd61e5 100644 --- a/source4/scripting/ejs/smbcalls_cli.c +++ b/source4/scripting/ejs/smbcalls_cli.c @@ -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 */ diff --git a/source4/smb_server/negprot.c b/source4/smb_server/negprot.c index 0a33b105cd..31f31272e0 100644 --- a/source4/smb_server/negprot.c +++ b/source4/smb_server/negprot.c @@ -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"); diff --git a/source4/smb_server/sesssetup.c b/source4/smb_server/sesssetup.c index 4e87aa6de6..a7005e39c5 100644 --- a/source4/smb_server/sesssetup.c +++ b/source4/smb_server/sesssetup.c @@ -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; diff --git a/source4/torture/auth/ntlmssp.c b/source4/torture/auth/ntlmssp.c index 48deb4e73a..578acb4441 100644 --- a/source4/torture/auth/ntlmssp.c +++ b/source4/torture/auth/ntlmssp.c @@ -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"); diff --git a/source4/torture/com/simple.c b/source4/torture/com/simple.c index 25800896db..12ff6bee3c 100644 --- a/source4/torture/com/simple.c +++ b/source4/torture/com/simple.c @@ -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]); diff --git a/source4/torture/gentest.c b/source4/torture/gentest.c index 1baad25290..a9d162b540 100644 --- a/source4/torture/gentest.c +++ b/source4/torture/gentest.c @@ -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, diff --git a/source4/torture/libnet/libnet_user.c b/source4/torture/libnet/libnet_user.c index 93cd540097..2e5dc96448 100644 --- a/source4/torture/libnet/libnet_user.c +++ b/source4/torture/libnet/libnet_user.c @@ -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; diff --git a/source4/torture/locktest.c b/source4/torture/locktest.c index 583ce87624..4b4e9d3bd3 100644 --- a/source4/torture/locktest.c +++ b/source4/torture/locktest.c @@ -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); } diff --git a/source4/torture/locktest2.c b/source4/torture/locktest2.c index aef45396eb..4bd99cd5d0 100644 --- a/source4/torture/locktest2.c +++ b/source4/torture/locktest2.c @@ -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; diff --git a/source4/torture/masktest.c b/source4/torture/masktest.c index 1536ddafd8..4ad280eac7 100644 --- a/source4/torture/masktest.c +++ b/source4/torture/masktest.c @@ -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; diff --git a/source4/torture/rpc/mgmt.c b/source4/torture/rpc/mgmt.c index be9cf649d3..7dfa67ce95 100644 --- a/source4/torture/rpc/mgmt.c +++ b/source4/torture/rpc/mgmt.c @@ -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); diff --git a/source4/torture/rpc/samlogon.c b/source4/torture/rpc/samlogon.c index 12b7ea92b1..37b9025194 100644 --- a/source4/torture/rpc/samlogon.c +++ b/source4/torture/rpc/samlogon.c @@ -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)); diff --git a/source4/torture/rpc/samsync.c b/source4/torture/rpc/samsync.c index 4690b18ead..652fef15c3 100644 --- a/source4/torture/rpc/samsync.c +++ b/source4/torture/rpc/samsync.c @@ -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)); diff --git a/source4/torture/rpc/scanner.c b/source4/torture/rpc/scanner.c index d7a5d03271..9741273c64 100644 --- a/source4/torture/rpc/scanner.c +++ b/source4/torture/rpc/scanner.c @@ -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); diff --git a/source4/torture/rpc/schannel.c b/source4/torture/rpc/schannel.c index 75f9198106..e87f950b62 100644 --- a/source4/torture/rpc/schannel.c +++ b/source4/torture/rpc/schannel.c @@ -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; } diff --git a/source4/torture/rpc/xplogin.c b/source4/torture/rpc/xplogin.c index 3a5a2f5844..c841267d97 100644 --- a/source4/torture/rpc/xplogin.c +++ b/source4/torture/rpc/xplogin.c @@ -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))); diff --git a/source4/torture/torture.c b/source4/torture/torture.c index a2ca9fc72f..c96f862142 100644 --- a/source4/torture/torture.c +++ b/source4/torture/torture.c @@ -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"); diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index 717a9364a5..7f9ab0c635 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -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; } diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index 68fe9223a1..1912beeb41 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -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; } diff --git a/source4/utils/net/net_time.c b/source4/utils/net/net_time.c index 507cfd5f6d..8bdef1f762 100644 --- a/source4/utils/net/net_time.c +++ b/source4/utils/net/net_time.c @@ -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; } diff --git a/source4/utils/net/net_user.c b/source4/utils/net/net_user.c index b1bf85d6f2..dabb4a0d61 100644 --- a/source4/utils/net/net_user.c +++ b/source4/utils/net/net_user.c @@ -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; } diff --git a/source4/utils/net/net_vampire.c b/source4/utils/net/net_vampire.c index 5a17544e82..e60fd85a7d 100644 --- a/source4/utils/net/net_vampire.c +++ b/source4/utils/net/net_vampire.c @@ -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; } diff --git a/source4/utils/ntlm_auth.c b/source4/utils/ntlm_auth.c index 8e858e2970..3a94d82c0c 100644 --- a/source4/utils/ntlm_auth.c +++ b/source4/utils/ntlm_auth.c @@ -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; -- cgit