1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-12 09:18:10 +03:00

* fixed byte order in epmapper parsing

* allow rpc transport to be specified on command line in smbtorture
(This used to be commit 8a82050fd6)
This commit is contained in:
Andrew Tridgell 2003-11-24 13:19:00 +00:00
parent 7befc0648e
commit f4e485117a
4 changed files with 87 additions and 46 deletions
source4

View File

@ -467,7 +467,7 @@ uint32 interpret_addr(const char *str)
if (strcmp(str,"255.255.255.255") == 0)
return(0xFFFFFFFF);
/* if it's in the form of an IP address then get the lib to interpret it */
/* if it's in the form of an IP address then get the lib to interpret it */
if (is_ipaddress(str)) {
res = inet_addr(str);
} else {

View File

@ -155,6 +155,10 @@ NTSTATUS dcerpc_pipe_open_tcp(struct dcerpc_pipe **p,
int fd;
struct in_addr addr;
if (port == 0) {
port = 135;
}
addr.s_addr = interpret_addr(server);
if (addr.s_addr == 0) {
return NT_STATUS_BAD_NETWORK_NAME;
@ -195,6 +199,7 @@ NTSTATUS dcerpc_pipe_open_tcp(struct dcerpc_pipe **p,
if (!NT_STATUS_IS_OK(status)) {
dcerpc_pipe_close(*p);
return status;
}
return NT_STATUS_OK;

View File

@ -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;
}

View File

@ -130,6 +130,33 @@ BOOL torture_close_connection(struct cli_state *c)
return ret;
}
/* open a rpc connection to a named pipe */
static NTSTATUS torture_rpc_tcp(struct dcerpc_pipe **p,
const char *pipe_name,
const char *pipe_uuid,
uint32 pipe_version)
{
NTSTATUS status;
char *host = lp_parm_string(-1, "torture", "host");
const char *port = lp_parm_string(-1, "torture", "share");
DEBUG(2,("Connecting to dcerpc server %s:%s\n", host, port));
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));
return status;
}
/* always do NDR validation in smbtorture */
(*p)->flags |= DCERPC_DEBUG_VALIDATE_BOTH;
return status;
}
/* open a rpc connection to a named pipe */
NTSTATUS torture_rpc_connection(struct dcerpc_pipe **p,
const char *pipe_name,
@ -138,6 +165,16 @@ NTSTATUS torture_rpc_connection(struct dcerpc_pipe **p,
{
struct cli_state *cli;
NTSTATUS status;
char *transport = lp_parm_string(-1, "torture", "transport");
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;
@ -157,30 +194,6 @@ 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 status;
status = dcerpc_pipe_open_tcp(p,
lp_parm_string(-1, "torture", "host"),
lp_parm_int(-1, "torture", "share"),
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));
return status;
}
/* always do NDR validation in smbtorture */
(*p)->flags |= DCERPC_DEBUG_VALIDATE_BOTH;
return status;
}
/* close a rpc connection to a named pipe */
NTSTATUS torture_rpc_close(struct dcerpc_pipe *p)
{
@ -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++;