summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2011-05-29 18:43:31 +0200
committerVolker Lendecke <vl@samba.org>2011-05-29 21:10:26 +0200
commit97dcdcd5c2b7d30a246a7faff89c6618cc083a94 (patch)
treef8f9914411da3ccdff978434cb8b857f138a085d
parent18a54fe4eb8f78a3661dbc5c357a6f021f09e79e (diff)
downloadsamba-97dcdcd5c2b7d30a246a7faff89c6618cc083a94.tar.gz
samba-97dcdcd5c2b7d30a246a7faff89c6618cc083a94.tar.bz2
samba-97dcdcd5c2b7d30a246a7faff89c6618cc083a94.zip
s3: Simplify run_bad_nbt_session
-rw-r--r--source3/torture/torture.c66
1 files changed, 26 insertions, 40 deletions
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 6afa94b3b2..36c300b360 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -273,42 +273,6 @@ fail:
return ret;
}
-static struct cli_state *open_bad_nbt_connection(void)
-{
- struct nmb_name called, calling;
- struct sockaddr_storage ss;
- struct cli_state *c;
- NTSTATUS status;
-
- make_nmb_name(&calling, myname, 0x0);
- make_nmb_name(&called , host, 0x20);
-
- zero_sockaddr(&ss);
-
- if (!(c = cli_initialise_ex(signing_state))) {
- printf("Failed initialize cli_struct to connect with %s\n", host);
- return NULL;
- }
-
- c->port = 139;
-
- status = cli_connect(c, host, &ss);
- if (!NT_STATUS_IS_OK(status)) {
- printf("Failed to connect with %s. Error %s\n", host, nt_errstr(status) );
- return NULL;
- }
-
- c->timeout = 4000; /* set a short timeout (4 seconds) */
-
- if (!cli_bad_session_request(c->fd, &calling, &called)) {
- printf("Failed to connect with %s. Error %s\n", host, nt_errstr(status) );
- return NULL;
- }
-
- return c;
-}
-
-
/* Insert a NULL at the first separator of the given path and return a pointer
* to the remainder of the string.
*/
@@ -2906,15 +2870,37 @@ static bool run_negprot_nowait(int dummy)
/* send smb negprot commands, not reading the response */
static bool run_bad_nbt_session(int dummy)
{
- static struct cli_state *cli;
+ struct nmb_name called, calling;
+ struct sockaddr_storage ss;
+ NTSTATUS status;
+ int fd;
+ bool ret;
printf("starting bad nbt session test\n");
- if (!(cli = open_bad_nbt_connection())) {
- return False;
+ make_nmb_name(&calling, myname, 0x0);
+ make_nmb_name(&called , host, 0x20);
+
+ if (!resolve_name(host, &ss, 0x20, true)) {
+ d_fprintf(stderr, "Could not resolve name %s\n", host);
+ return false;
+ }
+
+ status = open_socket_out(&ss, 139, 10000, &fd);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_fprintf(stderr, "open_socket_out failed: %s\n",
+ nt_errstr(status));
+ return false;
+ }
+
+ ret = cli_bad_session_request(fd, &calling, &called);
+ close(fd);
+ if (!ret) {
+ d_fprintf(stderr, "open_socket_out failed: %s\n",
+ nt_errstr(status));
+ return false;
}
- cli_shutdown(cli);
printf("finished bad nbt session test\n");
return true;
}