summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-04-22 10:21:22 +0200
committerJelmer Vernooij <jelmer@samba.org>2008-04-22 10:21:22 +0200
commit38a4f9df170fba0a05755e06dd4362d471b3db80 (patch)
treea1f3623e06ce4fd1e010afd5e72062dbee0d9b83
parent54efc107e58ed1eed7109ea08fdf808e3a15327b (diff)
parent7dddab3f6cdb36a537ca3ed9c9f3461993d1c11c (diff)
downloadsamba-38a4f9df170fba0a05755e06dd4362d471b3db80.tar.gz
samba-38a4f9df170fba0a05755e06dd4362d471b3db80.tar.bz2
samba-38a4f9df170fba0a05755e06dd4362d471b3db80.zip
Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into v4-0-test
(This used to be commit 1e38de45640430be002053b8bd52b615184134ba)
-rw-r--r--source4/auth/gensec/gensec.c22
-rw-r--r--source4/client/cifsdd.c17
-rw-r--r--source4/client/cifsdd.h2
-rw-r--r--source4/client/cifsddio.c12
-rw-r--r--source4/client/client.c46
-rw-r--r--source4/dsdb/samdb/samdb.c7
-rw-r--r--source4/lib/events/events.c2
-rw-r--r--source4/lib/ldb/ldb_ildap/ldb_ildap.c16
-rw-r--r--source4/lib/ldb_wrap.c2
-rw-r--r--source4/lib/messaging/messaging.c8
-rw-r--r--source4/lib/socket/testsuite.c2
-rw-r--r--source4/libcli/cldap/cldap.c6
-rw-r--r--source4/libcli/cliconnect.c5
-rw-r--r--source4/libcli/composite/composite.c6
-rw-r--r--source4/libcli/dgram/dgramsocket.c6
-rw-r--r--source4/libcli/ldap/ldap_bind.c5
-rw-r--r--source4/libcli/ldap/ldap_client.c12
-rw-r--r--source4/libcli/nbt/nbtsocket.c6
-rw-r--r--source4/libcli/raw/clisocket.c22
-rw-r--r--source4/libcli/resolve/host.c1
-rw-r--r--source4/libcli/resolve/nbtlist.c3
-rw-r--r--source4/libcli/resolve/resolve.c13
-rw-r--r--source4/libcli/smb_composite/connect.c8
-rw-r--r--source4/libcli/smb_composite/fetchfile.c2
-rw-r--r--source4/libcli/smb_composite/fsinfo.c2
-rw-r--r--source4/libcli/wrepl/winsrepl.c6
-rw-r--r--source4/libnet/libnet_site.c8
-rw-r--r--source4/librpc/rpc/dcerpc.c15
-rw-r--r--source4/librpc/rpc/dcerpc_connect.c15
-rw-r--r--source4/rpc_server/spoolss/dcesrv_spoolss.c3
-rw-r--r--source4/torture/auth/ntlmssp.c6
-rw-r--r--source4/torture/basic/base.c3
-rw-r--r--source4/torture/config.mk1
-rw-r--r--source4/torture/gentest.c33
-rw-r--r--source4/torture/ldap/cldap.c8
-rw-r--r--source4/torture/ldap/cldapbench.c4
-rw-r--r--source4/torture/ldap/common.c2
-rw-r--r--source4/torture/libnet/libnet_domain.c4
-rw-r--r--source4/torture/locktest.c26
-rw-r--r--source4/torture/locktest2.c26
-rw-r--r--source4/torture/masktest.c9
-rw-r--r--source4/torture/nbt/browse.c2
-rw-r--r--source4/torture/nbt/dgram.c6
-rw-r--r--source4/torture/nbt/nbt.c2
-rw-r--r--source4/torture/nbt/query.c2
-rw-r--r--source4/torture/nbt/register.c4
-rw-r--r--source4/torture/nbt/wins.c2
-rw-r--r--source4/torture/nbt/winsbench.c2
-rw-r--r--source4/torture/nbt/winsreplication.c18
-rw-r--r--source4/torture/raw/composite.c4
-rw-r--r--source4/torture/raw/lookuprate.c320
-rw-r--r--source4/torture/raw/raw.c2
-rw-r--r--source4/torture/rpc/dssync.c10
-rw-r--r--source4/torture/rpc/join.c4
-rw-r--r--source4/torture/rpc/rpc.c8
-rw-r--r--source4/torture/rpc/samba3rpc.c12
-rw-r--r--source4/torture/rpc/samlogon.c2
-rw-r--r--source4/torture/rpc/samsync.c4
-rw-r--r--source4/torture/rpc/schannel.c10
-rw-r--r--source4/torture/rpc/session_key.c6
-rw-r--r--source4/torture/unix/unix_info2.c4
-rw-r--r--source4/torture/unix/whoami.c2
-rw-r--r--source4/utils/nmblookup.c14
-rw-r--r--source4/utils/ntlm_auth.c10
64 files changed, 605 insertions, 247 deletions
diff --git a/source4/auth/gensec/gensec.c b/source4/auth/gensec/gensec.c
index 59ad15740e..c82b719dfd 100644
--- a/source4/auth/gensec/gensec.c
+++ b/source4/auth/gensec/gensec.c
@@ -482,6 +482,11 @@ static NTSTATUS gensec_start(TALLOC_CTX *mem_ctx,
struct messaging_context *msg,
struct gensec_security **gensec_security)
{
+ if (ev == NULL) {
+ DEBUG(0, ("No event context available!\n"));
+ return NT_STATUS_INTERNAL_ERROR;
+ }
+
(*gensec_security) = talloc(mem_ctx, struct gensec_security);
NT_STATUS_HAVE_NO_MEMORY(*gensec_security);
@@ -493,14 +498,6 @@ static NTSTATUS gensec_start(TALLOC_CTX *mem_ctx,
(*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;
(*gensec_security)->msg_ctx = msg;
@@ -548,20 +545,11 @@ _PUBLIC_ NTSTATUS gensec_client_start(TALLOC_CTX *mem_ctx,
struct loadparm_context *lp_ctx)
{
NTSTATUS status;
- struct event_context *new_ev = NULL;
-
- if (ev == NULL) {
- new_ev = event_context_init(mem_ctx);
- NT_STATUS_HAVE_NO_MEMORY(new_ev);
- ev = new_ev;
- }
status = gensec_start(mem_ctx, ev, lp_ctx, NULL, gensec_security);
if (!NT_STATUS_IS_OK(status)) {
- talloc_free(new_ev);
return status;
}
- talloc_steal((*gensec_security), new_ev);
(*gensec_security)->gensec_role = GENSEC_CLIENT;
return status;
diff --git a/source4/client/cifsdd.c b/source4/client/cifsdd.c
index 8e25dab927..ce48c7bad1 100644
--- a/source4/client/cifsdd.c
+++ b/source4/client/cifsdd.c
@@ -24,6 +24,7 @@
#include "lib/cmdline/popt_common.h"
#include "libcli/resolve/resolve.h"
#include "libcli/raw/libcliraw.h"
+#include "lib/events/events.h"
#include "cifsdd.h"
#include "param/param.h"
@@ -354,6 +355,7 @@ static void print_transfer_stats(void)
}
static struct dd_iohandle * open_file(struct resolve_context *resolve_ctx,
+ struct event_context *ev,
const char * which, const char **ports,
struct smbcli_options *smb_options)
{
@@ -375,13 +377,13 @@ static struct dd_iohandle * open_file(struct resolve_context *resolve_ctx,
if (strcmp(which, "if") == 0) {
path = check_arg_pathname("if");
- handle = dd_open_path(resolve_ctx, path, ports,
+ handle = dd_open_path(resolve_ctx, ev, path, ports,
check_arg_numeric("ibs"), options,
smb_options);
} else if (strcmp(which, "of") == 0) {
options |= DD_WRITE;
path = check_arg_pathname("of");
- handle = dd_open_path(resolve_ctx, path, ports,
+ handle = dd_open_path(resolve_ctx, ev, path, ports,
check_arg_numeric("obs"), options,
smb_options);
} else {
@@ -396,7 +398,7 @@ static struct dd_iohandle * open_file(struct resolve_context *resolve_ctx,
return(handle);
}
-static int copy_files(struct loadparm_context *lp_ctx)
+static int copy_files(struct event_context *ev, struct loadparm_context *lp_ctx)
{
uint8_t * iobuf; /* IO buffer. */
uint64_t iomax; /* Size of the IO buffer. */
@@ -433,12 +435,12 @@ static int copy_files(struct loadparm_context *lp_ctx)
DEBUG(4, ("IO buffer size is %llu, max xmit is %d\n",
(unsigned long long)iomax, options.max_xmit));
- if (!(ifile = open_file(lp_resolve_context(lp_ctx), "if",
+ if (!(ifile = open_file(lp_resolve_context(lp_ctx), ev, "if",
lp_smb_ports(lp_ctx), &options))) {
return(FILESYS_EXIT_CODE);
}
- if (!(ofile = open_file(lp_resolve_context(lp_ctx), "of",
+ if (!(ofile = open_file(lp_resolve_context(lp_ctx), ev, "of",
lp_smb_ports(lp_ctx), &options))) {
return(FILESYS_EXIT_CODE);
}
@@ -528,6 +530,7 @@ int main(int argc, const char ** argv)
{
int i;
const char ** dd_args;
+ struct event_context *ev;
poptContext pctx;
struct poptOption poptions[] = {
@@ -578,6 +581,8 @@ int main(int argc, const char ** argv)
}
}
+ ev = event_context_init(talloc_autofree_context());
+
gensec_init(cmdline_lp_ctx);
dump_args();
@@ -599,7 +604,7 @@ int main(int argc, const char ** argv)
CatchSignal(SIGINT, dd_handle_signal);
CatchSignal(SIGUSR1, dd_handle_signal);
- return(copy_files(cmdline_lp_ctx));
+ return(copy_files(ev, cmdline_lp_ctx));
}
/* vim: set sw=8 sts=8 ts=8 tw=79 : */
diff --git a/source4/client/cifsdd.h b/source4/client/cifsdd.h
index 810c882ea9..21a4ad4882 100644
--- a/source4/client/cifsdd.h
+++ b/source4/client/cifsdd.h
@@ -89,8 +89,10 @@ struct dd_iohandle
#define DD_OPLOCK 0x00000008
struct smbcli_options;
+struct event_context;
struct dd_iohandle * dd_open_path(struct resolve_context *resolve_ctx,
+ struct event_context *ev,
const char * path,
const char **ports,
uint64_t io_size, int options,
diff --git a/source4/client/cifsddio.c b/source4/client/cifsddio.c
index 7028e85078..4297c30012 100644
--- a/source4/client/cifsddio.c
+++ b/source4/client/cifsddio.c
@@ -221,6 +221,7 @@ static bool smb_write_func(void * handle, uint8_t * buf, uint64_t wanted,
}
static struct smbcli_state * init_smb_session(struct resolve_context *resolve_ctx,
+ struct event_context *ev,
const char * host,
const char **ports,
const char * share,
@@ -233,8 +234,9 @@ static struct smbcli_state * init_smb_session(struct resolve_context *resolve_ct
* each connection, but for now, we just use the same one for both.
*/
ret = smbcli_full_connection(NULL, &cli, host, ports, share,
- NULL /* devtype */, cmdline_credentials, resolve_ctx,
- NULL /* events */, options);
+ NULL /* devtype */,
+ cmdline_credentials, resolve_ctx,
+ ev, options);
if (!NT_STATUS_IS_OK(ret)) {
fprintf(stderr, "%s: connecting to //%s/%s: %s\n",
@@ -293,6 +295,7 @@ static int open_smb_file(struct smbcli_state * cli,
}
static struct dd_iohandle * open_cifs_handle(struct resolve_context *resolve_ctx,
+ struct event_context *ev,
const char * host,
const char **ports,
const char * share,
@@ -319,7 +322,7 @@ static struct dd_iohandle * open_cifs_handle(struct resolve_context *resolve_ctx
smbh->h.io_write = smb_write_func;
smbh->h.io_seek = smb_seek_func;
- if ((smbh->cli = init_smb_session(resolve_ctx, host, ports, share,
+ if ((smbh->cli = init_smb_session(resolve_ctx, ev, host, ports, share,
smb_options)) == NULL) {
return(NULL);
}
@@ -336,6 +339,7 @@ static struct dd_iohandle * open_cifs_handle(struct resolve_context *resolve_ctx
/* ------------------------------------------------------------------------- */
struct dd_iohandle * dd_open_path(struct resolve_context *resolve_ctx,
+ struct event_context *ev,
const char * path,
const char **ports,
uint64_t io_size,
@@ -355,7 +359,7 @@ struct dd_iohandle * dd_open_path(struct resolve_context *resolve_ctx,
/* Skip over leading directory separators. */
while (*remain == '/' || *remain == '\\') { remain++; }
- return(open_cifs_handle(resolve_ctx, host, ports,
+ return(open_cifs_handle(resolve_ctx, ev, host, ports,
share, remain,
io_size, options, smb_options));
}
diff --git a/source4/client/client.c b/source4/client/client.c
index ef88913c4d..79cc1b5382 100644
--- a/source4/client/client.c
+++ b/source4/client/client.c
@@ -2546,7 +2546,9 @@ static void display_share_result(struct srvsvc_NetShareCtr1 *ctr1)
/****************************************************************************
try and browse available shares on a host
****************************************************************************/
-static bool browse_host(struct loadparm_context *lp_ctx, const char *query_host)
+static bool browse_host(struct loadparm_context *lp_ctx,
+ struct event_context *ev_ctx,
+ const char *query_host)
{
struct dcerpc_pipe *p;
char *binding;
@@ -2560,7 +2562,7 @@ static bool browse_host(struct loadparm_context *lp_ctx, const char *query_host)
status = dcerpc_pipe_connect(mem_ctx, &p, binding,
&ndr_table_srvsvc,
- cmdline_credentials, NULL,
+ cmdline_credentials, ev_ctx,
lp_ctx);
if (!NT_STATUS_IS_OK(status)) {
d_printf("Failed to connect to %s - %s\n",
@@ -3022,6 +3024,7 @@ static int process_stdin(struct smbclient_context *ctx)
return a connection to a server
*******************************************************/
static bool do_connect(struct smbclient_context *ctx,
+ struct event_context *ev_ctx,
struct resolve_context *resolve_ctx,
const char *specified_server, const char **ports,
const char *specified_share,
@@ -3045,8 +3048,7 @@ static bool do_connect(struct smbclient_context *ctx,
status = smbcli_full_connection(ctx, &ctx->cli, server, ports,
share, NULL, cred, resolve_ctx,
- event_context_init(NULL),
- options);
+ ev_ctx, options);
if (!NT_STATUS_IS_OK(status)) {
d_printf("Connection to \\\\%s\\%s failed - %s\n",
server, share, nt_errstr(status));
@@ -3060,9 +3062,12 @@ static bool do_connect(struct smbclient_context *ctx,
/****************************************************************************
handle a -L query
****************************************************************************/
-static int do_host_query(struct loadparm_context *lp_ctx, const char *query_host, const char *workgroup)
+static int do_host_query(struct loadparm_context *lp_ctx,
+ struct event_context *ev_ctx,
+ const char *query_host,
+ const char *workgroup)
{
- browse_host(lp_ctx, query_host);
+ browse_host(lp_ctx, ev_ctx, query_host);
list_servers(workgroup);
return(0);
}
@@ -3071,7 +3076,12 @@ static int do_host_query(struct loadparm_context *lp_ctx, const char *query_host
/****************************************************************************
handle a message operation
****************************************************************************/
-static int do_message_op(const char *netbios_name, const char *desthost, const char **destports, const char *destip, int name_type, struct resolve_context *resolve_ctx, struct smbcli_options *options)
+static int do_message_op(const char *netbios_name, const char *desthost,
+ const char **destports, const char *destip,
+ int name_type,
+ struct event_context *ev_ctx,
+ struct resolve_context *resolve_ctx,
+ struct smbcli_options *options)
{
struct nbt_name called, calling;
const char *server_name;
@@ -3083,7 +3093,9 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c
server_name = destip ? destip : desthost;
- if (!(cli=smbcli_state_init(NULL)) || !smbcli_socket_connect(cli, server_name, destports, resolve_ctx, options)) {
+ if (!(cli = smbcli_state_init(NULL)) ||
+ !smbcli_socket_connect(cli, server_name, destports,
+ ev_ctx, resolve_ctx, options)) {
d_printf("Connection to %s failed\n", server_name);
return 1;
}
@@ -3124,6 +3136,7 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c
int rc = 0;
int name_type = 0x20;
TALLOC_CTX *mem_ctx;
+ struct event_context *ev_ctx;
struct smbclient_context *ctx;
const char *cmdstr = NULL;
struct smbcli_options smb_options;
@@ -3221,6 +3234,8 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c
lp_smbcli_options(cmdline_lp_ctx, &smb_options);
+ ev_ctx = event_context_init(talloc_autofree_context());
+
DEBUG( 3, ( "Client started (version %s).\n", SAMBA_VERSION_STRING ) );
if (query_host && (p=strchr_m(query_host,'#'))) {
@@ -3230,14 +3245,23 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c
}
if (query_host) {
- return do_host_query(cmdline_lp_ctx, query_host, lp_workgroup(cmdline_lp_ctx));
+ rc = do_host_query(cmdline_lp_ctx, ev_ctx, query_host,
+ lp_workgroup(cmdline_lp_ctx));
+ return rc;
}
if (message) {
- return do_message_op(lp_netbios_name(cmdline_lp_ctx), desthost, lp_smb_ports(cmdline_lp_ctx), dest_ip, name_type, lp_resolve_context(cmdline_lp_ctx), &smb_options);
+ rc = do_message_op(lp_netbios_name(cmdline_lp_ctx), desthost,
+ lp_smb_ports(cmdline_lp_ctx), dest_ip,
+ name_type, ev_ctx,
+ lp_resolve_context(cmdline_lp_ctx),
+ &smb_options);
+ return rc;
}
- if (!do_connect(ctx, lp_resolve_context(cmdline_lp_ctx), desthost, lp_smb_ports(cmdline_lp_ctx), service, cmdline_credentials, &smb_options))
+ if (!do_connect(ctx, ev_ctx, lp_resolve_context(cmdline_lp_ctx),
+ desthost, lp_smb_ports(cmdline_lp_ctx), service,
+ cmdline_credentials, &smb_options))
return 1;
if (base_directory)
diff --git a/source4/dsdb/samdb/samdb.c b/source4/dsdb/samdb/samdb.c
index 4af7fb7963..9154f5382b 100644
--- a/source4/dsdb/samdb/samdb.c
+++ b/source4/dsdb/samdb/samdb.c
@@ -37,6 +37,7 @@
#include "dsdb/samdb/samdb.h"
#include "dsdb/common/flags.h"
#include "param/param.h"
+#include "lib/events/events.h"
char *samdb_relative_path(struct ldb_context *ldb,
TALLOC_CTX *mem_ctx,
@@ -116,6 +117,12 @@ int samdb_copy_template(struct ldb_context *ldb,
event_ctx = (struct event_context *)ldb_get_opaque(ldb, "EventContext");
lp_ctx = (struct loadparm_context *)ldb_get_opaque(ldb, "loadparm");
+ /* FIXME: need to remove this wehn we finally pass the event
+ * context around in ldb */
+ if (event_ctx == NULL) {
+ event_ctx = event_context_init(templates_ldb);
+ }
+
templates_ldb = ldb_wrap_connect(ldb, event_ctx, lp_ctx,
templates_ldb_path, NULL,
NULL, 0, NULL);
diff --git a/source4/lib/events/events.c b/source4/lib/events/events.c
index 568aadc31e..252af4443d 100644
--- a/source4/lib/events/events.c
+++ b/source4/lib/events/events.c
@@ -207,6 +207,8 @@ struct event_context *event_context_init_byname(TALLOC_CTX *mem_ctx, const char
*/
struct event_context *event_context_init(TALLOC_CTX *mem_ctx)
{
+ DEBUG(0, ("New event context requested. Parent: [%s:%p]\n",
+ mem_ctx?talloc_get_name(mem_ctx):"NULL", mem_ctx));
return event_context_init_byname(mem_ctx, NULL);
}
diff --git a/source4/lib/ldb/ldb_ildap/ldb_ildap.c b/source4/lib/ldb/ldb_ildap/ldb_ildap.c
index 79958a86eb..6b50b2f5eb 100644
--- a/source4/lib/ldb/ldb_ildap/ldb_ildap.c
+++ b/source4/lib/ldb/ldb_ildap/ldb_ildap.c
@@ -737,6 +737,7 @@ static int ildb_connect(struct ldb_context *ldb, const char *url,
struct ildb_private *ildb;
NTSTATUS status;
struct cli_credentials *creds;
+ struct event_context *event_ctx;
module = talloc(ldb, struct ldb_module);
if (!module) {
@@ -756,8 +757,19 @@ static int ildb_connect(struct ldb_context *ldb, const char *url,
}
module->private_data = ildb;
ildb->module = module;
- ildb->ldap = ldap4_new_connection(ildb, ldb_get_opaque(ldb, "loadparm"),
- ldb_get_opaque(ldb, "EventContext"));
+
+ event_ctx = ldb_get_opaque(ldb, "EventContext");
+
+ /* FIXME: We must make the event context an explicit parameter, but we
+ * need to build the events library separately first. Hack a new event
+ * context so that CMD line utilities work until we have libevents for
+ * standalone builds ready */
+ if (event_ctx == NULL) {
+ event_ctx = event_context_init(NULL);
+ }
+
+ ildb->ldap = ldap4_new_connection(ildb, ldb_get_opaque(ldb, "loadparm"),
+ event_ctx);
if (!ildb->ldap) {
ldb_oom(ldb);
goto failed;
diff --git a/source4/lib/ldb_wrap.c b/source4/lib/ldb_wrap.c
index b71adcbca2..b564976524 100644
--- a/source4/lib/ldb_wrap.c
+++ b/source4/lib/ldb_wrap.c
@@ -116,7 +116,7 @@ struct ldb_context *ldb_wrap_connect(TALLOC_CTX *mem_ctx,
talloc_asprintf(ldb, "%s/ldb", lp_modulesdir(lp_ctx)));
if (ev == NULL) {
- ev = event_context_find(mem_ctx);
+ return NULL;
}
if (ldb_set_opaque(ldb, "EventContext", ev)) {
diff --git a/source4/lib/messaging/messaging.c b/source4/lib/messaging/messaging.c
index 29d6e00247..19284461ee 100644
--- a/source4/lib/messaging/messaging.c
+++ b/source4/lib/messaging/messaging.c
@@ -544,6 +544,10 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
NTSTATUS status;
struct socket_address *path;
+ if (ev == NULL) {
+ return NULL;
+ }
+
msg = talloc_zero(mem_ctx, struct messaging_context);
if (msg == NULL) {
return NULL;
@@ -556,10 +560,6 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
return NULL;
}
- if (ev == NULL) {
- ev = event_context_init(msg);
- }
-
/* create the messaging directory if needed */
mkdir(dir, 0700);
diff --git a/source4/lib/socket/testsuite.c b/source4/lib/socket/testsuite.c
index 813412c7bc..2c25d8f491 100644
--- a/source4/lib/socket/testsuite.c
+++ b/source4/lib/socket/testsuite.c
@@ -124,7 +124,7 @@ static bool test_tcp(struct torture_context *tctx)
DATA_BLOB blob, blob2;
size_t sent, nread;
TALLOC_CTX *mem_ctx = tctx;
- struct event_context *ev = event_context_init(mem_ctx);
+ struct event_context *ev = tctx->ev;
struct interface *ifaces;
status = socket_create("ip", SOCKET_TYPE_STREAM, &sock1, 0);
diff --git a/source4/libcli/cldap/cldap.c b/source4/libcli/cldap/cldap.c
index d9910285d9..614bd51d2a 100644
--- a/source4/libcli/cldap/cldap.c
+++ b/source4/libcli/cldap/cldap.c
@@ -250,11 +250,7 @@ struct cldap_socket *cldap_socket_init(TALLOC_CTX *mem_ctx,
cldap = talloc(mem_ctx, struct cldap_socket);
if (cldap == NULL) goto failed;
- if (event_ctx == NULL) {
- cldap->event_ctx = event_context_init(cldap);
- } else {
- cldap->event_ctx = talloc_reference(cldap, event_ctx);
- }
+ cldap->event_ctx = talloc_reference(cldap, event_ctx);
if (cldap->event_ctx == NULL) goto failed;
cldap->idr = idr_init(cldap);
diff --git a/source4/libcli/cliconnect.c b/source4/libcli/cliconnect.c
index 4858a96110..c20a7fd935 100644
--- a/source4/libcli/cliconnect.c
+++ b/source4/libcli/cliconnect.c
@@ -33,13 +33,14 @@
*/
bool smbcli_socket_connect(struct smbcli_state *cli, const char *server,
const char **ports,
+ struct event_context *ev_ctx,
struct resolve_context *resolve_ctx,
struct smbcli_options *options)
{
struct smbcli_socket *sock;
- sock = smbcli_sock_connect_byname(server, ports, NULL, resolve_ctx,
- NULL);
+ sock = smbcli_sock_connect_byname(server, ports, NULL,
+ resolve_ctx, ev_ctx);
if (sock == NULL) return false;
diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c
index 26169e7838..966f56cba8 100644
--- a/source4/libcli/composite/composite.c
+++ b/source4/libcli/composite/composite.c
@@ -42,7 +42,11 @@ _PUBLIC_ struct composite_context *composite_create(TALLOC_CTX *mem_ctx,
c = talloc_zero(mem_ctx, struct composite_context);
if (!c) return NULL;
c->state = COMPOSITE_STATE_IN_PROGRESS;
- c->event_ctx = ev;
+ c->event_ctx = talloc_reference(c, ev);
+ if (!c->event_ctx) {
+ talloc_free(c);
+ return NULL;
+ }
return c;
}
diff --git a/source4/libcli/dgram/dgramsocket.c b/source4/libcli/dgram/dgramsocket.c
index 130d8ae870..06b7bd5771 100644
--- a/source4/libcli/dgram/dgramsocket.c
+++ b/source4/libcli/dgram/dgramsocket.c
@@ -167,11 +167,7 @@ struct nbt_dgram_socket *nbt_dgram_socket_init(TALLOC_CTX *mem_ctx,
dgmsock = talloc(mem_ctx, struct nbt_dgram_socket);
if (dgmsock == NULL) goto failed;
- if (event_ctx == NULL) {
- dgmsock->event_ctx = event_context_init(dgmsock);
- } else {
- dgmsock->event_ctx = talloc_reference(dgmsock, event_ctx);
- }
+ dgmsock->event_ctx = talloc_reference(dgmsock, event_ctx);
if (dgmsock->event_ctx == NULL) goto failed;
status = socket_create("ip", SOCKET_TYPE_DGRAM, &dgmsock->sock, 0);
diff --git a/source4/libcli/ldap/ldap_bind.c b/source4/libcli/ldap/ldap_bind.c
index 2c04edf950..e1569e7296 100644
--- a/source4/libcli/ldap/ldap_bind.c
+++ b/source4/libcli/ldap/ldap_bind.c
@@ -200,7 +200,7 @@ static struct ldap_message *new_ldap_sasl_bind_msg(struct ldap_connection *conn,
/*
perform a sasl bind using the given credentials
*/
-_PUBLIC_ NTSTATUS ldap_bind_sasl(struct ldap_connection *conn,
+_PUBLIC_ NTSTATUS ldap_bind_sasl(struct ldap_connection *conn,
struct cli_credentials *creds,
struct loadparm_context *lp_ctx)
{
@@ -223,7 +223,8 @@ _PUBLIC_ NTSTATUS ldap_bind_sasl(struct ldap_connection *conn,
gensec_init(lp_ctx);
- status = gensec_client_start(conn, &conn->gensec, NULL, lp_ctx);
+ status = gensec_client_start(conn, &conn->gensec,
+ conn->event.event_ctx, lp_ctx);
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/ldap/ldap_client.c b/source4/libcli/ldap/ldap_client.c
index 296a7b11f2..bca867b033 100644
--- a/source4/libcli/ldap/ldap_client.c
+++ b/source4/libcli/ldap/ldap_client.c
@@ -48,17 +48,13 @@ _PUBLIC_ struct ldap_connection *ldap4_new_connection(TALLOC_CTX *mem_ctx,
{
struct ldap_connection *conn;
- conn = talloc_zero(mem_ctx, struct ldap_connection);
- if (conn == NULL) {
+ if (ev == NULL) {
return NULL;
}
- if (ev == NULL) {
- ev = event_context_init(conn);
- if (ev == NULL) {
- talloc_free(conn);
- return NULL;
- }
+ conn = talloc_zero(mem_ctx, struct ldap_connection);
+ if (conn == NULL) {
+ return NULL;
}
conn->next_messageid = 1;
diff --git a/source4/libcli/nbt/nbtsocket.c b/source4/libcli/nbt/nbtsocket.c
index 747127980a..5d4611e2d9 100644
--- a/source4/libcli/nbt/nbtsocket.c
+++ b/source4/libcli/nbt/nbtsocket.c
@@ -318,11 +318,7 @@ _PUBLIC_ struct nbt_name_socket *nbt_name_socket_init(TALLOC_CTX *mem_ctx,
nbtsock = talloc(mem_ctx, struct nbt_name_socket);
if (nbtsock == NULL) goto failed;
- if (event_ctx == NULL) {
- nbtsock->event_ctx = event_context_init(nbtsock);
- } else {
- nbtsock->event_ctx = talloc_reference(nbtsock, event_ctx);
- }
+ nbtsock->event_ctx = talloc_reference(nbtsock, event_ctx);
if (nbtsock->event_ctx == NULL) goto failed;
status = socket_create("ip", SOCKET_TYPE_DGRAM, &nbtsock->sock, 0);
diff --git a/source4/libcli/raw/clisocket.c b/source4/libcli/raw/clisocket.c
index 1dcf2d1c53..49838e8a1c 100644
--- a/source4/libcli/raw/clisocket.c
+++ b/source4/libcli/raw/clisocket.c
@@ -59,12 +59,7 @@ struct composite_context *smbcli_sock_connect_send(TALLOC_CTX *mem_ctx,
if (result == NULL) goto failed;
result->state = COMPOSITE_STATE_IN_PROGRESS;
- if (event_ctx != NULL) {
- result->event_ctx = talloc_reference(result, event_ctx);
- } else {
- result->event_ctx = event_context_init(result);
- }
-
+ result->event_ctx = talloc_reference(result, event_ctx);
if (result->event_ctx == NULL) goto failed;
state = talloc(result, struct sock_connect_state);
@@ -202,6 +197,11 @@ _PUBLIC_ struct smbcli_socket *smbcli_sock_connect_byname(const char *host, cons
TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
struct smbcli_socket *result;
+ if (event_ctx == NULL) {
+ DEBUG(0, ("Invalid NULL event context passed in as parameter\n"));
+ return NULL;
+ }
+
if (tmp_ctx == NULL) {
DEBUG(0, ("talloc_new failed\n"));
return NULL;
@@ -214,16 +214,6 @@ _PUBLIC_ struct smbcli_socket *smbcli_sock_connect_byname(const char *host, cons
return NULL;
}
- if (event_ctx == NULL) {
- event_ctx = event_context_init(mem_ctx);
- }
-
- if (event_ctx == NULL) {
- DEBUG(0, ("event_context_init failed\n"));
- talloc_free(tmp_ctx);
- return NULL;
- }
-
/* allow hostnames of the form NAME#xx and do a netbios lookup */
if ((p = strchr(name, '#'))) {
name_type = strtol(p+1, NULL, 16);
diff --git a/source4/libcli/resolve/host.c b/source4/libcli/resolve/host.c
index 4b8f3f9553..1a695432ee 100644
--- a/source4/libcli/resolve/host.c
+++ b/source4/libcli/resolve/host.c
@@ -135,7 +135,6 @@ struct composite_context *resolve_name_host_send(TALLOC_CTX *mem_ctx,
c = composite_create(mem_ctx, event_ctx);
if (c == NULL) return NULL;
- c->event_ctx = talloc_reference(c, event_ctx);
if (composite_nomem(c->event_ctx, c)) return c;
state = talloc(c, struct host_state);
diff --git a/source4/libcli/resolve/nbtlist.c b/source4/libcli/resolve/nbtlist.c
index 887bdd7ecf..8f085c5404 100644
--- a/source4/libcli/resolve/nbtlist.c
+++ b/source4/libcli/resolve/nbtlist.c
@@ -110,10 +110,9 @@ struct composite_context *resolve_name_nbtlist_send(TALLOC_CTX *mem_ctx,
struct nbtlist_state *state;
int i;
- c = composite_create(event_ctx, event_ctx);
+ c = composite_create(mem_ctx, event_ctx);
if (c == NULL) return NULL;
- c->event_ctx = talloc_reference(c, event_ctx);
if (composite_nomem(c->event_ctx, c)) return c;
state = talloc(c, struct nbtlist_state);
diff --git a/source4/libcli/resolve/resolve.c b/source4/libcli/resolve/resolve.c
index 33ace09443..aaf9ff1f8d 100644
--- a/source4/libcli/resolve/resolve.c
+++ b/source4/libcli/resolve/resolve.c
@@ -136,19 +136,14 @@ struct composite_context *resolve_name_send(struct resolve_context *ctx,
struct composite_context *c;
struct resolve_state *state;
- c = composite_create(event_ctx, event_ctx);
- if (c == NULL) return NULL;
-
- if (ctx == NULL) {
+ if (ctx == NULL || event_ctx == NULL) {
composite_error(c, NT_STATUS_INVALID_PARAMETER);
return c;
}
- if (event_ctx == NULL) {
- c->event_ctx = event_context_init(c);
- } else {
- c->event_ctx = talloc_reference(c, event_ctx);
- }
+ c = composite_create(ctx, event_ctx);
+ if (c == NULL) return NULL;
+
if (composite_nomem(c->event_ctx, c)) return c;
state = talloc(c, struct resolve_state);
diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c
index c44c62f868..c4abfa5e37 100644
--- a/source4/libcli/smb_composite/connect.c
+++ b/source4/libcli/smb_composite/connect.c
@@ -451,17 +451,15 @@ struct composite_context *smb_composite_connect_send(struct smb_composite_connec
c = talloc_zero(mem_ctx, struct composite_context);
if (c == NULL) goto failed;
+ c->event_ctx = talloc_reference(c, event_ctx);
+ if (c->event_ctx == NULL) goto failed;
+
state = talloc_zero(c, struct connect_state);
if (state == NULL) goto failed;
- if (event_ctx == NULL) {
- event_ctx = event_context_init(mem_ctx);
- }
-
state->io = io;
c->state = COMPOSITE_STATE_IN_PROGRESS;
- c->event_ctx = talloc_reference(c, event_ctx);
c->private_data = state;
state->stage = CONNECT_RESOLVE;
diff --git a/source4/libcli/smb_composite/fetchfile.c b/source4/libcli/smb_composite/fetchfile.c
index d8d7481270..9cd02a51f4 100644
--- a/source4/libcli/smb_composite/fetchfile.c
+++ b/source4/libcli/smb_composite/fetchfile.c
@@ -62,7 +62,6 @@ static NTSTATUS fetchfile_connect(struct composite_context *c,
state->creq->async.fn = fetchfile_composite_handler;
state->stage = FETCHFILE_READ;
- c->event_ctx = talloc_reference(c, state->creq->event_ctx);
return NT_STATUS_OK;
}
@@ -158,7 +157,6 @@ struct composite_context *smb_composite_fetchfile_send(struct smb_composite_fetc
c->state = COMPOSITE_STATE_IN_PROGRESS;
state->stage = FETCHFILE_CONNECT;
- c->event_ctx = talloc_reference(c, state->creq->event_ctx);
c->private_data = state;
return c;
diff --git a/source4/libcli/smb_composite/fsinfo.c b/source4/libcli/smb_composite/fsinfo.c
index 2ec13df9b6..270d71f518 100644
--- a/source4/libcli/smb_composite/fsinfo.c
+++ b/source4/libcli/smb_composite/fsinfo.c
@@ -52,7 +52,6 @@ static NTSTATUS fsinfo_connect(struct composite_context *c,
state->req->async.fn = fsinfo_raw_handler;
state->stage = FSINFO_QUERY;
- c->event_ctx = talloc_reference(c, state->req->session->transport->socket->event.ctx);
return NT_STATUS_OK;
}
@@ -158,7 +157,6 @@ struct composite_context *smb_composite_fsinfo_send(struct smbcli_tree *tree,
c->state = COMPOSITE_STATE_IN_PROGRESS;
state->stage = FSINFO_CONNECT;
- c->event_ctx = talloc_reference(c, tree->session->transport->socket->event.ctx);
c->private_data = state;
state->creq = smb_composite_connect_send(state->connect, state,
diff --git a/source4/libcli/wrepl/winsrepl.c b/source4/libcli/wrepl/winsrepl.c
index 3e7793c0c7..0a4e52bd7b 100644
--- a/source4/libcli/wrepl/winsrepl.c
+++ b/source4/libcli/wrepl/winsrepl.c
@@ -172,11 +172,7 @@ struct wrepl_socket *wrepl_socket_init(TALLOC_CTX *mem_ctx,
wrepl_socket = talloc_zero(mem_ctx, struct wrepl_socket);
if (!wrepl_socket) return NULL;
- if (event_ctx == NULL) {
- wrepl_socket->event.ctx = event_context_init(wrepl_socket);
- } else {
- wrepl_socket->event.ctx = talloc_reference(wrepl_socket, event_ctx);
- }
+ wrepl_socket->event.ctx = talloc_reference(wrepl_socket, event_ctx);
if (!wrepl_socket->event.ctx) goto failed;
wrepl_socket->iconv_convenience = iconv_convenience;
diff --git a/source4/libnet/libnet_site.c b/source4/libnet/libnet_site.c
index dabd23a5be..f39d9e039c 100644
--- a/source4/libnet/libnet_site.c
+++ b/source4/libnet/libnet_site.c
@@ -30,7 +30,7 @@
* 1. Setup a CLDAP socket.
* 2. Lookup the default Site-Name.
*/
-NTSTATUS libnet_FindSite(TALLOC_CTX *ctx, struct libnet_JoinSite *r)
+NTSTATUS libnet_FindSite(TALLOC_CTX *ctx, struct libnet_context *lctx, struct libnet_JoinSite *r)
{
NTSTATUS status;
TALLOC_CTX *tmp_ctx;
@@ -55,7 +55,7 @@ NTSTATUS libnet_FindSite(TALLOC_CTX *ctx, struct libnet_JoinSite *r)
search.in.acct_control = -1;
search.in.version = 6;
- cldap = cldap_socket_init(tmp_ctx, NULL, lp_iconv_convenience(global_loadparm));
+ cldap = cldap_socket_init(tmp_ctx, lctx->event_ctx, lp_iconv_convenience(global_loadparm));
status = cldap_netlogon(cldap, tmp_ctx, &search);
if (!NT_STATUS_IS_OK(status)) {
/*
@@ -148,7 +148,7 @@ NTSTATUS libnet_JoinSite(struct libnet_context *ctx,
}
make_nbt_name_client(&name, libnet_r->out.samr_binding->host);
- status = resolve_name(lp_resolve_context(ctx->lp_ctx), &name, r, &dest_addr, NULL);
+ status = resolve_name(lp_resolve_context(ctx->lp_ctx), &name, r, &dest_addr, ctx->event_ctx);
if (!NT_STATUS_IS_OK(status)) {
libnet_r->out.error_string = NULL;
talloc_free(tmp_ctx);
@@ -161,7 +161,7 @@ NTSTATUS libnet_JoinSite(struct libnet_context *ctx,
r->in.domain_dn_str = libnet_r->out.domain_dn_str;
r->in.cldap_port = lp_cldap_port(ctx->lp_ctx);
- status = libnet_FindSite(tmp_ctx, r);
+ status = libnet_FindSite(tmp_ctx, ctx, r);
if (!NT_STATUS_IS_OK(status)) {
libnet_r->out.error_string =
talloc_steal(libnet_r, r->out.error_string);
diff --git a/source4/librpc/rpc/dcerpc.c b/source4/librpc/rpc/dcerpc.c
index 5e32f6f5bf..4758189d3b 100644
--- a/source4/librpc/rpc/dcerpc.c
+++ b/source4/librpc/rpc/dcerpc.c
@@ -67,22 +67,15 @@ static 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->iconv_convenience = talloc_reference(c, ic);
- c->event_ctx = ev;
-
- if (!talloc_reference(c, ev)) {
+ c->event_ctx = talloc_reference(c, ev);
+
+ if (c->event_ctx == NULL) {
talloc_free(c);
return NULL;
}
+
c->call_id = 1;
c->security_state.auth_info = NULL;
c->security_state.session_key = dcerpc_generic_session_key;
diff --git a/source4/librpc/rpc/dcerpc_connect.c b/source4/librpc/rpc/dcerpc_connect.c
index cc7f2ddbaa..a22cad9a4a 100644
--- a/source4/librpc/rpc/dcerpc_connect.c
+++ b/source4/librpc/rpc/dcerpc_connect.c
@@ -717,12 +717,6 @@ _PUBLIC_ struct composite_context* dcerpc_pipe_connect_b_send(TALLOC_CTX *parent
struct pipe_connect_state *s;
struct event_context *new_ev = NULL;
- if (ev == NULL) {
- new_ev = event_context_init(parent_ctx);
- if (new_ev == NULL) return NULL;
- ev = new_ev;
- }
-
/* composite context allocation and setup */
c = composite_create(parent_ctx, ev);
if (c == NULL) {
@@ -844,21 +838,12 @@ _PUBLIC_ struct composite_context* dcerpc_pipe_connect_send(TALLOC_CTX *parent_c
struct pipe_conn_state *s;
struct dcerpc_binding *b;
struct composite_context *pipe_conn_req;
- struct event_context *new_ev = NULL;
-
- if (ev == NULL) {
- new_ev = event_context_init(parent_ctx);
- if (new_ev == NULL) return NULL;
- ev = new_ev;
- }
/* composite context allocation and setup */
c = composite_create(parent_ctx, ev);
if (c == NULL) {
- talloc_free(new_ev);
return NULL;
}
- talloc_steal(c, new_ev);
s = talloc_zero(c, struct pipe_conn_state);
if (composite_nomem(s, c)) return c;
diff --git a/source4/rpc_server/spoolss/dcesrv_spoolss.c b/source4/rpc_server/spoolss/dcesrv_spoolss.c
index 46270727a4..28e30002e2 100644
--- a/source4/rpc_server/spoolss/dcesrv_spoolss.c
+++ b/source4/rpc_server/spoolss/dcesrv_spoolss.c
@@ -1156,7 +1156,8 @@ static WERROR dcesrv_spoolss_RemoteFindFirstPrinterChangeNotifyEx(struct dcesrv_
creds = cli_credentials_init_anon(mem_ctx); /* FIXME: Use machine credentials instead ? */
status = dcerpc_pipe_connect_b(mem_ctx, &p, binding, &ndr_table_spoolss,
- creds, NULL, dce_call->conn->dce_ctx->lp_ctx);
+ creds, dce_call->event_ctx,
+ dce_call->conn->dce_ctx->lp_ctx);
if (NT_STATUS_IS_ERR(status)) {
DEBUG(0, ("unable to call back to %s\n", r->in.str));
diff --git a/source4/torture/auth/ntlmssp.c b/source4/torture/auth/ntlmssp.c
index 917a24ad59..739a048d29 100644
--- a/source4/torture/auth/ntlmssp.c
+++ b/source4/torture/auth/ntlmssp.c
@@ -33,7 +33,8 @@ static bool torture_ntlmssp_self_check(struct torture_context *tctx)
TALLOC_CTX *mem_ctx = tctx;
torture_assert_ntstatus_ok(tctx,
- gensec_client_start(mem_ctx, &gensec_security, NULL, tctx->lp_ctx),
+ gensec_client_start(mem_ctx, &gensec_security,
+ tctx->ev, tctx->lp_ctx),
"gensec client start");
gensec_set_credentials(gensec_security, cmdline_credentials);
@@ -87,7 +88,8 @@ static bool torture_ntlmssp_self_check(struct torture_context *tctx)
talloc_free(gensec_security);
torture_assert_ntstatus_ok(tctx,
- gensec_client_start(mem_ctx, &gensec_security, NULL, tctx->lp_ctx),
+ gensec_client_start(mem_ctx, &gensec_security,
+ tctx->ev, tctx->lp_ctx),
"Failed to start GENSEC for NTLMSSP");
gensec_set_credentials(gensec_security, cmdline_credentials);
diff --git a/source4/torture/basic/base.c b/source4/torture/basic/base.c
index 3a3a7c2fd5..966d436935 100644
--- a/source4/torture/basic/base.c
+++ b/source4/torture/basic/base.c
@@ -55,7 +55,8 @@ static struct smbcli_state *open_nbt_connection(struct torture_context *tctx)
lp_smbcli_options(tctx->lp_ctx, &options);
- if (!smbcli_socket_connect(cli, host, lp_smb_ports(tctx->lp_ctx), lp_resolve_context(tctx->lp_ctx), &options)) {
+ if (!smbcli_socket_connect(cli, host, lp_smb_ports(tctx->lp_ctx), tctx->ev,
+ lp_resolve_context(tctx->lp_ctx), &options)) {
torture_comment(tctx, "Failed to connect with %s\n", host);
goto failed;
}
diff --git a/source4/torture/config.mk b/source4/torture/config.mk
index 2f3fa38863..1565797609 100644
--- a/source4/torture/config.mk
+++ b/source4/torture/config.mk
@@ -86,6 +86,7 @@ TORTURE_RAW_OBJ_FILES = $(addprefix torture/raw/, \
lock.o \
pingpong.o \
lockbench.o \
+ lookuprate.o \
openbench.o \
rename.o \
eas.o \
diff --git a/source4/torture/gentest.c b/source4/torture/gentest.c
index 6d872c687b..ae18fe809c 100644
--- a/source4/torture/gentest.c
+++ b/source4/torture/gentest.c
@@ -19,6 +19,7 @@
#include "includes.h"
#include "lib/cmdline/popt_common.h"
+#include "lib/events/events.h"
#include "system/time.h"
#include "system/filesys.h"
#include "libcli/raw/request.h"
@@ -154,7 +155,8 @@ static bool connect_servers_fast(void)
/*****************************************************
connect to the servers
*******************************************************/
-static bool connect_servers(struct loadparm_context *lp_ctx)
+static bool connect_servers(struct event_context *ev,
+ struct loadparm_context *lp_ctx)
{
int i, j;
@@ -193,7 +195,7 @@ static bool connect_servers(struct loadparm_context *lp_ctx)
servers[i].share_name, NULL,
servers[i].credentials,
lp_resolve_context(lp_ctx),
- NULL, &smb_options);
+ ev, &smb_options);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to connect to \\\\%s\\%s - %s\n",
servers[i].server_name, servers[i].share_name,
@@ -1937,11 +1939,11 @@ static struct {
run the test with the current set of op_parms parameters
return the number of operations that completed successfully
*/
-static int run_test(struct loadparm_context *lp_ctx)
+static int run_test(struct event_context *ev, struct loadparm_context *lp_ctx)
{
int op, i;
- if (!connect_servers(lp_ctx)) {
+ if (!connect_servers(ev, lp_ctx)) {
printf("Failed to connect to servers\n");
exit(1);
}
@@ -2018,7 +2020,8 @@ static int run_test(struct loadparm_context *lp_ctx)
perform a backtracking analysis of the minimal set of operations
to generate an error
*/
-static void backtrack_analyze(struct loadparm_context *lp_ctx)
+static void backtrack_analyze(struct event_context *ev,
+ struct loadparm_context *lp_ctx)
{
int chunk, ret;
@@ -2039,7 +2042,7 @@ static void backtrack_analyze(struct loadparm_context *lp_ctx)
}
printf("Testing %d ops with %d-%d disabled\n",
options.numops, base, max-1);
- ret = run_test(lp_ctx);
+ ret = run_test(ev, lp_ctx);
printf("Completed %d of %d ops\n", ret, options.numops);
for (i=base;i<max; i++) {
op_parms[i].disabled = false;
@@ -2071,7 +2074,7 @@ static void backtrack_analyze(struct loadparm_context *lp_ctx)
} while (chunk > 0);
printf("Reduced to %d ops\n", options.numops);
- ret = run_test(lp_ctx);
+ ret = run_test(ev, lp_ctx);
if (ret != options.numops - 1) {
printf("Inconsistent result? ret=%d numops=%d\n", ret, options.numops);
}
@@ -2080,7 +2083,8 @@ static void backtrack_analyze(struct loadparm_context *lp_ctx)
/*
start the main gentest process
*/
-static bool start_gentest(struct loadparm_context *lp_ctx)
+static bool start_gentest(struct event_context *ev,
+ struct loadparm_context *lp_ctx)
{
int op;
int ret;
@@ -2116,15 +2120,15 @@ static bool start_gentest(struct loadparm_context *lp_ctx)
}
}
- ret = run_test(lp_ctx);
+ ret = run_test(ev, lp_ctx);
if (ret != options.numops && options.analyze) {
options.numops = ret+1;
- backtrack_analyze(lp_ctx);
+ backtrack_analyze(ev, lp_ctx);
} else if (options.analyze_always) {
- backtrack_analyze(lp_ctx);
+ backtrack_analyze(ev, lp_ctx);
} else if (options.analyze_continuous) {
- while (run_test(lp_ctx) == options.numops) ;
+ while (run_test(ev, lp_ctx) == options.numops) ;
}
return ret == options.numops;
@@ -2171,6 +2175,7 @@ static bool split_unc_name(const char *unc, char **server, char **share)
int i, username_count=0;
bool ret;
char *ignore_file=NULL;
+ struct event_context *ev;
struct loadparm_context *lp_ctx;
poptContext pc;
int argc_new;
@@ -2278,9 +2283,11 @@ static bool split_unc_name(const char *unc, char **server, char **share)
printf("seed=%u\n", options.seed);
+ ev = event_context_init(talloc_autofree_context());
+
gensec_init(lp_ctx);
- ret = start_gentest(lp_ctx);
+ ret = start_gentest(ev, lp_ctx);
if (ret) {
printf("gentest completed - no errors\n");
diff --git a/source4/torture/ldap/cldap.c b/source4/torture/ldap/cldap.c
index dbe9d2f9a4..ca4d9b7705 100644
--- a/source4/torture/ldap/cldap.c
+++ b/source4/torture/ldap/cldap.c
@@ -38,13 +38,15 @@
*/
static bool test_cldap_netlogon(struct torture_context *tctx, const char *dest)
{
- struct cldap_socket *cldap = cldap_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ struct cldap_socket *cldap;
NTSTATUS status;
struct cldap_netlogon search, empty_search;
union nbt_cldap_netlogon n1;
struct GUID guid;
int i;
+ cldap = cldap_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
+
ZERO_STRUCT(search);
search.in.dest_address = dest;
search.in.dest_port = lp_cldap_port(tctx->lp_ctx);
@@ -244,13 +246,15 @@ static void cldap_dump_results(struct cldap_search *search)
*/
static bool test_cldap_generic(struct torture_context *tctx, const char *dest)
{
- struct cldap_socket *cldap = cldap_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ struct cldap_socket *cldap;
NTSTATUS status;
struct cldap_search search;
const char *attrs1[] = { "currentTime", "highestCommittedUSN", NULL };
const char *attrs2[] = { "currentTime", "highestCommittedUSN", "netlogon", NULL };
const char *attrs3[] = { "netlogon", NULL };
+ cldap = cldap_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
+
ZERO_STRUCT(search);
search.in.dest_address = dest;
search.in.dest_port = lp_cldap_port(tctx->lp_ctx);
diff --git a/source4/torture/ldap/cldapbench.c b/source4/torture/ldap/cldapbench.c
index 51586ac733..df2a5b0551 100644
--- a/source4/torture/ldap/cldapbench.c
+++ b/source4/torture/ldap/cldapbench.c
@@ -51,7 +51,7 @@ static void request_handler(struct cldap_request *req)
*/
static bool bench_cldap(struct torture_context *tctx, const char *address)
{
- struct cldap_socket *cldap = cldap_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ struct cldap_socket *cldap;
int num_sent=0;
struct timeval tv = timeval_current();
bool ret = true;
@@ -59,6 +59,8 @@ static bool bench_cldap(struct torture_context *tctx, const char *address)
struct cldap_netlogon search;
struct bench_state *state;
+ cldap = cldap_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
+
state = talloc_zero(tctx, struct bench_state);
ZERO_STRUCT(search);
diff --git a/source4/torture/ldap/common.c b/source4/torture/ldap/common.c
index 65b02ed5e8..5913163822 100644
--- a/source4/torture/ldap/common.c
+++ b/source4/torture/ldap/common.c
@@ -65,7 +65,7 @@ NTSTATUS torture_ldap_connection(struct torture_context *tctx,
return NT_STATUS_INVALID_PARAMETER;
}
- *conn = ldap4_new_connection(tctx, tctx->lp_ctx, NULL);
+ *conn = ldap4_new_connection(tctx, tctx->lp_ctx, tctx->ev);
status = ldap_connect(*conn, url);
if (!NT_STATUS_IS_OK(status)) {
diff --git a/source4/torture/libnet/libnet_domain.c b/source4/torture/libnet/libnet_domain.c
index eb6abc45d5..7d5be368c2 100644
--- a/source4/torture/libnet/libnet_domain.c
+++ b/source4/torture/libnet/libnet_domain.c
@@ -201,7 +201,7 @@ bool torture_domain_close_lsa(struct torture_context *torture)
mem_ctx = talloc_init("torture_domain_close_lsa");
status = dcerpc_pipe_connect_b(mem_ctx, &p, binding, &ndr_table_lsarpc,
- cmdline_credentials, NULL, torture->lp_ctx);
+ cmdline_credentials, torture->ev, torture->lp_ctx);
if (!NT_STATUS_IS_OK(status)) {
d_printf("failed to connect to server: %s\n", nt_errstr(status));
ret = false;
@@ -330,7 +330,7 @@ bool torture_domain_close_samr(struct torture_context *torture)
mem_ctx = talloc_init("torture_domain_close_samr");
status = dcerpc_pipe_connect_b(mem_ctx, &p, binding, &ndr_table_samr,
- ctx->cred, NULL, torture->lp_ctx);
+ ctx->cred, torture->ev, torture->lp_ctx);
if (!NT_STATUS_IS_OK(status)) {
d_printf("failed to connect to server: %s\n", nt_errstr(status));
ret = false;
diff --git a/source4/torture/locktest.c b/source4/torture/locktest.c
index 618568acf9..8959232edb 100644
--- a/source4/torture/locktest.c
+++ b/source4/torture/locktest.c
@@ -19,6 +19,7 @@
#include "includes.h"
#include "lib/cmdline/popt_common.h"
+#include "lib/events/events.h"
#include "system/filesys.h"
#include "system/time.h"
#include "pstring.h"
@@ -107,7 +108,8 @@ static struct record *recorded;
/*****************************************************
return a connection to a server
*******************************************************/
-static struct smbcli_state *connect_one(struct loadparm_context *lp_ctx,
+static struct smbcli_state *connect_one(struct event_context *ev,
+ struct loadparm_context *lp_ctx,
char *share, int snum, int conn)
{
struct smbcli_state *c;
@@ -162,7 +164,7 @@ static struct smbcli_state *connect_one(struct loadparm_context *lp_ctx,
share, NULL,
servers[snum],
lp_resolve_context(lp_ctx),
- NULL, &options);
+ ev, &options);
if (!NT_STATUS_IS_OK(status)) {
sleep(2);
}
@@ -176,7 +178,8 @@ static struct smbcli_state *connect_one(struct loadparm_context *lp_ctx,
}
-static void reconnect(struct loadparm_context *lp_ctx,
+static void reconnect(struct event_context *ev,
+ struct loadparm_context *lp_ctx,
struct smbcli_state *cli[NSERVERS][NCONNECTIONS], int fnum[NSERVERS][NCONNECTIONS][NFILES],
char *share[NSERVERS])
{
@@ -193,7 +196,7 @@ static void reconnect(struct loadparm_context *lp_ctx,
}
talloc_free(cli[server][conn]);
}
- cli[server][conn] = connect_one(lp_ctx, share[server],
+ cli[server][conn] = connect_one(ev, lp_ctx, share[server],
server, conn);
if (!cli[server][conn]) {
DEBUG(0,("Failed to connect to %s\n", share[server]));
@@ -396,7 +399,9 @@ static int retest(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
we then do random locking ops in tamdem on the 4 fnums from each
server and ensure that the results match
*/
-static int test_locks(struct loadparm_context *lp_ctx, char *share[NSERVERS])
+static int test_locks(struct event_context *ev,
+ struct loadparm_context *lp_ctx,
+ char *share[NSERVERS])
{
struct smbcli_state *cli[NSERVERS][NCONNECTIONS];
int fnum[NSERVERS][NCONNECTIONS][NFILES];
@@ -447,7 +452,7 @@ static int test_locks(struct loadparm_context *lp_ctx, char *share[NSERVERS])
#endif
}
- reconnect(lp_ctx, cli, fnum, share);
+ reconnect(ev, lp_ctx, cli, fnum, share);
open_files(cli, fnum);
n = retest(cli, fnum, numops);
@@ -465,7 +470,7 @@ static int test_locks(struct loadparm_context *lp_ctx, char *share[NSERVERS])
n1 = n;
close_files(cli, fnum);
- reconnect(lp_ctx, cli, fnum, share);
+ reconnect(ev, lp_ctx, cli, fnum, share);
open_files(cli, fnum);
for (i=0;i<n-skip;i+=skip) {
@@ -503,7 +508,7 @@ static int test_locks(struct loadparm_context *lp_ctx, char *share[NSERVERS])
}
close_files(cli, fnum);
- reconnect(lp_ctx, cli, fnum, share);
+ reconnect(ev, lp_ctx, cli, fnum, share);
open_files(cli, fnum);
showall = true;
n1 = retest(cli, fnum, n);
@@ -543,6 +548,7 @@ static void usage(poptContext pc)
int opt;
int seed, server;
int username_count=0;
+ struct event_context *ev;
struct loadparm_context *lp_ctx;
poptContext pc;
int argc_new, i;
@@ -631,12 +637,14 @@ static void usage(poptContext pc)
servers[1] = servers[0];
}
+ ev = event_context_init(talloc_autofree_context());
+
gensec_init(lp_ctx);
DEBUG(0,("seed=%u base=%d range=%d min_length=%d\n",
seed, lock_base, lock_range, min_length));
srandom(seed);
- return test_locks(lp_ctx, share);
+ return test_locks(ev, lp_ctx, share);
}
diff --git a/source4/torture/locktest2.c b/source4/torture/locktest2.c
index 0fe3725385..1784a0a729 100644
--- a/source4/torture/locktest2.c
+++ b/source4/torture/locktest2.c
@@ -19,6 +19,7 @@
#include "includes.h"
#include "system/passwd.h"
+#include "lib/events/events.h"
static fstring password;
static fstring username;
@@ -137,7 +138,8 @@ static bool try_unlock(struct smbcli_state *c, int fstype,
return a connection to a server
*******************************************************/
static struct smbcli_state *connect_one(char *share, const char **ports,
- struct smb_options *options)
+ struct smb_options *optionsi,
+ struct event_context *ev)
{
struct smbcli_state *c;
char *server_n;
@@ -165,7 +167,7 @@ static struct smbcli_state *connect_one(char *share, const char **ports,
nt_status = smbcli_full_connection(NULL,
&c, myname, server_n, ports, share, NULL,
- username, lp_workgroup(), password, NULL,
+ username, lp_workgroup(), password, ev,
options);
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0, ("smbcli_full_connection failed with error %s\n", nt_errstr(nt_status)));
@@ -183,6 +185,7 @@ static void reconnect(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
int fnum[NSERVERS][NUMFSTYPES][NCONNECTIONS][NFILES],
const char **ports,
struct smbcli_options *options,
+ struct event_context *ev,
char *share1, char *share2)
{
int server, conn, f, fstype;
@@ -201,7 +204,7 @@ static void reconnect(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
smbcli_ulogoff(cli[server][conn]);
talloc_free(cli[server][conn]);
}
- cli[server][conn] = connect_one(share[server], ports, options);
+ cli[server][conn] = connect_one(share[server], ports, options, ev);
if (!cli[server][conn]) {
DEBUG(0,("Failed to connect to %s\n", share[server]));
exit(1);
@@ -347,7 +350,11 @@ static int retest(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
we then do random locking ops in tamdem on the 4 fnums from each
server and ensure that the results match
*/
-static void test_locks(char *share1, char *share2, char *nfspath1, char *nfspath2, const char **ports, struct smbcli_options *options)
+static void test_locks(char *share1, char *share2,
+ char *nfspath1, char *nfspath2,
+ const char **ports,
+ struct smbcli_options *options,
+ struct event_context *ev)
{
struct smbcli_state *cli[NSERVERS][NCONNECTIONS];
char *nfs[NSERVERS];
@@ -376,7 +383,7 @@ static void test_locks(char *share1, char *share2, char *nfspath1, char *nfspath
recorded[n].needed = true;
}
- reconnect(cli, nfs, fnum, ports, options, share1, share2);
+ reconnect(cli, nfs, fnum, ports, options, ev, share1, share2);
open_files(cli, nfs, fnum);
n = retest(cli, nfs, fnum, numops);
@@ -387,7 +394,7 @@ static void test_locks(char *share1, char *share2, char *nfspath1, char *nfspath
n1 = n;
close_files(cli, nfs, fnum);
- reconnect(cli, nfs, fnum, ports, options, share1, share2);
+ reconnect(cli, nfs, fnum, ports, options, ev, share1, share2);
open_files(cli, nfs, fnum);
for (i=0;i<n-1;i++) {
@@ -414,7 +421,7 @@ static void test_locks(char *share1, char *share2, char *nfspath1, char *nfspath
}
close_files(cli, nfs, fnum);
- reconnect(cli, nfs, fnum, ports, options, share1, share2);
+ reconnect(cli, nfs, fnum, ports, options, ev, share1, share2);
open_files(cli, nfs, fnum);
showall = true;
n1 = retest(cli, nfs, fnum, n);
@@ -466,6 +473,7 @@ static void usage(void)
char *p;
int seed;
struct loadparm_context *lp_ctx;
+ struct event_context *ev;
setlinebuf(stdout);
@@ -542,10 +550,12 @@ static void usage(void)
DEBUG(0,("seed=%u\n", seed));
srandom(seed);
+ ev = event_context_init(talloc_autofree_context());
+
locking_init(1);
lp_smbcli_options(lp_ctx, &options);
test_locks(share1, share2, nfspath1, nfspath2, lp_smb_ports(lp_ctx),
- &options);
+ &options, ev);
return(0);
}
diff --git a/source4/torture/masktest.c b/source4/torture/masktest.c
index ac7029aa50..39b1296dbe 100644
--- a/source4/torture/masktest.c
+++ b/source4/torture/masktest.c
@@ -30,6 +30,7 @@
#include "param/param.h"
#include "dynconfig.h"
#include "libcli/resolve/resolve.h"
+#include "lib/events/events.h"
static bool showall = false;
static bool old_list = false;
@@ -73,6 +74,7 @@ static char *reg_test(struct smbcli_state *cli, char *pattern, char *long_name,
return a connection to a server
*******************************************************/
static struct smbcli_state *connect_one(struct resolve_context *resolve_ctx,
+ struct event_context *ev,
char *share, const char **ports,
struct smbcli_options *options)
{
@@ -92,7 +94,7 @@ static struct smbcli_state *connect_one(struct resolve_context *resolve_ctx,
server,
ports,
share, NULL,
- cmdline_credentials, resolve_ctx, NULL,
+ cmdline_credentials, resolve_ctx, ev,
options);
if (!NT_STATUS_IS_OK(status)) {
@@ -291,6 +293,7 @@ static void usage(poptContext pc)
struct smbcli_state *cli;
int opt;
int seed;
+ struct event_context *ev;
struct loadparm_context *lp_ctx;
struct smbcli_options options;
poptContext pc;
@@ -352,11 +355,13 @@ static void usage(poptContext pc)
lp_ctx = cmdline_lp_ctx;
+ ev = event_context_init(talloc_autofree_context());
+
gensec_init(lp_ctx);
lp_smbcli_options(lp_ctx, &options);
- cli = connect_one(lp_resolve_context(lp_ctx), share,
+ cli = connect_one(lp_resolve_context(lp_ctx), ev, share,
lp_smb_ports(lp_ctx), &options);
if (!cli) {
DEBUG(0,("Failed to connect to %s\n", share));
diff --git a/source4/torture/nbt/browse.c b/source4/torture/nbt/browse.c
index e609e72055..a0e7b7d9ca 100644
--- a/source4/torture/nbt/browse.c
+++ b/source4/torture/nbt/browse.c
@@ -40,7 +40,7 @@ bool torture_nbt_browse(struct torture_context *torture)
name.scope = NULL;
/* do an initial name resolution to find its IP */
- status = resolve_name(&name, mem_ctx, &address, NULL);
+ status = resolve_name(&name, mem_ctx, &address, torture->ev);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to resolve %s - %s\n",
name.name, nt_errstr(status));
diff --git a/source4/torture/nbt/dgram.c b/source4/torture/nbt/dgram.c
index a4c8be888c..a3585896eb 100644
--- a/source4/torture/nbt/dgram.c
+++ b/source4/torture/nbt/dgram.c
@@ -64,7 +64,7 @@ static void netlogon_handler(struct dgram_mailslot_handler *dgmslot,
static bool nbt_test_netlogon(struct torture_context *tctx)
{
struct dgram_mailslot_handler *dgmslot;
- struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(tctx, NULL,
+ struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(tctx, tctx->ev,
lp_iconv_convenience(tctx->lp_ctx));
struct socket_address *dest;
const char *myaddress;
@@ -147,7 +147,7 @@ static bool nbt_test_netlogon(struct torture_context *tctx)
static bool nbt_test_netlogon2(struct torture_context *tctx)
{
struct dgram_mailslot_handler *dgmslot;
- struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(tctx, NULL,
+ struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(tctx, tctx->ev,
lp_iconv_convenience(tctx->lp_ctx));
struct socket_address *dest;
const char *myaddress;
@@ -257,7 +257,7 @@ static void ntlogon_handler(struct dgram_mailslot_handler *dgmslot,
static bool nbt_test_ntlogon(struct torture_context *tctx)
{
struct dgram_mailslot_handler *dgmslot;
- struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(tctx, NULL,
+ struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(tctx, tctx->ev,
lp_iconv_convenience(tctx->lp_ctx));
struct socket_address *dest;
struct test_join *join_ctx;
diff --git a/source4/torture/nbt/nbt.c b/source4/torture/nbt/nbt.c
index 6cb9507398..d27a26eb30 100644
--- a/source4/torture/nbt/nbt.c
+++ b/source4/torture/nbt/nbt.c
@@ -34,7 +34,7 @@ bool torture_nbt_get_name(struct torture_context *tctx,
/* do an initial name resolution to find its IP */
torture_assert_ntstatus_ok(tctx,
- resolve_name(lp_resolve_context(tctx->lp_ctx), name, tctx, address, NULL),
+ resolve_name(lp_resolve_context(tctx->lp_ctx), name, tctx, address, tctx->ev),
talloc_asprintf(tctx,
"Failed to resolve %s", name->name));
diff --git a/source4/torture/nbt/query.c b/source4/torture/nbt/query.c
index 1ba6172e5c..3f3a15cca5 100644
--- a/source4/torture/nbt/query.c
+++ b/source4/torture/nbt/query.c
@@ -47,7 +47,7 @@ static void increment_handler(struct nbt_name_request *req)
*/
static bool bench_namequery(struct torture_context *tctx)
{
- struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, NULL,
+ struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, tctx->ev,
lp_iconv_convenience(tctx->lp_ctx));
int num_sent=0;
struct result_struct *result;
diff --git a/source4/torture/nbt/register.c b/source4/torture/nbt/register.c
index b9f06c479d..a8681f828f 100644
--- a/source4/torture/nbt/register.c
+++ b/source4/torture/nbt/register.c
@@ -44,7 +44,7 @@ static bool nbt_register_own(struct torture_context *tctx)
{
struct nbt_name_register io;
NTSTATUS status;
- struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, NULL,
+ struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, tctx->ev,
lp_iconv_convenience(tctx->lp_ctx));
struct socket_address *socket_address;
struct nbt_name name;
@@ -114,7 +114,7 @@ static bool nbt_refresh_own(struct torture_context *tctx)
{
struct nbt_name_refresh io;
NTSTATUS status;
- struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, NULL,
+ struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, tctx->ev,
lp_iconv_convenience(tctx->lp_ctx));
const char *myaddress;
struct socket_address *socket_address;
diff --git a/source4/torture/nbt/wins.c b/source4/torture/nbt/wins.c
index 059b2dc919..ae20de6e2f 100644
--- a/source4/torture/nbt/wins.c
+++ b/source4/torture/nbt/wins.c
@@ -53,7 +53,7 @@ static bool nbt_test_wins_name(struct torture_context *tctx, const char *address
struct nbt_name_refresh_wins refresh;
struct nbt_name_release release;
NTSTATUS status;
- struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
const char *myaddress;
struct socket_address *socket_address;
struct interface *ifaces;
diff --git a/source4/torture/nbt/winsbench.c b/source4/torture/nbt/winsbench.c
index ea4abaf21b..a0d90fb653 100644
--- a/source4/torture/nbt/winsbench.c
+++ b/source4/torture/nbt/winsbench.c
@@ -225,7 +225,7 @@ static void generate_request(struct nbt_name_socket *nbtsock, struct wins_state
*/
static bool bench_wins(struct torture_context *tctx)
{
- struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
int num_sent=0;
struct timeval tv = timeval_current();
bool ret = true;
diff --git a/source4/torture/nbt/winsreplication.c b/source4/torture/nbt/winsreplication.c
index 470eee8310..ee7a1510d5 100644
--- a/source4/torture/nbt/winsreplication.c
+++ b/source4/torture/nbt/winsreplication.c
@@ -103,8 +103,8 @@ static bool test_assoc_ctx1(struct torture_context *tctx)
torture_comment(tctx, "Test if assoc_ctx is only valid on the conection it was created on\n");
- wrepl_socket1 = wrepl_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
- wrepl_socket2 = wrepl_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ wrepl_socket1 = wrepl_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
+ wrepl_socket2 = wrepl_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
torture_comment(tctx, "Setup 2 wrepl connections\n");
status = wrepl_connect(wrepl_socket1, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, address), address);
@@ -186,7 +186,7 @@ static bool test_assoc_ctx2(struct torture_context *tctx)
torture_comment(tctx, "Test if we always get back the same assoc_ctx\n");
- wrepl_socket = wrepl_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ wrepl_socket = wrepl_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
torture_comment(tctx, "Setup wrepl connections\n");
status = wrepl_connect(wrepl_socket, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, address), address);
@@ -255,7 +255,7 @@ static bool test_wins_replication(struct torture_context *tctx)
torture_comment(tctx, "Test one pull replication cycle\n");
- wrepl_socket = wrepl_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ wrepl_socket = wrepl_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
torture_comment(tctx, "Setup wrepl connections\n");
status = wrepl_connect(wrepl_socket, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, address), address);
@@ -553,7 +553,7 @@ static struct test_wrepl_conflict_conn *test_create_conflict_ctx(
if (!ctx) return NULL;
ctx->address = address;
- ctx->pull = wrepl_socket_init(ctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ ctx->pull = wrepl_socket_init(ctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
if (!ctx->pull) return NULL;
torture_comment(tctx, "Setup wrepl conflict pull connection\n");
@@ -610,7 +610,7 @@ static struct test_wrepl_conflict_conn *test_create_conflict_ctx(
talloc_free(pull_table.out.partners);
- ctx->nbtsock = nbt_name_socket_init(ctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ ctx->nbtsock = nbt_name_socket_init(ctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
if (!ctx->nbtsock) return NULL;
load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces);
@@ -628,7 +628,7 @@ static struct test_wrepl_conflict_conn *test_create_conflict_ctx(
status = socket_listen(ctx->nbtsock->sock, ctx->myaddr, 0, 0);
if (!NT_STATUS_IS_OK(status)) return NULL;
- ctx->nbtsock_srv = nbt_name_socket_init(ctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ ctx->nbtsock_srv = nbt_name_socket_init(ctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
if (!ctx->nbtsock_srv) return NULL;
/* Make a port 137 version of ctx->myaddr */
@@ -645,7 +645,7 @@ static struct test_wrepl_conflict_conn *test_create_conflict_ctx(
}
if (ctx->myaddr2 && ctx->nbtsock_srv) {
- ctx->nbtsock2 = nbt_name_socket_init(ctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ ctx->nbtsock2 = nbt_name_socket_init(ctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
if (!ctx->nbtsock2) return NULL;
status = socket_listen(ctx->nbtsock2->sock, ctx->myaddr2, 0, 0);
@@ -722,7 +722,7 @@ static bool test_wrepl_update_one(struct torture_context *tctx,
uint32_t assoc_ctx;
NTSTATUS status;
- wrepl_socket = wrepl_socket_init(ctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ wrepl_socket = wrepl_socket_init(ctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
status = wrepl_connect(wrepl_socket, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, ctx->address), ctx->address);
CHECK_STATUS(tctx, status, NT_STATUS_OK);
diff --git a/source4/torture/raw/composite.c b/source4/torture/raw/composite.c
index 1f31fbc515..d73ac1327e 100644
--- a/source4/torture/raw/composite.c
+++ b/source4/torture/raw/composite.c
@@ -296,7 +296,7 @@ static bool test_appendacl(struct smbcli_state *cli, struct torture_context *tct
c[i]->async.private_data = count;
}
- event_ctx = talloc_reference(tctx, cli->tree->session->transport->socket->event.ctx);
+ event_ctx = tctx->ev;
printf("waiting for completion\n");
while (*count != num_ops) {
event_loop_once(event_ctx);
@@ -354,7 +354,7 @@ static bool test_fsinfo(struct smbcli_state *cli, struct torture_context *tctx)
printf("testing parallel queryfsinfo [Object ID] with %d ops\n", torture_numops);
- event_ctx = talloc_reference(tctx, cli->tree->session->transport->socket->event.ctx);
+ event_ctx = tctx->ev;
c = talloc_array(tctx, struct composite_context *, torture_numops);
for (i=0; i<torture_numops; i++) {
diff --git a/source4/torture/raw/lookuprate.c b/source4/torture/raw/lookuprate.c
new file mode 100644
index 0000000000..0e8f002efb
--- /dev/null
+++ b/source4/torture/raw/lookuprate.c
@@ -0,0 +1,320 @@
+/*
+ File lookup rate test.
+
+ Copyright (C) James Peach 2006
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "param/param.h"
+#include "system/filesys.h"
+#include "torture/torture.h"
+#include "torture/basic/proto.h"
+#include "libcli/libcli.h"
+#include "torture/util.h"
+#include "lib/cmdline/popt_common.h"
+#include "auth/credentials/credentials.h"
+
+#define BASEDIR "\\lookuprate"
+#define MISSINGNAME BASEDIR "\\foo"
+
+#define FUZZ_PERCENT 10
+
+#define usec_to_sec(s) ((s) / 1000000)
+#define sec_to_usec(s) ((s) * 1000000)
+
+struct rate_record
+{
+ unsigned dirent_count;
+ unsigned querypath_persec;
+ unsigned findfirst_persec;
+};
+
+static struct rate_record records[] =
+{
+ { 0, 0, 0 }, /* Base (optimal) lookup rate. */
+ { 100, 0, 0},
+ { 1000, 0, 0},
+ { 10000, 0, 0},
+ { 100000, 0, 0}
+};
+
+typedef NTSTATUS lookup_function(struct smbcli_tree *tree, const char * path);
+
+/* Test whether rhs is within fuzz% of lhs. */
+static bool fuzzily_equal(unsigned lhs, unsigned rhs, int percent)
+{
+ double fuzz = (double)lhs * (double)percent/100.0;
+
+ if (((double)rhs >= ((double)lhs - fuzz)) &&
+ ((double)rhs <= ((double)lhs + fuzz))) {
+ return true;
+ }
+
+ return false;
+
+}
+
+static NTSTATUS fill_directory(struct smbcli_tree *tree,
+ const char * path, unsigned count)
+{
+ NTSTATUS status;
+ char *fname = NULL;
+ unsigned i;
+ unsigned current;
+
+ struct timeval start;
+ struct timeval now;
+
+ status = smbcli_mkdir(tree, path);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ printf("filling directory %s with %u files... ", path, count);
+ fflush(stdout);
+
+ current = random();
+ start = timeval_current();
+
+ for (i = 0; i < count; ++i) {
+ int fnum;
+
+ ++current;
+ fname = talloc_asprintf(NULL, "%s\\fill%u",
+ path, current);
+
+ fnum = smbcli_open(tree, fname, O_RDONLY|O_CREAT,
+ OPENX_MODE_DENY_NONE);
+ if (fnum < 0) {
+ talloc_free(fname);
+ return smbcli_nt_error(tree);
+ }
+
+ smbcli_close(tree, fnum);
+ talloc_free(fname);
+ }
+
+ if (count) {
+ double rate;
+ now = timeval_current();
+ rate = (double)count / usec_to_sec((double)usec_time_diff(&now, &start));
+ printf("%u/sec\n", (unsigned)rate);
+ } else {
+ printf("done\n");
+ }
+
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS squash_lookup_error(NTSTATUS status)
+{
+ if (NT_STATUS_IS_OK(status)) {
+ return NT_STATUS_OK;
+ }
+
+ /* We don't care if the file isn't there. */
+ if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_PATH_NOT_FOUND)) {
+ return NT_STATUS_OK;
+ }
+
+ if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
+ return NT_STATUS_OK;
+ }
+
+ if (NT_STATUS_EQUAL(status, NT_STATUS_NO_SUCH_FILE)) {
+ return NT_STATUS_OK;
+ }
+
+ return status;
+}
+
+/* Look up a pathname using TRANS2_QUERY_PATH_INFORMATION. */
+static NTSTATUS querypath_lookup(struct smbcli_tree *tree, const char * path)
+{
+ NTSTATUS status;
+ time_t ftimes[3];
+ size_t fsize;
+ uint16_t fmode;
+
+ status = smbcli_qpathinfo(tree, path, &ftimes[0], &ftimes[1], &ftimes[2],
+ &fsize, &fmode);
+
+ return squash_lookup_error(status);
+}
+
+/* Look up a pathname using TRANS2_FIND_FIRST2. */
+static NTSTATUS findfirst_lookup(struct smbcli_tree *tree, const char * path)
+{
+ NTSTATUS status = NT_STATUS_OK;
+
+ if (smbcli_list(tree, path, 0, NULL, NULL) < 0) {
+ status = smbcli_nt_error(tree);
+ }
+
+ return squash_lookup_error(status);
+}
+
+static NTSTATUS lookup_rate_convert(struct smbcli_tree *tree,
+ lookup_function lookup, const char * path, unsigned * rate)
+{
+ NTSTATUS status;
+
+ struct timeval start;
+ struct timeval now;
+ unsigned count = 0;
+ int64_t elapsed = 0;
+
+#define LOOKUP_PERIOD_SEC (2)
+
+ start = timeval_current();
+ while (elapsed < sec_to_usec(LOOKUP_PERIOD_SEC)) {
+
+ status = lookup(tree, path);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ ++count;
+ now = timeval_current();
+ elapsed = usec_time_diff(&now, &start);
+ }
+
+#undef LOOKUP_PERIOD_SEC
+
+ *rate = (unsigned)((double)count / (double)usec_to_sec(elapsed));
+ return NT_STATUS_OK;
+}
+
+static bool remove_working_directory(struct smbcli_tree *tree,
+ const char * path)
+{
+ int tries;
+
+ /* Using smbcli_deltree to delete a very large number of files
+ * doesn't work against all servers. Work around this by
+ * retrying.
+ */
+ for (tries = 0; tries < 5; ) {
+ int ret;
+
+ ret = smbcli_deltree(tree, BASEDIR);
+ if (ret == -1) {
+ tries++;
+ printf("(%s) failed to deltree %s: %s\n",
+ __location__, BASEDIR,
+ smbcli_errstr(tree));
+ continue;
+ }
+
+ return true;
+ }
+
+ return false;
+
+}
+
+/* Verify that looking up a file name takes constant time.
+ *
+ * This test samples the lookup rate for a non-existant filename in a
+ * directory, while varying the number of files in the directory. The
+ * lookup rate should continue to approximate the lookup rate for the
+ * empty directory case.
+ */
+bool torture_bench_lookup(struct torture_context *torture)
+{
+ NTSTATUS status;
+ bool result = false;
+
+ int i, tries;
+ struct smbcli_state *cli = NULL;
+
+ if (!torture_open_connection(&cli, torture, 0)) {
+ goto done;
+ }
+
+ remove_working_directory(cli->tree, BASEDIR);
+
+ for (i = 0; i < ARRAY_SIZE(records); ++i) {
+ printf("testing lookup rate with %u directory entries\n",
+ records[i].dirent_count);
+
+ status = fill_directory(cli->tree, BASEDIR,
+ records[i].dirent_count);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("failed to fill directory: %s\n", nt_errstr(status));
+ goto done;
+ }
+
+ status = lookup_rate_convert(cli->tree, querypath_lookup,
+ MISSINGNAME, &records[i].querypath_persec);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("querypathinfo of %s failed: %s\n",
+ MISSINGNAME, nt_errstr(status));
+ goto done;
+ }
+
+ status = lookup_rate_convert(cli->tree, findfirst_lookup,
+ MISSINGNAME, &records[i].findfirst_persec);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("findfirst of %s failed: %s\n",
+ MISSINGNAME, nt_errstr(status));
+ goto done;
+ }
+
+ printf("entries = %u, querypath = %u/sec, findfirst = %u/sec\n",
+ records[i].dirent_count,
+ records[i].querypath_persec,
+ records[i].findfirst_persec);
+
+ if (!remove_working_directory(cli->tree, BASEDIR)) {
+ goto done;
+ }
+ }
+
+ /* Ok. We have run all our tests. Walk through the records we
+ * accumulated and figure out whether the lookups took constant
+ * time of not.
+ */
+ for (i = 0; i < ARRAY_SIZE(records); ++i) {
+ if (!fuzzily_equal(records[0].querypath_persec,
+ records[i].querypath_persec,
+ FUZZ_PERCENT)) {
+ printf("querypath rate for %d entries differed by "
+ "more than %d%% from base rate\n",
+ records[i].dirent_count, FUZZ_PERCENT);
+ result = false;
+ }
+
+ if (!fuzzily_equal(records[0].findfirst_persec,
+ records[i].findfirst_persec,
+ FUZZ_PERCENT)) {
+ printf("findfirst rate for %d entries differed by "
+ "more than %d%% from base rate\n",
+ records[i].dirent_count, FUZZ_PERCENT);
+ result = false;
+ }
+ }
+
+done:
+ if (cli) {
+ remove_working_directory(cli->tree, BASEDIR);
+ talloc_free(cli);
+ }
+
+ return result;
+}
+
+/* vim: set sts=8 sw=8 : */
diff --git a/source4/torture/raw/raw.c b/source4/torture/raw/raw.c
index bb3dde728f..262ed1384b 100644
--- a/source4/torture/raw/raw.c
+++ b/source4/torture/raw/raw.c
@@ -33,6 +33,8 @@ NTSTATUS torture_raw_init(void)
torture_suite_add_simple_test(suite, "PING-PONG", torture_ping_pong);
torture_suite_add_simple_test(suite, "BENCH-LOCK", torture_bench_lock);
torture_suite_add_simple_test(suite, "BENCH-OPEN", torture_bench_open);
+ torture_suite_add_simple_test(suite, "BENCH-LOOKUP",
+ torture_bench_lookup);
torture_suite_add_simple_test(suite, "OFFLINE", torture_test_offline);
torture_suite_add_1smb_test(suite, "QFSINFO", torture_raw_qfsinfo);
torture_suite_add_1smb_test(suite, "QFILEINFO", torture_raw_qfileinfo);
diff --git a/source4/torture/rpc/dssync.c b/source4/torture/rpc/dssync.c
index b28e429a75..00617f4072 100644
--- a/source4/torture/rpc/dssync.c
+++ b/source4/torture/rpc/dssync.c
@@ -178,12 +178,11 @@ static bool _test_DsBind(struct torture_context *tctx,
{
NTSTATUS status;
bool ret = true;
- struct event_context *event = NULL;
status = dcerpc_pipe_connect_b(ctx,
&b->pipe, ctx->drsuapi_binding,
&ndr_table_drsuapi,
- credentials, event, tctx->lp_ctx);
+ credentials, tctx->ev, tctx->lp_ctx);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to connect to server as a BDC: %s\n", nt_errstr(status));
@@ -254,10 +253,11 @@ static bool test_GetInfo(struct torture_context *tctx, struct DsSyncTest *ctx)
struct drsuapi_DsCrackNames r;
struct drsuapi_DsNameString names[1];
bool ret = true;
-
- struct cldap_socket *cldap = cldap_socket_init(ctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ struct cldap_socket *cldap;
struct cldap_netlogon search;
-
+
+ cldap = cldap_socket_init(ctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
+
r.in.bind_handle = &ctx->admin.drsuapi.bind_handle;
r.in.level = 1;
r.in.req.req1.codepage = 1252; /* western european */
diff --git a/source4/torture/rpc/join.c b/source4/torture/rpc/join.c
index 849b9fd1e9..cd5eb32fa8 100644
--- a/source4/torture/rpc/join.c
+++ b/source4/torture/rpc/join.c
@@ -39,7 +39,7 @@ bool torture_rpc_join(struct torture_context *torture)
"IPC$", NULL,
machine_account,
lp_resolve_context(torture->lp_ctx),
- NULL, &options);
+ torture->ev, &options);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("%s failed to connect to IPC$ with workstation credentials\n",
TORTURE_NETBIOS_NAME));
@@ -65,7 +65,7 @@ bool torture_rpc_join(struct torture_context *torture)
"IPC$", NULL,
machine_account,
lp_resolve_context(torture->lp_ctx),
- NULL, &options);
+ torture->ev, &options);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("%s failed to connect to IPC$ with workstation credentials\n",
TORTURE_NETBIOS_NAME));
diff --git a/source4/torture/rpc/rpc.c b/source4/torture/rpc/rpc.c
index 6e38d0465a..7c8e78b160 100644
--- a/source4/torture/rpc/rpc.c
+++ b/source4/torture/rpc/rpc.c
@@ -83,7 +83,7 @@ _PUBLIC_ NTSTATUS torture_rpc_connection(struct torture_context *tctx,
status = dcerpc_pipe_connect_b(tctx,
p, binding, table,
- cmdline_credentials, NULL, tctx->lp_ctx);
+ cmdline_credentials, tctx->ev, tctx->lp_ctx);
if (NT_STATUS_IS_ERR(status)) {
printf("Failed to connect to remote server: %s %s\n",
@@ -113,7 +113,7 @@ NTSTATUS torture_rpc_connection_transport(struct torture_context *tctx,
binding->assoc_group_id = assoc_group_id;
status = dcerpc_pipe_connect_b(tctx, p, binding, table,
- cmdline_credentials, NULL, tctx->lp_ctx);
+ cmdline_credentials, tctx->ev, tctx->lp_ctx);
if (NT_STATUS_IS_ERR(status)) {
*p = NULL;
@@ -147,7 +147,7 @@ static bool torture_rpc_setup_machine(struct torture_context *tctx,
&(tcase_data->pipe),
binding,
tcase->table,
- tcase_data->credentials, NULL, tctx->lp_ctx);
+ tcase_data->credentials, tctx->ev, tctx->lp_ctx);
torture_assert_ntstatus_ok(tctx, status, "Error connecting to server");
@@ -205,7 +205,7 @@ static bool torture_rpc_setup_anonymous(struct torture_context *tctx,
&(tcase_data->pipe),
binding,
tcase->table,
- tcase_data->credentials, NULL, tctx->lp_ctx);
+ tcase_data->credentials, tctx->ev, tctx->lp_ctx);
torture_assert_ntstatus_ok(tctx, status, "Error connecting to server");
diff --git a/source4/torture/rpc/samba3rpc.c b/source4/torture/rpc/samba3rpc.c
index 8eb1f54b4f..40a7c156f4 100644
--- a/source4/torture/rpc/samba3rpc.c
+++ b/source4/torture/rpc/samba3rpc.c
@@ -89,7 +89,7 @@ bool torture_bind_authcontext(struct torture_context *torture)
lp_smb_ports(torture->lp_ctx),
"IPC$", NULL, cmdline_credentials,
lp_resolve_context(torture->lp_ctx),
- NULL, &options);
+ torture->ev, &options);
if (!NT_STATUS_IS_OK(status)) {
d_printf("smbcli_full_connection failed: %s\n",
nt_errstr(status));
@@ -303,7 +303,7 @@ bool torture_bind_samba3(struct torture_context *torture)
lp_smb_ports(torture->lp_ctx),
"IPC$", NULL, cmdline_credentials,
lp_resolve_context(torture->lp_ctx),
- NULL, &options);
+ torture->ev, &options);
if (!NT_STATUS_IS_OK(status)) {
d_printf("smbcli_full_connection failed: %s\n",
nt_errstr(status));
@@ -1220,7 +1220,7 @@ bool torture_netlogon_samba3(struct torture_context *torture)
lp_smb_ports(torture->lp_ctx),
"IPC$", NULL, anon_creds,
lp_resolve_context(torture->lp_ctx),
- NULL, &options);
+ torture->ev, &options);
if (!NT_STATUS_IS_OK(status)) {
d_printf("smbcli_full_connection failed: %s\n",
nt_errstr(status));
@@ -1307,7 +1307,7 @@ static bool test_join3(struct torture_context *tctx,
lp_smb_ports(tctx->lp_ctx),
"IPC$", NULL, smb_creds,
lp_resolve_context(tctx->lp_ctx),
- NULL, &options);
+ tctx->ev, &options);
if (!NT_STATUS_IS_OK(status)) {
d_printf("smbcli_full_connection failed: %s\n",
nt_errstr(status));
@@ -1682,7 +1682,7 @@ bool torture_samba3_rpc_getusername(struct torture_context *torture)
lp_smb_ports(torture->lp_ctx),
"IPC$", NULL, cmdline_credentials,
lp_resolve_context(torture->lp_ctx),
- NULL, &options);
+ torture->ev, &options);
if (!NT_STATUS_IS_OK(status)) {
d_printf("(%s) smbcli_full_connection failed: %s\n",
__location__, nt_errstr(status));
@@ -1709,7 +1709,7 @@ bool torture_samba3_rpc_getusername(struct torture_context *torture)
lp_smb_ports(torture->lp_ctx),
"IPC$", NULL, anon_creds,
lp_resolve_context(torture->lp_ctx),
- NULL, &options);
+ torture->ev, &options);
if (!NT_STATUS_IS_OK(status)) {
d_printf("(%s) anon smbcli_full_connection failed: %s\n",
__location__, nt_errstr(status));
diff --git a/source4/torture/rpc/samlogon.c b/source4/torture/rpc/samlogon.c
index 24b2511bc7..ab3283a952 100644
--- a/source4/torture/rpc/samlogon.c
+++ b/source4/torture/rpc/samlogon.c
@@ -1602,7 +1602,7 @@ bool torture_rpc_samlogon(struct torture_context *torture)
status = dcerpc_pipe_connect_b(mem_ctx, &p, b,
&ndr_table_netlogon,
- machine_credentials, NULL, torture->lp_ctx);
+ machine_credentials, torture->ev, torture->lp_ctx);
if (!NT_STATUS_IS_OK(status)) {
d_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 3b152d92aa..9705f7b0de 100644
--- a/source4/torture/rpc/samsync.c
+++ b/source4/torture/rpc/samsync.c
@@ -1560,7 +1560,7 @@ bool torture_rpc_samsync(struct torture_context *torture)
status = dcerpc_pipe_connect_b(samsync_state,
&samsync_state->p, b,
&ndr_table_netlogon,
- credentials, NULL, torture->lp_ctx);
+ credentials, torture->ev, torture->lp_ctx);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to connect to server as a BDC: %s\n", nt_errstr(status));
@@ -1598,7 +1598,7 @@ bool torture_rpc_samsync(struct torture_context *torture)
&samsync_state->p_netlogon_wksta,
b_netlogon_wksta,
&ndr_table_netlogon,
- credentials_wksta, NULL, torture->lp_ctx);
+ credentials_wksta, torture->ev, torture->lp_ctx);
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/schannel.c b/source4/torture/rpc/schannel.c
index 46605e53e6..c89b71baaf 100644
--- a/source4/torture/rpc/schannel.c
+++ b/source4/torture/rpc/schannel.c
@@ -258,7 +258,7 @@ static bool test_schannel(struct torture_context *tctx,
b->flags |= dcerpc_flags;
status = dcerpc_pipe_connect_b(tctx, &p, b, &ndr_table_samr,
- credentials, NULL, tctx->lp_ctx);
+ credentials, tctx->ev, tctx->lp_ctx);
torture_assert_ntstatus_ok(tctx, status,
"Failed to connect with schannel");
@@ -328,7 +328,7 @@ static bool test_schannel(struct torture_context *tctx,
b->flags |= dcerpc_flags;
status = dcerpc_pipe_connect_b(tctx, &p_samr2, b, &ndr_table_samr,
- credentials, NULL, tctx->lp_ctx);
+ credentials, tctx->ev, tctx->lp_ctx);
torture_assert_ntstatus_ok(tctx, status,
"Failed to connect with schannel");
@@ -370,7 +370,7 @@ static bool test_schannel(struct torture_context *tctx,
b->flags &= ~DCERPC_AUTH_OPTIONS;
status = dcerpc_pipe_connect_b(tctx, &p_netlogon3, b, &ndr_table_netlogon,
- credentials, NULL, tctx->lp_ctx);
+ credentials, tctx->ev, tctx->lp_ctx);
torture_assert_ntstatus_ok(tctx, status, "Failed to connect without schannel");
torture_assert(tctx, !test_netlogon_ex_ops(p_netlogon3, tctx, credentials, creds),
@@ -453,12 +453,12 @@ bool torture_rpc_schannel2(struct torture_context *torture)
printf("Opening first connection\n");
status = dcerpc_pipe_connect_b(torture, &p1, b, &ndr_table_netlogon,
- credentials1, NULL, torture->lp_ctx);
+ credentials1, torture->ev, torture->lp_ctx);
torture_assert_ntstatus_ok(torture, status, "Failed to connect with schannel");
torture_comment(torture, "Opening second connection\n");
status = dcerpc_pipe_connect_b(torture, &p2, b, &ndr_table_netlogon,
- credentials2, NULL, torture->lp_ctx);
+ credentials2, torture->ev, torture->lp_ctx);
torture_assert_ntstatus_ok(torture, status, "Failed to connect with schannel");
credentials1->netlogon_creds = NULL;
diff --git a/source4/torture/rpc/session_key.c b/source4/torture/rpc/session_key.c
index fcb828ddb2..0df7e576ee 100644
--- a/source4/torture/rpc/session_key.c
+++ b/source4/torture/rpc/session_key.c
@@ -158,7 +158,11 @@ static bool test_secrets(struct torture_context *torture, const void *_data)
binding->flags |= settings->bindoptions;
torture_assert_ntstatus_ok(torture,
- dcerpc_pipe_connect_b(torture, &p, binding, &ndr_table_lsarpc, cmdline_credentials, NULL, torture->lp_ctx),
+ dcerpc_pipe_connect_b(torture, &p, binding,
+ &ndr_table_lsarpc,
+ cmdline_credentials,
+ torture->ev,
+ torture->lp_ctx),
"connect");
if (!test_lsa_OpenPolicy2(p, torture, &handle)) {
diff --git a/source4/torture/unix/unix_info2.c b/source4/torture/unix/unix_info2.c
index c14be9e2d0..d7482ddcf1 100644
--- a/source4/torture/unix/unix_info2.c
+++ b/source4/torture/unix/unix_info2.c
@@ -63,8 +63,8 @@ static struct smbcli_state *connect_to_server(struct torture_context *tctx)
lp_smb_ports(tctx->lp_ctx),
share, NULL,
cmdline_credentials,
- lp_resolve_context(tctx->lp_ctx), NULL,
- &options);
+ lp_resolve_context(tctx->lp_ctx),
+ tctx->ev, &options);
if (!NT_STATUS_IS_OK(status)) {
printf("failed to connect to //%s/%s: %s\n",
diff --git a/source4/torture/unix/whoami.c b/source4/torture/unix/whoami.c
index a1333ac5bd..d4f19bb57a 100644
--- a/source4/torture/unix/whoami.c
+++ b/source4/torture/unix/whoami.c
@@ -84,7 +84,7 @@ static struct smbcli_state *connect_to_server(struct torture_context *tctx,
lp_smb_ports(tctx->lp_ctx),
share, NULL,
creds, lp_resolve_context(tctx->lp_ctx),
- NULL, &options);
+ tctx->ev, &options);
if (!NT_STATUS_IS_OK(status)) {
printf("failed to connect to //%s/%s: %s\n",
diff --git a/source4/utils/nmblookup.c b/source4/utils/nmblookup.c
index fe03e0dbbe..980e06602d 100644
--- a/source4/utils/nmblookup.c
+++ b/source4/utils/nmblookup.c
@@ -24,6 +24,7 @@
#include "includes.h"
#include "lib/cmdline/popt_common.h"
#include "lib/socket/socket.h"
+#include "lib/events/events.h"
#include "system/network.h"
#include "system/locale.h"
#include "lib/socket/netif.h"
@@ -180,7 +181,7 @@ static NTSTATUS do_node_query(struct nbt_name_socket *nbtsock,
}
-static bool process_one(struct loadparm_context *lp_ctx,
+static bool process_one(struct loadparm_context *lp_ctx, struct event_context *ev,
struct interface *ifaces, const char *name, int nbt_port)
{
TALLOC_CTX *tmp_ctx = talloc_new(NULL);
@@ -211,7 +212,7 @@ static bool process_one(struct loadparm_context *lp_ctx,
node_name = talloc_strdup(tmp_ctx, name);
}
- nbtsock = nbt_name_socket_init(tmp_ctx, NULL, lp_iconv_convenience(lp_ctx));
+ nbtsock = nbt_name_socket_init(tmp_ctx, ev, lp_iconv_convenience(lp_ctx));
if (options.root_port) {
all_zero_addr = socket_address_from_strings(tmp_ctx, nbtsock->sock->backend_name,
@@ -271,6 +272,7 @@ int main(int argc, const char *argv[])
{
bool ret = true;
struct interface *ifaces;
+ struct event_context *ev;
poptContext pc;
int opt;
enum {
@@ -356,13 +358,17 @@ int main(int argc, const char *argv[])
}
load_interfaces(NULL, lp_interfaces(cmdline_lp_ctx), &ifaces);
-
+
+ ev = event_context_init(talloc_autofree_context());
+
while (poptPeekArg(pc)) {
const char *name = poptGetArg(pc);
- ret &= process_one(cmdline_lp_ctx, ifaces, name, lp_nbt_port(cmdline_lp_ctx));
+ ret &= process_one(cmdline_lp_ctx, ev, ifaces, name, lp_nbt_port(cmdline_lp_ctx));
}
+ talloc_free(ev);
+
talloc_free(ifaces);
poptFreeContext(pc);
diff --git a/source4/utils/ntlm_auth.c b/source4/utils/ntlm_auth.c
index 0c9a41fd70..07c0e4f31e 100644
--- a/source4/utils/ntlm_auth.c
+++ b/source4/utils/ntlm_auth.c
@@ -461,6 +461,10 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode,
return;
}
+ ev = event_context_init(state);
+ if (!ev) {
+ exit(1);
+ }
/* setup gensec */
if (!(state->gensec_state)) {
switch (stdio_helper_mode) {
@@ -468,7 +472,7 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode,
case NTLMSSP_CLIENT_1:
/* setup the client side */
- nt_status = gensec_client_start(NULL, &state->gensec_state, NULL, lp_ctx);
+ nt_status = gensec_client_start(NULL, &state->gensec_state, ev, lp_ctx);
if (!NT_STATUS_IS_OK(nt_status)) {
exit(1);
}
@@ -476,10 +480,6 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode,
break;
case GSS_SPNEGO_SERVER:
case SQUID_2_5_NTLMSSP:
- ev = event_context_init(state);
- if (!ev) {
- exit(1);
- }
msg = messaging_client_init(state, lp_messaging_path(state, lp_ctx),
lp_iconv_convenience(lp_ctx), ev);
if (!msg) {