summaryrefslogtreecommitdiffstats
path: root/source3
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2011-08-30 18:50:35 +0200
committerStefan Metzmacher <metze@samba.org>2011-11-24 19:02:32 +0100
commit773d0a6addbf015cf698bdd1eac7e1dc66617d21 (patch)
tree90e410aa921624e080580e7fbd7e8f7f7c96b750 /source3
parentf60b768df404ec314602be5b5f2a0ba2c5052788 (diff)
downloadsamba-773d0a6addbf015cf698bdd1eac7e1dc66617d21.tar.gz
samba-773d0a6addbf015cf698bdd1eac7e1dc66617d21.tar.xz
samba-773d0a6addbf015cf698bdd1eac7e1dc66617d21.zip
s3:torture: add SMB2-NEGPROT test
metze
Diffstat (limited to 'source3')
-rw-r--r--source3/torture/proto.h1
-rw-r--r--source3/torture/test_smb2.c63
-rw-r--r--source3/torture/torture.c1
3 files changed, 65 insertions, 0 deletions
diff --git a/source3/torture/proto.h b/source3/torture/proto.h
index bf75a5ae93d..adfccd8c207 100644
--- a/source3/torture/proto.h
+++ b/source3/torture/proto.h
@@ -94,6 +94,7 @@ bool run_notify_online(int dummy);
bool run_nttrans_create(int dummy);
bool run_nttrans_fsctl(int dummy);
bool run_smb2_basic(int dummy);
+bool run_smb2_negprot(int dummy);
bool run_local_conv_auth_info(int dummy);
bool run_local_sprintf_append(int dummy);
diff --git a/source3/torture/test_smb2.c b/source3/torture/test_smb2.c
index 5444c91ba65..0c4944f1f0d 100644
--- a/source3/torture/test_smb2.c
+++ b/source3/torture/test_smb2.c
@@ -153,3 +153,66 @@ bool run_smb2_basic(int dummy)
return true;
}
+
+bool run_smb2_negprot(int dummy)
+{
+ struct cli_state *cli;
+ NTSTATUS status;
+ enum protocol_types protocol;
+ const char *name = NULL;
+
+ printf("Starting SMB2-NEGPROT\n");
+
+ if (!torture_init_connection(&cli)) {
+ return false;
+ }
+ cli->smb2.pid = 0xFEFF;
+
+ status = smbXcli_negprot(cli->conn, cli->timeout,
+ PROTOCOL_CORE, PROTOCOL_SMB2_22);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("smbXcli_negprot returned %s\n", nt_errstr(status));
+ return false;
+ }
+
+ protocol = smbXcli_conn_protocol(cli->conn);
+
+ switch (protocol) {
+ case PROTOCOL_SMB2_02:
+ name = "SMB2_02";
+ break;
+ case PROTOCOL_SMB2_10:
+ name = "SMB2_10";
+ break;
+ case PROTOCOL_SMB2_22:
+ name = "SMB2_22";
+ break;
+ default:
+ break;
+ }
+
+ if (name) {
+ printf("Server supports %s\n", name);
+ } else {
+ printf("Server DOES NOT support SMB2\n");
+ return false;
+ }
+
+ status = smbXcli_negprot(cli->conn, cli->timeout,
+ protocol, protocol);
+ if (!NT_STATUS_EQUAL(status, NT_STATUS_CONNECTION_RESET) &&
+ !NT_STATUS_EQUAL(status, NT_STATUS_CONNECTION_DISCONNECTED) &&
+ !NT_STATUS_EQUAL(status, NT_STATUS_CONNECTION_ABORTED)) {
+ printf("2nd smbXcli_negprot should disconnect - returned %s\n",
+ nt_errstr(status));
+ return false;
+ }
+
+ if (smbXcli_conn_is_connected(cli->conn)) {
+ printf("2nd smbXcli_negprot should disconnect "
+ "- still connected\n");
+ return false;
+ }
+
+ return true;
+}
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 20ee6bc7469..db8f1cd20fe 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -8874,6 +8874,7 @@ static struct {
{ "SMB-ANY-CONNECT", run_smb_any_connect },
{ "NOTIFY-ONLINE", run_notify_online },
{ "SMB2-BASIC", run_smb2_basic },
+ { "SMB2-NEGPROT", run_smb2_negprot },
{ "LOCAL-SUBSTITUTE", run_local_substitute, 0},
{ "LOCAL-GENCACHE", run_local_gencache, 0},
{ "LOCAL-TALLOC-DICT", run_local_talloc_dict, 0},