diff options
author | David Disseldorp <ddiss@suse.de> | 2011-09-22 22:23:08 +0200 |
---|---|---|
committer | David Disseldorp <ddiss@samba.org> | 2011-09-29 13:14:21 +0200 |
commit | 392fd0db38a2382b5f96d1a5882ea4e4fcda9d01 (patch) | |
tree | 69368aaf6f18c39291c359fe3a19e52075da2f03 /source4/torture | |
parent | bd5e9758f8350b5137dccf0d5ebf24aefb970997 (diff) | |
download | samba-392fd0db38a2382b5f96d1a5882ea4e4fcda9d01.tar.gz samba-392fd0db38a2382b5f96d1a5882ea4e4fcda9d01.tar.bz2 samba-392fd0db38a2382b5f96d1a5882ea4e4fcda9d01.zip |
s4-torture: add smb2 ioctl test suite
Currently only covers FSCTL_GET_SHADOW_COPY_DATA.
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'source4/torture')
-rw-r--r-- | source4/torture/smb2/ioctl.c | 87 | ||||
-rw-r--r-- | source4/torture/smb2/smb2.c | 1 | ||||
-rw-r--r-- | source4/torture/smb2/wscript_build | 2 |
3 files changed, 89 insertions, 1 deletions
diff --git a/source4/torture/smb2/ioctl.c b/source4/torture/smb2/ioctl.c new file mode 100644 index 0000000000..bc8a96a58f --- /dev/null +++ b/source4/torture/smb2/ioctl.c @@ -0,0 +1,87 @@ +/* + Unix SMB/CIFS implementation. + + test suite for SMB2 ioctl operations + + Copyright (C) David Disseldorp 2011 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include "includes.h" +#include "librpc/gen_ndr/security.h" +#include "libcli/smb2/smb2.h" +#include "libcli/smb2/smb2_calls.h" +#include "torture/torture.h" +#include "torture/smb2/proto.h" + +#define FNAME "testfsctl.dat" + +/* + basic testing of SMB2 shadow copy calls +*/ +static bool test_ioctl_get_shadow_copy(struct torture_context *torture, + struct smb2_tree *tree) +{ + struct smb2_handle h; + uint8_t buf[100]; + NTSTATUS status; + union smb_ioctl ioctl; + TALLOC_CTX *tmp_ctx = talloc_new(tree); + + smb2_util_unlink(tree, FNAME); + + status = torture_smb2_testfile(tree, FNAME, &h); + if (!NT_STATUS_IS_OK(status)) { + printf("create write\n"); + return false; + } + + ZERO_ARRAY(buf); + status = smb2_util_write(tree, h, buf, 0, ARRAY_SIZE(buf)); + if (!NT_STATUS_IS_OK(status)) { + printf("failed write\n"); + return false; + } + + ZERO_STRUCT(ioctl); + ioctl.smb2.level = RAW_IOCTL_SMB2; + ioctl.smb2.in.file.handle = h; + ioctl.smb2.in.function = 0x144064; /* FSCTL_GET_SHADOW_COPY_DATA 0x144064 */ + ioctl.smb2.in.max_response_size = 16; + ioctl.smb2.in.flags = 1; /* Is FSCTL */ + + status = smb2_ioctl(tree, tmp_ctx, &ioctl.smb2); + if (!NT_STATUS_IS_OK(status)) { + printf("FSCTL_GET_SHADOW_COPY_DATA failed\n"); + return false; + } + + return true; +} + +/* + basic testing of SMB2 ioctls +*/ +struct torture_suite *torture_smb2_ioctl_init(void) +{ + struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "ioctl"); + + torture_suite_add_1smb2_test(suite, "shadow_copy", test_ioctl_get_shadow_copy); + + suite->description = talloc_strdup(suite, "SMB2-IOCTL tests"); + + return suite; +} + diff --git a/source4/torture/smb2/smb2.c b/source4/torture/smb2/smb2.c index 0126cf169c..de8d400ff8 100644 --- a/source4/torture/smb2/smb2.c +++ b/source4/torture/smb2/smb2.c @@ -144,6 +144,7 @@ NTSTATUS torture_smb2_init(void) torture_suite_add_suite(suite, torture_smb2_compound_init()); torture_suite_add_suite(suite, torture_smb2_oplocks_init()); torture_suite_add_suite(suite, torture_smb2_streams_init()); + torture_suite_add_suite(suite, torture_smb2_ioctl_init()); torture_suite_add_1smb2_test(suite, "bench-oplock", test_smb2_bench_oplock); torture_suite_add_1smb2_test(suite, "hold-oplock", test_smb2_hold_oplock); diff --git a/source4/torture/smb2/wscript_build b/source4/torture/smb2/wscript_build index eb8a2951f6..458a27b004 100644 --- a/source4/torture/smb2/wscript_build +++ b/source4/torture/smb2/wscript_build @@ -1,7 +1,7 @@ #!/usr/bin/env python bld.SAMBA_MODULE('TORTURE_SMB2', - source='connect.c scan.c util.c getinfo.c setinfo.c lock.c notify.c smb2.c durable_open.c oplock.c dir.c lease.c create.c acls.c read.c compound.c streams.c', + source='connect.c scan.c util.c getinfo.c setinfo.c lock.c notify.c smb2.c durable_open.c oplock.c dir.c lease.c create.c acls.c read.c compound.c streams.c ioctl.c', subsystem='smbtorture', deps='LIBCLI_SMB2 POPT_CREDENTIALS torture', internal_module=True, |