s4-selftest: add functions which create with desired access
authorUri Simchoni <uri@samba.org>
Sun, 31 Jul 2016 11:26:24 +0000 (14:26 +0300)
committerDavid Disseldorp <ddiss@samba.org>
Tue, 16 Aug 2016 09:31:27 +0000 (11:31 +0200)
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 <uri@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>
source4/torture/smb2/util.c

index 814e398dd085cc87a8317480b1caf0e5369ce7cc..c9d47aec1e6b54a289535a502732b6d768692c64 100644 (file)
@@ -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