s3:torture: add SMB2-NEGPROT test
authorStefan Metzmacher <metze@samba.org>
Tue, 30 Aug 2011 16:50:35 +0000 (18:50 +0200)
committerStefan Metzmacher <metze@samba.org>
Thu, 24 Nov 2011 18:02:32 +0000 (19:02 +0100)
metze

source3/torture/proto.h
source3/torture/test_smb2.c
source3/torture/torture.c

index bf75a5ae93d61752da3ccc3bfa9404f2b3cdce99..adfccd8c2071c742b082fc4e2acd8795098b3877 100644 (file)
@@ -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);
 
index 5444c91ba65dd2554340fe79f2014d9ceb0fae90..0c4944f1f0dc67029c93604a437710dcf6eeca5b 100644 (file)
@@ -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;
+}
index 20ee6bc74693fdec06d716794295273948113657..db8f1cd20fe8f74169260d7f3dc0f5f6c7cd2323 100644 (file)
@@ -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},