seltest: allow opening files with arbitrary rights in smb2.ioctl tests
authorUri Simchoni <uri@samba.org>
Mon, 15 Aug 2016 20:39:50 +0000 (23:39 +0300)
committerKarolin Seeger <kseeger@samba.org>
Tue, 13 Sep 2016 10:27:27 +0000 (12:27 +0200)
Separate file creation (which requires write access) from the
opening of the file for the test (which might be without write
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>
(cherry picked from commit 6ce0304eda4b464972defcecd591fab03428bd03)

source4/torture/smb2/ioctl.c

index 8e7f69ad819d1041dd2e0271d1ffaba3bab959db..0aadca29b0718fc2866113e87d2cd215433a241b 100644 (file)
@@ -273,20 +273,36 @@ static bool test_setup_create_fill(struct torture_context *torture,
                                   uint32_t file_attributes)
 {
        bool ok;
+       uint32_t initial_access = desired_access;
+
+       if (size > 0) {
+               initial_access |= SEC_FILE_APPEND_DATA;
+       }
 
        smb2_util_unlink(tree, fname);
 
        ok = test_setup_open(torture, tree, mem_ctx,
                             fname,
                             fh,
-                            desired_access,
+                            initial_access,
                             file_attributes);
-       torture_assert(torture, ok, "file open");
+       torture_assert(torture, ok, "file create");
 
        if (size > 0) {
                ok = write_pattern(torture, tree, mem_ctx, *fh, 0, size, 0);
                torture_assert(torture, ok, "write pattern");
        }
+
+       if (initial_access != desired_access) {
+               smb2_util_close(tree, *fh);
+               ok = test_setup_open(torture, tree, mem_ctx,
+                                    fname,
+                                    fh,
+                                    desired_access,
+                                    file_attributes);
+               torture_assert(torture, ok, "file open");
+       }
+
        return true;
 }