summaryrefslogtreecommitdiff
path: root/source4/torture/smb2
diff options
context:
space:
mode:
authorDavid Disseldorp <ddiss@samba.org>2013-08-07 17:16:12 +0200
committerJeremy Allison <jra@samba.org>2013-08-09 22:03:38 +0200
commitd944841211a407c3587ccabd3615df55fba72aaf (patch)
tree7ee4f3662921fcf7140dd0110635997920486609 /source4/torture/smb2
parent8fde65e1998e8dfa5210b74c04a5ee6e6c837202 (diff)
downloadsamba-d944841211a407c3587ccabd3615df55fba72aaf.tar.gz
samba-d944841211a407c3587ccabd3615df55fba72aaf.tar.bz2
samba-d944841211a407c3587ccabd3615df55fba72aaf.zip
torture: add smb2 FSCTL_[GET/SET]_COMPRESSION test
This test simply creates a file and checks the compression state before and after FSCTL_SET_COMPRESSION(COMPRESSION_FORMAT_DEFAULT). The test expects the compression state to be COMPRESSION_FORMAT_LZNT1 after set, conforming to Windows Server behaviour. If the server responds to the first FSCTL_GET_COMPRESSION request with NT_STATUS_NOT_SUPPORTED or NT_STATUS_INVALID_DEVICE_REQUEST, then the test is skipped. This allows it to run during selftest. Signed-off-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Fri Aug 9 22:03:39 CEST 2013 on sn-devel-104
Diffstat (limited to 'source4/torture/smb2')
-rw-r--r--source4/torture/smb2/ioctl.c84
1 files changed, 84 insertions, 0 deletions
diff --git a/source4/torture/smb2/ioctl.c b/source4/torture/smb2/ioctl.c
index e8d12038e0..6b5895b7c0 100644
--- a/source4/torture/smb2/ioctl.c
+++ b/source4/torture/smb2/ioctl.c
@@ -1530,6 +1530,88 @@ static bool test_ioctl_copy_chunk_max_output_sz(struct torture_context *torture,
return true;
}
+static bool test_ioctl_compress_file_flag(struct torture_context *torture,
+ struct smb2_tree *tree)
+{
+ struct smb2_handle fh;
+ NTSTATUS status;
+ union smb_ioctl ioctl;
+ TALLOC_CTX *tmp_ctx = talloc_new(tree);
+ struct compression_state cmpr_state;
+ enum ndr_err_code ndr_ret;
+ bool ok;
+
+ ok = test_setup_create_fill(torture, tree, tmp_ctx,
+ FNAME, &fh, 0, SEC_RIGHTS_FILE_ALL);
+ torture_assert(torture, ok, "setup compression file");
+
+ ZERO_STRUCT(ioctl);
+ ioctl.smb2.level = RAW_IOCTL_SMB2;
+ ioctl.smb2.in.file.handle = fh;
+ ioctl.smb2.in.function = FSCTL_GET_COMPRESSION;
+ ioctl.smb2.in.max_response_size = sizeof(struct compression_state);
+ ioctl.smb2.in.flags = SMB2_IOCTL_FLAG_IS_FSCTL;
+
+ status = smb2_ioctl(tree, tmp_ctx, &ioctl.smb2);
+ if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)
+ || NT_STATUS_EQUAL(status, NT_STATUS_INVALID_DEVICE_REQUEST)) {
+ smb2_util_close(tree, fh);
+ torture_skip(torture, "FSCTL_GET_COMPRESSION not supported\n");
+ }
+ torture_assert_ntstatus_ok(torture, status, "FSCTL_GET_COMPRESSION");
+
+ ndr_ret = ndr_pull_struct_blob(&ioctl.smb2.out.out, tmp_ctx,
+ &cmpr_state,
+ (ndr_pull_flags_fn_t)ndr_pull_compression_state);
+
+ torture_assert_ndr_success(torture, ndr_ret,
+ "ndr_pull_compression_state");
+
+ torture_assert(torture, (cmpr_state.format == COMPRESSION_FORMAT_NONE),
+ "initial compression state not NONE");
+
+ ZERO_STRUCT(ioctl);
+ ioctl.smb2.level = RAW_IOCTL_SMB2;
+ ioctl.smb2.in.file.handle = fh;
+ ioctl.smb2.in.function = FSCTL_SET_COMPRESSION;
+ ioctl.smb2.in.flags = SMB2_IOCTL_FLAG_IS_FSCTL;
+
+ cmpr_state.format = COMPRESSION_FORMAT_DEFAULT;
+ ndr_ret = ndr_push_struct_blob(&ioctl.smb2.in.out, tmp_ctx,
+ &cmpr_state,
+ (ndr_push_flags_fn_t)ndr_push_compression_state);
+ torture_assert_ndr_success(torture, ndr_ret,
+ "ndr_push_compression_state");
+
+ status = smb2_ioctl(tree, tmp_ctx, &ioctl.smb2);
+ torture_assert_ntstatus_ok(torture, status, "FSCTL_SET_COMPRESSION");
+
+ ZERO_STRUCT(ioctl);
+ ioctl.smb2.level = RAW_IOCTL_SMB2;
+ ioctl.smb2.in.file.handle = fh;
+ ioctl.smb2.in.function = FSCTL_GET_COMPRESSION;
+ ioctl.smb2.in.max_response_size = sizeof(struct compression_state);
+ ioctl.smb2.in.flags = SMB2_IOCTL_FLAG_IS_FSCTL;
+
+ status = smb2_ioctl(tree, tmp_ctx, &ioctl.smb2);
+ torture_assert_ntstatus_ok(torture, status,
+ "FSCTL_GET_COMPRESSION");
+
+ ndr_ret = ndr_pull_struct_blob(&ioctl.smb2.out.out, tmp_ctx,
+ &cmpr_state,
+ (ndr_pull_flags_fn_t)ndr_pull_compression_state);
+
+ torture_assert_ndr_success(torture, ndr_ret,
+ "ndr_pull_compression_state");
+
+ torture_assert(torture, (cmpr_state.format == COMPRESSION_FORMAT_LZNT1),
+ "invalid compression state after set");
+
+ smb2_util_close(tree, fh);
+ talloc_free(tmp_ctx);
+ return true;
+}
+
/*
basic testing of SMB2 ioctls
*/
@@ -1573,6 +1655,8 @@ struct torture_suite *torture_smb2_ioctl_init(void)
test_ioctl_copy_chunk_sparse_dest);
torture_suite_add_1smb2_test(suite, "copy_chunk_max_output_sz",
test_ioctl_copy_chunk_max_output_sz);
+ torture_suite_add_1smb2_test(suite, "compress_file_flag",
+ test_ioctl_compress_file_flag);
suite->description = talloc_strdup(suite, "SMB2-IOCTL tests");