s4:torture/util: add torture_smb2_open()
authorRalph Boehme <slow@samba.org>
Wed, 10 Oct 2018 16:45:56 +0000 (18:45 +0200)
committerJeremy Allison <jra@samba.org>
Wed, 31 Oct 2018 20:27:20 +0000 (21:27 +0100)
This seems to be missing: a simple wrapper to just open a file without
fancy options.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source4/torture/smb2/util.c

index 65090b0e8b75f9ab6c57c00e2c5d9aa7de8601ed..ac8a0d5df7763d1cdeb0df3dcc5f6ab39905e4ae 100644 (file)
@@ -527,6 +527,36 @@ NTSTATUS torture_smb2_testfile(struct smb2_tree *tree, const char *fname,
                                            SEC_RIGHTS_FILE_ALL);
 }
 
+/*
+  create and return a handle to a test file
+  with a specific access mask
+*/
+NTSTATUS torture_smb2_open(struct smb2_tree *tree,
+                          const char *fname,
+                          uint32_t desired_access,
+                          struct smb2_handle *handle)
+{
+       struct smb2_create io;
+       NTSTATUS status;
+
+       io = (struct smb2_create) {
+               .in.fname = fname,
+               .in.desired_access = desired_access,
+               .in.file_attributes = FILE_ATTRIBUTE_NORMAL,
+               .in.create_disposition = NTCREATEX_DISP_OPEN,
+               .in.share_access = NTCREATEX_SHARE_ACCESS_MASK,
+       };
+
+       status = smb2_create(tree, tree, &io);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
+
+       *handle = io.out.file.handle;
+
+       return NT_STATUS_OK;
+}
+
 /*
   create and return a handle to a test directory
   with specific desired access