s3:torture: add a new test SMB2-TCON-DEPENDENCE
authorMichael Adam <obnox@samba.org>
Mon, 19 Sep 2011 08:09:34 +0000 (10:09 +0200)
committerStefan Metzmacher <metze@samba.org>
Thu, 24 Nov 2011 18:02:33 +0000 (19:02 +0100)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
source3/torture/proto.h
source3/torture/test_smb2.c
source3/torture/torture.c

index e68545d98df52544dd47b0d625ed3f65fb09a6e7..b7de9e6b2b7598a5e4f912a6b0af2e9fb498bb38 100644 (file)
@@ -96,6 +96,7 @@ bool run_nttrans_fsctl(int dummy);
 bool run_smb2_basic(int dummy);
 bool run_smb2_negprot(int dummy);
 bool run_smb2_session_reconnect(int dummy);
+bool run_smb2_tcon_dependence(int dummy);
 bool run_local_conv_auth_info(int dummy);
 bool run_local_sprintf_append(int dummy);
 
index 04aa072adc465f2325041bc44fbc63c3b74f94e3..4a3b42c8ea0385522191ffea56939b15ab8a17c0 100644 (file)
@@ -609,3 +609,107 @@ bool run_smb2_session_reconnect(int dummy)
 
        return true;
 }
+
+bool run_smb2_tcon_dependence(int dummy)
+{
+       struct cli_state *cli;
+       NTSTATUS status;
+       uint64_t fid_persistent, fid_volatile;
+       const char *hello = "Hello, world\n";
+       uint8_t *result;
+       uint32_t nread;
+
+       printf("Starting SMB2-TCON-DEPENDENCE\n");
+
+       if (!torture_init_connection(&cli)) {
+               return false;
+       }
+       cli->smb2.pid = 0xFEFF;
+
+       status = smbXcli_negprot(cli->conn, cli->timeout,
+                                PROTOCOL_SMB2_02, PROTOCOL_SMB2_22);
+       if (!NT_STATUS_IS_OK(status)) {
+               printf("smbXcli_negprot returned %s\n", nt_errstr(status));
+               return false;
+       }
+
+       status = cli_session_setup(cli, username,
+                                  password, strlen(password),
+                                  password, strlen(password),
+                                  workgroup);
+       if (!NT_STATUS_IS_OK(status)) {
+               printf("cli_session_setup returned %s\n", nt_errstr(status));
+               return false;
+       }
+
+       status = cli_tree_connect(cli, share, "?????", "", 0);
+       if (!NT_STATUS_IS_OK(status)) {
+               printf("cli_tree_connect returned %s\n", nt_errstr(status));
+               return false;
+       }
+
+       status = smb2cli_create(cli, "tcon_depedence.txt",
+                       SMB2_OPLOCK_LEVEL_NONE, /* oplock_level, */
+                       SMB2_IMPERSONATION_IMPERSONATION, /* impersonation_level, */
+                       SEC_STD_ALL | SEC_FILE_ALL, /* desired_access, */
+                       FILE_ATTRIBUTE_NORMAL, /* file_attributes, */
+                       FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, /* share_access, */
+                       FILE_CREATE, /* create_disposition, */
+                       FILE_DELETE_ON_CLOSE, /* create_options, */
+                       NULL, /* smb2_create_blobs *blobs */
+                       &fid_persistent,
+                       &fid_volatile);
+       if (!NT_STATUS_IS_OK(status)) {
+               printf("smb2cli_create on cli %s\n", nt_errstr(status));
+               return false;
+       }
+
+       status = smb2cli_write(cli, strlen(hello), 0, fid_persistent,
+                              fid_volatile, 0, 0, (const uint8_t *)hello);
+       if (!NT_STATUS_IS_OK(status)) {
+               printf("smb2cli_write returned %s\n", nt_errstr(status));
+               return false;
+       }
+
+       status = smb2cli_flush(cli, fid_persistent, fid_volatile);
+       if (!NT_STATUS_IS_OK(status)) {
+               printf("smb2cli_flush returned %s\n", nt_errstr(status));
+               return false;
+       }
+
+       status = smb2cli_read(cli, 0x10000, 0, fid_persistent,
+                              fid_volatile, 2, 0,
+                              talloc_tos(), &result, &nread);
+       if (!NT_STATUS_IS_OK(status)) {
+               printf("smb2cli_read returned %s\n", nt_errstr(status));
+               return false;
+       }
+
+       if (nread != strlen(hello)) {
+               printf("smb2cli_read returned %d bytes, expected %d\n",
+                      (int)nread, (int)strlen(hello));
+               return false;
+       }
+
+       if (memcmp(hello, result, nread) != 0) {
+               printf("smb2cli_read returned '%s', expected '%s'\n",
+                      result, hello);
+               return false;
+       }
+
+       /* check behaviour with wrong tid... */
+
+       cli->smb2.tid++;
+
+       status = smb2cli_read(cli, 0x10000, 0, fid_persistent,
+                              fid_volatile, 2, 0,
+                              talloc_tos(), &result, &nread);
+       if (!NT_STATUS_EQUAL(status, NT_STATUS_NETWORK_NAME_DELETED)) {
+               printf("smb2cli_read returned %s\n", nt_errstr(status));
+               return false;
+       }
+
+       cli->smb2.tid--;
+
+       return true;
+}
index 9dc8925107401e1776d5b56f046c16f69b0f8739..0d6a3be041e08e812855bbabe923bb4fa415d5c6 100644 (file)
@@ -8876,6 +8876,7 @@ static struct {
        { "SMB2-BASIC", run_smb2_basic },
        { "SMB2-NEGPROT", run_smb2_negprot },
        { "SMB2-SESSION-RECONNECT", run_smb2_session_reconnect },
+       { "SMB2-TCON-DEPENDENCE", run_smb2_tcon_dependence },
        { "LOCAL-SUBSTITUTE", run_local_substitute, 0},
        { "LOCAL-GENCACHE", run_local_gencache, 0},
        { "LOCAL-TALLOC-DICT", run_local_talloc_dict, 0},