From 4b0199a5493ea2b88558cc40871e63c1dc8dbb56 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 12 Dec 2007 02:15:29 +0100 Subject: r26409: Pass smb ports along. (This used to be commit 2833f320de1f1fd39c710ad0a61c3fa1bb1df31f) --- source4/torture/basic/base.c | 2 +- source4/torture/basic/misc.c | 2 +- source4/torture/gentest.c | 25 +++++++++++++------------ source4/torture/locktest.c | 1 + source4/torture/locktest2.c | 17 +++++++++-------- source4/torture/masktest.c | 5 +++-- source4/torture/nbt/wins.c | 1 + source4/torture/raw/composite.c | 4 ++-- source4/torture/raw/lockbench.c | 2 +- source4/torture/raw/openbench.c | 2 +- source4/torture/rpc/join.c | 4 ++++ source4/torture/rpc/samba3rpc.c | 6 ++++++ source4/torture/rpc/schannel.c | 3 ++- source4/torture/unix/unix_info2.c | 6 ++++-- source4/torture/unix/whoami.c | 5 +++-- source4/torture/util_smb.c | 1 + 16 files changed, 53 insertions(+), 33 deletions(-) (limited to 'source4/torture') diff --git a/source4/torture/basic/base.c b/source4/torture/basic/base.c index 6f02fc4fe5..cba57ac413 100644 --- a/source4/torture/basic/base.c +++ b/source4/torture/basic/base.c @@ -51,7 +51,7 @@ static struct smbcli_state *open_nbt_connection(struct torture_context *tctx) goto failed; } - if (!smbcli_socket_connect(cli, host, lp_resolve_context(tctx->lp_ctx), lp_max_xmit(tctx->lp_ctx), lp_maxmux(tctx->lp_ctx))) { + if (!smbcli_socket_connect(cli, host, lp_smb_ports(tctx->lp_ctx), lp_resolve_context(tctx->lp_ctx), lp_max_xmit(tctx->lp_ctx), lp_maxmux(tctx->lp_ctx))) { torture_comment(tctx, "Failed to connect with %s\n", host); goto failed; } diff --git a/source4/torture/basic/misc.c b/source4/torture/basic/misc.c index e9a41e8299..0832556b53 100644 --- a/source4/torture/basic/misc.c +++ b/source4/torture/basic/misc.c @@ -815,7 +815,7 @@ static struct composite_context *torture_connect_async( torture_comment(tctx, "Open Connection to %s/%s\n",host,share); smb->in.dest_host=talloc_strdup(mem_ctx,host); smb->in.service=talloc_strdup(mem_ctx,share); - smb->in.port=0; + smb->in.dest_ports=lp_smb_ports(tctx->lp_ctx); smb->in.called_name = strupper_talloc(mem_ctx, host); smb->in.service_type=NULL; smb->in.credentials=cmdline_credentials; diff --git a/source4/torture/gentest.c b/source4/torture/gentest.c index 25512b9567..b257f1dc35 100644 --- a/source4/torture/gentest.c +++ b/source4/torture/gentest.c @@ -152,7 +152,7 @@ static bool connect_servers_fast(void) /***************************************************** connect to the servers *******************************************************/ -static bool connect_servers(void) +static bool connect_servers(struct loadparm_context *lp_ctx) { int i, j; @@ -185,6 +185,7 @@ static bool connect_servers(void) status = smbcli_full_connection(NULL, &servers[i].cli[j], servers[i].server_name, + lp_smb_ports(lp_ctx), servers[i].share_name, NULL, servers[i].credentials, NULL); if (!NT_STATUS_IS_OK(status)) { @@ -1927,11 +1928,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(void) +static int run_test(struct loadparm_context *lp_ctx) { int op, i; - if (!connect_servers()) { + if (!connect_servers(lp_ctx)) { printf("Failed to connect to servers\n"); exit(1); } @@ -2008,7 +2009,7 @@ static int run_test(void) perform a backtracking analysis of the minimal set of operations to generate an error */ -static void backtrack_analyze(void) +static void backtrack_analyze(struct loadparm_context *lp_ctx) { int chunk, ret; @@ -2029,7 +2030,7 @@ static void backtrack_analyze(void) } printf("Testing %d ops with %d-%d disabled\n", options.numops, base, max-1); - ret = run_test(); + ret = run_test(lp_ctx); printf("Completed %d of %d ops\n", ret, options.numops); for (i=base;i 0); printf("Reduced to %d ops\n", options.numops); - ret = run_test(); + ret = run_test(lp_ctx); if (ret != options.numops - 1) { printf("Inconsistent result? ret=%d numops=%d\n", ret, options.numops); } @@ -2070,7 +2071,7 @@ static void backtrack_analyze(void) /* start the main gentest process */ -static bool start_gentest(void) +static bool start_gentest(struct loadparm_context *lp_ctx) { int op; int ret; @@ -2106,15 +2107,15 @@ static bool start_gentest(void) } } - ret = run_test(); + ret = run_test(lp_ctx); if (ret != options.numops && options.analyze) { options.numops = ret+1; - backtrack_analyze(); + backtrack_analyze(lp_ctx); } else if (options.analyze_always) { - backtrack_analyze(); + backtrack_analyze(lp_ctx); } else if (options.analyze_continuous) { - while (run_test() == options.numops) ; + while (run_test(lp_ctx) == options.numops) ; } return ret == options.numops; @@ -2279,7 +2280,7 @@ static bool split_unc_name(const char *unc, char **server, char **share) printf("seed=%u\n", options.seed); - ret = start_gentest(); + ret = start_gentest(lp_ctx); if (ret) { printf("gentest completed - no errors\n"); diff --git a/source4/torture/locktest.c b/source4/torture/locktest.c index 82e9b416b3..9758cd2cf6 100644 --- a/source4/torture/locktest.c +++ b/source4/torture/locktest.c @@ -153,6 +153,7 @@ static struct smbcli_state *connect_one(struct loadparm_context *lp_ctx, printf("\\\\%s\\%s\n", server, share); status = smbcli_full_connection(NULL, &c, server, + lp_smb_ports(lp_ctx), share, NULL, servers[snum], NULL); if (!NT_STATUS_IS_OK(status)) { diff --git a/source4/torture/locktest2.c b/source4/torture/locktest2.c index 1dfefc15ed..db323e1391 100644 --- a/source4/torture/locktest2.c +++ b/source4/torture/locktest2.c @@ -136,7 +136,7 @@ static bool try_unlock(struct smbcli_state *c, int fstype, /***************************************************** return a connection to a server *******************************************************/ -static struct smbcli_state *connect_one(char *share) +static struct smbcli_state *connect_one(char *share, const char **ports) { struct smbcli_state *c; char *server_n; @@ -163,7 +163,7 @@ static struct smbcli_state *connect_one(char *share) slprintf(myname,sizeof(myname), "lock-%u-%u", getpid(), count++); nt_status = smbcli_full_connection(NULL, - &c, myname, server_n, 0, share, NULL, + &c, myname, server_n, ports, share, NULL, username, lp_workgroup(), password, NULL); if (!NT_STATUS_IS_OK(nt_status)) { DEBUG(0, ("smbcli_full_connection failed with error %s\n", nt_errstr(nt_status))); @@ -179,6 +179,7 @@ static struct smbcli_state *connect_one(char *share) static void reconnect(struct smbcli_state *cli[NSERVERS][NCONNECTIONS], char *nfs[NSERVERS], int fnum[NSERVERS][NUMFSTYPES][NCONNECTIONS][NFILES], + const char **ports, char *share1, char *share2) { int server, conn, f, fstype; @@ -197,7 +198,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]); + cli[server][conn] = connect_one(share[server], ports); if (!cli[server][conn]) { DEBUG(0,("Failed to connect to %s\n", share[server])); exit(1); @@ -343,7 +344,7 @@ 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) +static void test_locks(char *share1, char *share2, char *nfspath1, char *nfspath2, const char **ports) { struct smbcli_state *cli[NSERVERS][NCONNECTIONS]; char *nfs[NSERVERS]; @@ -372,7 +373,7 @@ static void test_locks(char *share1, char *share2, char *nfspath1, char *nfspath recorded[n].needed = true; } - reconnect(cli, nfs, fnum, share1, share2); + reconnect(cli, nfs, fnum, share1, share2, ports); open_files(cli, nfs, fnum); n = retest(cli, nfs, fnum, numops); @@ -383,7 +384,7 @@ static void test_locks(char *share1, char *share2, char *nfspath1, char *nfspath n1 = n; close_files(cli, nfs, fnum); - reconnect(cli, nfs, fnum, share1, share2); + reconnect(cli, nfs, fnum, share1, share2, ports); open_files(cli, nfs, fnum); for (i=0;ilp_ctx); io.in.wins_servers = str_list_make(tctx, address, NULL); io.in.addresses = str_list_make(tctx, myaddress, NULL); io.in.nb_flags = nb_flags; diff --git a/source4/torture/raw/composite.c b/source4/torture/raw/composite.c index 5a663fb565..0367110ddc 100644 --- a/source4/torture/raw/composite.c +++ b/source4/torture/raw/composite.c @@ -153,7 +153,7 @@ static bool test_fetchfile(struct smbcli_state *cli, struct torture_context *tct } io2.in.dest_host = torture_setting_string(tctx, "host", NULL); - io2.in.port = 0; + io2.in.ports = lp_smb_ports(tctx->lp_ctx); io2.in.called_name = torture_setting_string(tctx, "host", NULL); io2.in.service = torture_setting_string(tctx, "share", NULL); io2.in.service_type = "A:"; @@ -341,7 +341,7 @@ static bool test_fsinfo(struct smbcli_state *cli, struct torture_context *tctx) bool ret = true; io1.in.dest_host = torture_setting_string(tctx, "host", NULL); - io1.in.port = 0; + io1.in.dest_ports = lp_smb_ports(tctx->lp_ctx); io1.in.called_name = torture_setting_string(tctx, "host", NULL); io1.in.service = torture_setting_string(tctx, "share", NULL); io1.in.service_type = "A:"; diff --git a/source4/torture/raw/lockbench.c b/source4/torture/raw/lockbench.c index 113634f264..744aab66b1 100644 --- a/source4/torture/raw/lockbench.c +++ b/source4/torture/raw/lockbench.c @@ -185,7 +185,7 @@ static void reopen_connection(struct event_context *ev, struct timed_event *te, } io->in.dest_host = state->dest_host; - io->in.port = state->dest_port; + io->in.dest_ports = state->dest_port; io->in.called_name = state->called_name; io->in.service = share; io->in.service_type = state->service_type; diff --git a/source4/torture/raw/openbench.c b/source4/torture/raw/openbench.c index 8f9803fa4d..ceb52cdfcf 100644 --- a/source4/torture/raw/openbench.c +++ b/source4/torture/raw/openbench.c @@ -123,7 +123,7 @@ static void reopen_connection(struct event_context *ev, struct timed_event *te, } io->in.dest_host = state->dest_host; - io->in.port = state->dest_port; + io->in.dest_ports = state->dest_port; io->in.called_name = state->called_name; io->in.service = share; io->in.service_type = state->service_type; diff --git a/source4/torture/rpc/join.c b/source4/torture/rpc/join.c index d973d2d083..8ab6ae03ea 100644 --- a/source4/torture/rpc/join.c +++ b/source4/torture/rpc/join.c @@ -5,6 +5,8 @@ #include "auth/credentials/credentials.h" #include "torture/rpc/rpc.h" +#include "param/param.h" + #define TORTURE_NETBIOS_NAME "smbtorturejoin" @@ -29,6 +31,7 @@ bool torture_rpc_join(struct torture_context *torture) } status = smbcli_full_connection(tj, &cli, host, + lp_smb_ports(torture->lp_ctx), "IPC$", NULL, machine_account, NULL); @@ -53,6 +56,7 @@ bool torture_rpc_join(struct torture_context *torture) } status = smbcli_full_connection(tj, &cli, host, + lp_smb_ports(torture->lp_ctx), "IPC$", NULL, machine_account, NULL); diff --git a/source4/torture/rpc/samba3rpc.c b/source4/torture/rpc/samba3rpc.c index 96ed03fc6f..496453e181 100644 --- a/source4/torture/rpc/samba3rpc.c +++ b/source4/torture/rpc/samba3rpc.c @@ -80,6 +80,7 @@ bool torture_bind_authcontext(struct torture_context *torture) status = smbcli_full_connection(mem_ctx, &cli, torture_setting_string(torture, "host", NULL), + lp_smb_ports(torture->lp_ctx), "IPC$", NULL, cmdline_credentials, NULL); if (!NT_STATUS_IS_OK(status)) { @@ -287,6 +288,7 @@ bool torture_bind_samba3(struct torture_context *torture) status = smbcli_full_connection(mem_ctx, &cli, torture_setting_string(torture, "host", NULL), + lp_smb_ports(torture->lp_ctx), "IPC$", NULL, cmdline_credentials, NULL); if (!NT_STATUS_IS_OK(status)) { @@ -1144,6 +1146,7 @@ bool torture_netlogon_samba3(struct torture_context *torture) status = smbcli_full_connection(mem_ctx, &cli, torture_setting_string(torture, "host", NULL), + lp_smb_ports(torture->lp_ctx), "IPC$", NULL, anon_creds, NULL); if (!NT_STATUS_IS_OK(status)) { d_printf("smbcli_full_connection failed: %s\n", @@ -1225,6 +1228,7 @@ static bool test_join3(struct torture_context *tctx, status = smbcli_full_connection(tctx, &cli, torture_setting_string(tctx, "host", NULL), + lp_smb_ports(tctx->lp_ctx), "IPC$", NULL, smb_creds, NULL); if (!NT_STATUS_IS_OK(status)) { d_printf("smbcli_full_connection failed: %s\n", @@ -1588,6 +1592,7 @@ bool torture_samba3_rpc_getusername(struct torture_context *torture) status = smbcli_full_connection( mem_ctx, &cli, torture_setting_string(torture, "host", NULL), + lp_smb_ports(torture->lp_ctx), "IPC$", NULL, cmdline_credentials, NULL); if (!NT_STATUS_IS_OK(status)) { d_printf("(%s) smbcli_full_connection failed: %s\n", @@ -1612,6 +1617,7 @@ bool torture_samba3_rpc_getusername(struct torture_context *torture) status = smbcli_full_connection( mem_ctx, &cli, torture_setting_string(torture, "host", NULL), + lp_smb_ports(torture->lp_ctx), "IPC$", NULL, anon_creds, NULL); if (!NT_STATUS_IS_OK(status)) { d_printf("(%s) anon smbcli_full_connection failed: %s\n", diff --git a/source4/torture/rpc/schannel.c b/source4/torture/rpc/schannel.c index 6b0cbbf525..cb9b8be2c9 100644 --- a/source4/torture/rpc/schannel.c +++ b/source4/torture/rpc/schannel.c @@ -244,7 +244,8 @@ static bool test_schannel(struct torture_context *tctx, struct creds_CredentialState *creds; struct cli_credentials *credentials; - join_ctx = torture_join_domain(tctx, talloc_asprintf(tctx, "%s%d", TEST_MACHINE_NAME, i), + join_ctx = torture_join_domain(tctx, + talloc_asprintf(tctx, "%s%d", TEST_MACHINE_NAME, i), acct_flags, &credentials); torture_assert(tctx, join_ctx != NULL, "Failed to join domain"); diff --git a/source4/torture/unix/unix_info2.c b/source4/torture/unix/unix_info2.c index 882dc7a084..d5fe8bc260 100644 --- a/source4/torture/unix/unix_info2.c +++ b/source4/torture/unix/unix_info2.c @@ -26,6 +26,7 @@ #include "torture/basic/proto.h" #include "lib/cmdline/popt_common.h" #include "auth/credentials/credentials.h" +#include "param/param.h" struct unix_info2 { uint64_t end_of_file; @@ -54,8 +55,9 @@ static struct smbcli_state *connect_to_server(struct torture_context *tctx) const char *host = torture_setting_string(tctx, "host", NULL); const char *share = torture_setting_string(tctx, "share", NULL); - status = smbcli_full_connection(tctx, &cli, - host, share, NULL, + status = smbcli_full_connection(tctx, &cli, host, + lp_smb_ports(tctx->lp_ctx), + share, NULL, cmdline_credentials, NULL); if (!NT_STATUS_IS_OK(status)) { diff --git a/source4/torture/unix/whoami.c b/source4/torture/unix/whoami.c index 422e2abcbf..412a256da7 100644 --- a/source4/torture/unix/whoami.c +++ b/source4/torture/unix/whoami.c @@ -75,8 +75,9 @@ static struct smbcli_state *connect_to_server(struct torture_context *tctx, const char *host = torture_setting_string(tctx, "host", NULL); const char *share = torture_setting_string(tctx, "share", NULL); - status = smbcli_full_connection(tctx, &cli, - host, share, NULL, + status = smbcli_full_connection(tctx, &cli, host, + lp_smb_ports(tctx->lp_ctx), + share, NULL, creds, NULL); if (!NT_STATUS_IS_OK(status)) { diff --git a/source4/torture/util_smb.c b/source4/torture/util_smb.c index 65dfaec1cc..1168f31679 100644 --- a/source4/torture/util_smb.c +++ b/source4/torture/util_smb.c @@ -474,6 +474,7 @@ _PUBLIC_ bool torture_open_connection_share(TALLOC_CTX *mem_ctx, NTSTATUS status; status = smbcli_full_connection(mem_ctx, c, hostname, + lp_smb_ports(tctx->lp_ctx), sharename, NULL, cmdline_credentials, ev); if (!NT_STATUS_IS_OK(status)) { -- cgit