The branch, v4-0-test has been updated via b7c96e0cc270bd3b1c9bd117a22df3f657b6acd5 (commit) via c16d1d430a0f1e3643c1e769b10e9d88b4719d17 (commit) via 3045d391626fba169aa26be52174883e18d323e9 (commit) from ca7e4d9166a7cb10495cf3ecd9c4e72103fbec30 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v4-0-test - Log ----------------------------------------------------------------- commit b7c96e0cc270bd3b1c9bd117a22df3f657b6acd5 Author: Simo Sorce <[EMAIL PROTECTED]> Date: Mon Apr 21 19:53:29 2008 -0400 Make sure we have an event context available commit c16d1d430a0f1e3643c1e769b10e9d88b4719d17 Author: Simo Sorce <[EMAIL PROTECTED]> Date: Mon Apr 21 19:53:15 2008 -0400 Fix build commit 3045d391626fba169aa26be52174883e18d323e9 Author: Simo Sorce <[EMAIL PROTECTED]> Date: Mon Apr 21 17:58:23 2008 -0400 Remove more event_context_init() uses from function calls within deep down the code. Make sure we pass around the event_context where we need it instead. All test but a few python ones fail. Jelmer promised to fix them. ----------------------------------------------------------------------- Summary of changes: source/auth/gensec/gensec.c | 22 +++---------- source/client/cifsdd.c | 17 +++++++---- source/client/cifsdd.h | 2 + source/client/cifsddio.c | 12 +++++-- source/client/client.c | 46 +++++++++++++++++++++------- source/dsdb/samdb/samdb.c | 7 ++++ source/lib/events/events.c | 2 + source/lib/ldb/ldb_ildap/ldb_ildap.c | 16 ++++++++- source/lib/ldb_wrap.c | 2 +- source/lib/messaging/messaging.c | 8 ++-- source/lib/socket/testsuite.c | 2 +- source/libcli/cldap/cldap.c | 6 +--- source/libcli/cliconnect.c | 5 ++- source/libcli/composite/composite.c | 6 +++- source/libcli/dgram/dgramsocket.c | 6 +--- source/libcli/ldap/ldap_bind.c | 5 ++- source/libcli/ldap/ldap_client.c | 12 ++----- source/libcli/nbt/nbtsocket.c | 6 +--- source/libcli/raw/clisocket.c | 22 ++++---------- source/libcli/resolve/host.c | 1 - source/libcli/resolve/nbtlist.c | 3 +- source/libcli/resolve/resolve.c | 13 ++----- source/libcli/smb_composite/connect.c | 8 ++--- source/libcli/smb_composite/fetchfile.c | 2 - source/libcli/smb_composite/fsinfo.c | 2 - source/libcli/wrepl/winsrepl.c | 6 +--- source/libnet/libnet_site.c | 8 ++-- source/librpc/rpc/dcerpc.c | 15 ++------- source/librpc/rpc/dcerpc_connect.c | 15 --------- source/rpc_server/spoolss/dcesrv_spoolss.c | 3 +- source/torture/auth/ntlmssp.c | 6 ++- source/torture/basic/base.c | 3 +- source/torture/gentest.c | 33 ++++++++++++-------- source/torture/ldap/cldap.c | 8 ++++- source/torture/ldap/cldapbench.c | 4 ++- source/torture/ldap/common.c | 2 +- source/torture/libnet/libnet_domain.c | 4 +- source/torture/locktest.c | 26 ++++++++++----- source/torture/locktest2.c | 26 +++++++++++----- source/torture/masktest.c | 9 ++++- source/torture/nbt/browse.c | 2 +- source/torture/nbt/dgram.c | 6 ++-- source/torture/nbt/nbt.c | 2 +- source/torture/nbt/query.c | 2 +- source/torture/nbt/register.c | 4 +- source/torture/nbt/wins.c | 2 +- source/torture/nbt/winsbench.c | 2 +- source/torture/nbt/winsreplication.c | 18 +++++----- source/torture/raw/composite.c | 4 +- source/torture/raw/lookuprate.c | 1 + source/torture/rpc/dssync.c | 10 +++--- source/torture/rpc/join.c | 4 +- source/torture/rpc/rpc.c | 8 ++-- source/torture/rpc/samba3rpc.c | 12 ++++---- source/torture/rpc/samlogon.c | 2 +- source/torture/rpc/samsync.c | 4 +- source/torture/rpc/schannel.c | 10 +++--- source/torture/rpc/session_key.c | 6 +++- source/torture/unix/unix_info2.c | 4 +- source/torture/unix/whoami.c | 2 +- source/utils/nmblookup.c | 14 ++++++-- source/utils/ntlm_auth.c | 10 +++--- 62 files changed, 283 insertions(+), 247 deletions(-) Changeset truncated at 500 lines: diff --git a/source/auth/gensec/gensec.c b/source/auth/gensec/gensec.c index 59ad157..c82b719 100644 --- a/source/auth/gensec/gensec.c +++ b/source/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/source/client/cifsdd.c b/source/client/cifsdd.c index 8e25dab..ce48c7b 100644 --- a/source/client/cifsdd.c +++ b/source/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/source/client/cifsdd.h b/source/client/cifsdd.h index 810c882..21a4ad4 100644 --- a/source/client/cifsdd.h +++ b/source/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/source/client/cifsddio.c b/source/client/cifsddio.c index 7028e85..4297c30 100644 --- a/source/client/cifsddio.c +++ b/source/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/source/client/client.c b/source/client/client.c index ef88913..79cc1b5 100644 --- a/source/client/client.c +++ b/source/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/source/dsdb/samdb/samdb.c b/source/dsdb/samdb/samdb.c index 4af7fb7..9154f53 100644 --- a/source/dsdb/samdb/samdb.c +++ b/source/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/source/lib/events/events.c b/source/lib/events/events.c index 568aadc..252af44 100644 --- a/source/lib/events/events.c +++ b/source/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/source/lib/ldb/ldb_ildap/ldb_ildap.c b/source/lib/ldb/ldb_ildap/ldb_ildap.c index 79958a8..6b50b2f 100644 --- a/source/lib/ldb/ldb_ildap/ldb_ildap.c +++ b/source/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/source/lib/ldb_wrap.c b/source/lib/ldb_wrap.c index b71adcb..b564976 100644 --- a/source/lib/ldb_wrap.c +++ b/source/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/source/lib/messaging/messaging.c b/source/lib/messaging/messaging.c index 29d6e00..1928446 100644 --- a/source/lib/messaging/messaging.c +++ b/source/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/source/lib/socket/testsuite.c b/source/lib/socket/testsuite.c index 813412c..2c25d8f 100644 --- a/source/lib/socket/testsuite.c +++ b/source/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/source/libcli/cldap/cldap.c b/source/libcli/cldap/cldap.c index d991028..614bd51 100644 --- a/source/libcli/cldap/cldap.c +++ b/source/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/source/libcli/cliconnect.c b/source/libcli/cliconnect.c index 4858a96..c20a7fd 100644 --- a/source/libcli/cliconnect.c +++ b/source/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/source/libcli/composite/composite.c b/source/libcli/composite/composite.c -- Samba Shared Repository