From 6b1d5dd81f99132868006456275817cf444a8677 Mon Sep 17 00:00:00 2001 From: Uri Simchoni Date: Sun, 31 Jul 2016 14:26:24 +0300 Subject: [PATCH] s4-selftest: add functions which create with desired access Add functions which create a file or a directory with specific desired access. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12149 Signed-off-by: Uri Simchoni Reviewed-by: David Disseldorp (cherry picked from commit 1b06acafa4e9ea91a50e5ed85da881187057da6e) --- source4/torture/smb2/util.c | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c index 814e398dd08..c9d47aec1e6 100644 --- a/source4/torture/smb2/util.c +++ b/source4/torture/smb2/util.c @@ -428,19 +428,20 @@ bool torture_smb2_con_sopt(struct torture_context *tctx, return true; } - /* create and return a handle to a test file + with a specific access mask */ -NTSTATUS torture_smb2_testfile(struct smb2_tree *tree, const char *fname, - struct smb2_handle *handle) +NTSTATUS torture_smb2_testfile_access(struct smb2_tree *tree, const char *fname, + struct smb2_handle *handle, + uint32_t desired_access) { struct smb2_create io; NTSTATUS status; ZERO_STRUCT(io); io.in.oplock_level = 0; - io.in.desired_access = SEC_RIGHTS_FILE_ALL; + io.in.desired_access = desired_access; io.in.file_attributes = FILE_ATTRIBUTE_NORMAL; io.in.create_disposition = NTCREATEX_DISP_OPEN_IF; io.in.share_access = @@ -458,18 +459,30 @@ NTSTATUS torture_smb2_testfile(struct smb2_tree *tree, const char *fname, return NT_STATUS_OK; } +/* + create and return a handle to a test file +*/ +NTSTATUS torture_smb2_testfile(struct smb2_tree *tree, const char *fname, + struct smb2_handle *handle) +{ + return torture_smb2_testfile_access(tree, fname, handle, + SEC_RIGHTS_FILE_ALL); +} + /* create and return a handle to a test directory + with specific desired access */ -NTSTATUS torture_smb2_testdir(struct smb2_tree *tree, const char *fname, - struct smb2_handle *handle) +NTSTATUS torture_smb2_testdir_access(struct smb2_tree *tree, const char *fname, + struct smb2_handle *handle, + uint32_t desired_access) { struct smb2_create io; NTSTATUS status; ZERO_STRUCT(io); io.in.oplock_level = 0; - io.in.desired_access = SEC_RIGHTS_DIR_ALL; + io.in.desired_access = desired_access; io.in.file_attributes = FILE_ATTRIBUTE_DIRECTORY; io.in.create_disposition = NTCREATEX_DISP_OPEN_IF; io.in.share_access = NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE; @@ -484,6 +497,15 @@ NTSTATUS torture_smb2_testdir(struct smb2_tree *tree, const char *fname, return NT_STATUS_OK; } +/* + create and return a handle to a test directory +*/ +NTSTATUS torture_smb2_testdir(struct smb2_tree *tree, const char *fname, + struct smb2_handle *handle) +{ + return torture_smb2_testdir_access(tree, fname, handle, + SEC_RIGHTS_DIR_ALL); +} /* create a complex file using SMB2, to make it easier to -- 2.47.2