summaryrefslogtreecommitdiff
path: root/source3/torture/test_smb2.c
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2011-09-19 10:09:34 +0200
committerStefan Metzmacher <metze@samba.org>2011-11-24 19:02:33 +0100
commit4c29389c045ec6489b10cb64aab394d21fe884ed (patch)
treec99f5dad1f6aebc572c1d4cef9f1a005ef7a24cb /source3/torture/test_smb2.c
parent1fef161d2a0b73519cba23739e326ba0b2e11c2a (diff)
downloadsamba-4c29389c045ec6489b10cb64aab394d21fe884ed.tar.gz
samba-4c29389c045ec6489b10cb64aab394d21fe884ed.tar.bz2
samba-4c29389c045ec6489b10cb64aab394d21fe884ed.zip
s3:torture: add a new test SMB2-TCON-DEPENDENCE
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'source3/torture/test_smb2.c')
-rw-r--r--source3/torture/test_smb2.c104
1 files changed, 104 insertions, 0 deletions
diff --git a/source3/torture/test_smb2.c b/source3/torture/test_smb2.c
index 04aa072adc..4a3b42c8ea 100644
--- a/source3/torture/test_smb2.c
+++ b/source3/torture/test_smb2.c
@@ -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;
+}