diff options
author | Andrew Tridgell <tridge@samba.org> | 2003-11-24 13:19:00 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2003-11-24 13:19:00 +0000 |
commit | f4e485117a0dea627addfb8518e6517c7104fd9e (patch) | |
tree | 6caaaa42897ddc169de7d23990725cf7af2a6bdb /source4/torture | |
parent | 7befc0648e4366980b7efdf31cc946ea11de5101 (diff) | |
download | samba-f4e485117a0dea627addfb8518e6517c7104fd9e.tar.gz samba-f4e485117a0dea627addfb8518e6517c7104fd9e.tar.bz2 samba-f4e485117a0dea627addfb8518e6517c7104fd9e.zip |
* fixed byte order in epmapper parsing
* allow rpc transport to be specified on command line in smbtorture
(This used to be commit 8a82050fd6f45bcdb31c2c365eaed5fc12599e4f)
Diffstat (limited to 'source4/torture')
-rw-r--r-- | source4/torture/rpc/epmapper.c | 14 | ||||
-rw-r--r-- | source4/torture/torture.c | 94 |
2 files changed, 72 insertions, 36 deletions
diff --git a/source4/torture/rpc/epmapper.c b/source4/torture/rpc/epmapper.c index a056f2254e..cef3355b8a 100644 --- a/source4/torture/rpc/epmapper.c +++ b/source4/torture/rpc/epmapper.c @@ -50,7 +50,7 @@ static void display_tower(TALLOC_CTX *mem_ctx, struct epm_towers *twr) printf(" IP:"); if (rhs->rhs_data.length == 4) { struct in_addr in; - in.s_addr = RIVAL(rhs->rhs_data.data, 0); + in.s_addr = IVAL(rhs->rhs_data.data, 0); printf("%s", inet_ntoa(in)); } break; @@ -74,14 +74,14 @@ static void display_tower(TALLOC_CTX *mem_ctx, struct epm_towers *twr) case 0x1f: printf(" TCP:"); if (rhs->rhs_data.length == 2) { - printf("%d", SVAL(rhs->rhs_data.data, 0)); + printf("%d", RSVAL(rhs->rhs_data.data, 0)); } break; default: printf(" UNK(%02x):", lhs->protocol); if (rhs->rhs_data.length == 2) { - printf("%d", SVAL(rhs->rhs_data.data, 0)); + printf("%d", RSVAL(rhs->rhs_data.data, 0)); } break; } @@ -179,10 +179,10 @@ BOOL torture_rpc_epmapper(int dummy) mem_ctx = talloc_init("torture_rpc_epmapper"); - status = torture_rpc_tcp(&p, - DCERPC_EPMAPPER_NAME, - DCERPC_EPMAPPER_UUID, - DCERPC_EPMAPPER_VERSION); + status = torture_rpc_connection(&p, + DCERPC_EPMAPPER_NAME, + DCERPC_EPMAPPER_UUID, + DCERPC_EPMAPPER_VERSION); if (!NT_STATUS_IS_OK(status)) { return False; } diff --git a/source4/torture/torture.c b/source4/torture/torture.c index 73373d944c..22798ed236 100644 --- a/source4/torture/torture.c +++ b/source4/torture/torture.c @@ -131,23 +131,22 @@ BOOL torture_close_connection(struct cli_state *c) } /* open a rpc connection to a named pipe */ -NTSTATUS torture_rpc_connection(struct dcerpc_pipe **p, +static NTSTATUS torture_rpc_tcp(struct dcerpc_pipe **p, const char *pipe_name, const char *pipe_uuid, uint32 pipe_version) { - struct cli_state *cli; NTSTATUS status; + char *host = lp_parm_string(-1, "torture", "host"); + const char *port = lp_parm_string(-1, "torture", "share"); - if (!torture_open_connection(&cli)) { - return NT_STATUS_UNSUCCESSFUL; - } + DEBUG(2,("Connecting to dcerpc server %s:%s\n", host, port)); - status = dcerpc_pipe_open_smb(p, cli->tree, pipe_name, pipe_uuid, pipe_version); + status = dcerpc_pipe_open_tcp(p, host, atoi(port), + pipe_uuid, pipe_version); if (!NT_STATUS_IS_OK(status)) { printf("Open of pipe '%s' failed with error (%s)\n", pipe_name, nt_errstr(status)); - torture_close_connection(cli); return status; } @@ -157,21 +156,35 @@ NTSTATUS torture_rpc_connection(struct dcerpc_pipe **p, return status; } + /* open a rpc connection to a named pipe */ -NTSTATUS torture_rpc_tcp(struct dcerpc_pipe **p, - const char *pipe_name, - const char *pipe_uuid, - uint32 pipe_version) +NTSTATUS torture_rpc_connection(struct dcerpc_pipe **p, + const char *pipe_name, + const char *pipe_uuid, + uint32 pipe_version) { + struct cli_state *cli; NTSTATUS status; + char *transport = lp_parm_string(-1, "torture", "transport"); - status = dcerpc_pipe_open_tcp(p, - lp_parm_string(-1, "torture", "host"), - lp_parm_int(-1, "torture", "share"), - pipe_uuid, pipe_version); + if (strcmp(transport, "ncacn_ip_tcp") == 0) { + return torture_rpc_tcp(p, pipe_name, pipe_uuid, pipe_version); + } + + if (strcmp(transport, "ncacn_np") != 0) { + printf("Unsupported RPC transport '%s'\n", transport); + return NT_STATUS_UNSUCCESSFUL; + } + + if (!torture_open_connection(&cli)) { + return NT_STATUS_UNSUCCESSFUL; + } + + status = dcerpc_pipe_open_smb(p, cli->tree, pipe_name, pipe_uuid, pipe_version); if (!NT_STATUS_IS_OK(status)) { printf("Open of pipe '%s' failed with error (%s)\n", pipe_name, nt_errstr(status)); + torture_close_connection(cli); return status; } @@ -4148,27 +4161,50 @@ static void usage(void) for(p = argv[1]; *p; p++) if(*p == '\\') *p = '/'; - - if (strncmp(argv[1], "//", 2)) { - usage(); - } - host = strdup(&argv[1][2]); - p = strchr_m(&host[2],'/'); - if (!p) { - usage(); + + /* see if its a RPC transport specifier */ + if (strncmp(argv[1], "ncacn", 5) == 0) { + char *transport = strdup(argv[1]); + p = strchr_m(transport, ':'); + if (!p) usage(); + *p = 0; + host = p+1; + p = strchr_m(host, ':'); + if (p) { + *p = 0; + share = p+1; + lp_set_cmdline("torture:share", share); + } else { + share = ""; + lp_set_cmdline("torture:share", share); + } + lp_set_cmdline("torture:host", host); + lp_set_cmdline("torture:transport", transport); + } else { + if (strncmp(argv[1], "//", 2)) { + usage(); + } + + host = strdup(&argv[1][2]); + p = strchr_m(&host[2],'/'); + if (!p) { + usage(); + } + *p = 0; + share = strdup(p+1); + + lp_set_cmdline("torture:host", host); + lp_set_cmdline("torture:share", share); + lp_set_cmdline("torture:password", ""); + lp_set_cmdline("torture:transport", "ncacn_np"); } - *p = 0; - share = strdup(p+1); if (getenv("LOGNAME")) { username = strdup(getenv("LOGNAME")); } - - lp_set_cmdline("torture:host", host); - lp_set_cmdline("torture:share", share); lp_set_cmdline("torture:username", username); - lp_set_cmdline("torture:password", ""); + argc--; argv++; |