s4:torture add a specific share mode conflict test
authorChristian Ambach <ambi@samba.org>
Tue, 4 Jun 2013 16:18:44 +0000 (18:18 +0200)
committerChristian Ambach <ambi@samba.org>
Tue, 4 Jun 2013 16:18:44 +0000 (18:18 +0200)
this shows that the lack of ALLOW_DELETE in GPFS breaks saving with
Office 2007

source4/torture/smb2/create.c

index fcf40e17d6fa0cd3a0af3de9e19bbafd52f110b0..b9c514640ca79d8701700b67129657f4a23c18ed 100644 (file)
@@ -1472,6 +1472,77 @@ done:
        return ret;
 }
 
+/*
+  test with an already opened file and open in a way that should
+  not conflict (simulating Office 2007 behavior)
+*/
+
+static bool test_create_conflict(struct torture_context *tctx,
+                                struct smb2_tree *tree)
+{
+       union smb_open io, io1;
+       const char *fname = DNAME "\\torture_ntcreatex.txt";
+       NTSTATUS status;
+       bool ret = true;
+       struct smb2_handle h;
+
+       torture_comment(tctx,
+               "Testing SMB2 secondary open with non-conflicting sharemode\n");
+
+       smb2_util_unlink(tree, fname);
+
+       status = torture_smb2_testdir(tree, DNAME, &h);
+       CHECK_STATUS(status, NT_STATUS_OK);
+
+       status = smb2_util_close(tree, h);
+       CHECK_STATUS(status, NT_STATUS_OK);
+
+       ZERO_STRUCT(io.smb2);
+       io.generic.level = RAW_OPEN_SMB2;
+       io.smb2.in.create_flags = NTCREATEX_FLAGS_EXTENDED;
+       io.smb2.in.desired_access = 0x120089;
+       io.smb2.in.alloc_size = 0;
+       io.smb2.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
+       io.smb2.in.share_access = NTCREATEX_SHARE_ACCESS_READ |
+               NTCREATEX_SHARE_ACCESS_DELETE;
+       io.smb2.in.create_disposition = NTCREATEX_DISP_CREATE;
+       io.smb2.in.create_options = NTCREATEX_OPTIONS_NON_DIRECTORY_FILE;
+       io.smb2.in.impersonation_level = SMB2_IMPERSONATION_IMPERSONATION;
+       io.smb2.in.security_flags = SMB2_SECURITY_DYNAMIC_TRACKING;
+       io.smb2.in.fname = fname;
+
+       status = smb2_create(tree, tctx, &(io.smb2));
+       CHECK_STATUS(status, NT_STATUS_OK);
+
+       ZERO_STRUCT(io1.smb2);
+       io1.smb2.in.create_flags = NTCREATEX_FLAGS_EXTENDED;
+       io1.smb2.in.desired_access = 0x130089;
+       io1.smb2.in.alloc_size = 0;
+       io1.smb2.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
+       io1.smb2.in.share_access = NTCREATEX_SHARE_ACCESS_READ |
+               NTCREATEX_SHARE_ACCESS_WRITE | NTCREATEX_SHARE_ACCESS_DELETE;
+       io1.smb2.in.create_disposition = NTCREATEX_DISP_OPEN_IF;
+
+       io1.smb2.in.create_options = 0;
+       io1.smb2.in.impersonation_level = SMB2_IMPERSONATION_IMPERSONATION;
+       io1.smb2.in.security_flags = SMB2_SECURITY_DYNAMIC_TRACKING;
+       io1.smb2.in.fname = fname;
+
+       status = smb2_create(tree, tctx, &(io1.smb2));
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "Second open was unsuccessful\n");
+
+done:
+
+       smb2_util_close(tree, io.smb2.out.file.handle);
+       smb2_util_close(tree, io1.smb2.out.file.handle);
+       smb2_util_unlink(tree, fname);
+       smb2_deltree(tree, DNAME);
+
+       return ret;
+}
+
+
 /*
    basic testing of SMB2 read
 */
@@ -1489,6 +1560,7 @@ struct torture_suite *torture_smb2_create_init(void)
        torture_suite_add_1smb2_test(suite, "aclfile", test_create_acl_file);
        torture_suite_add_1smb2_test(suite, "acldir", test_create_acl_dir);
        torture_suite_add_1smb2_test(suite, "nulldacl", test_create_null_dacl);
+       torture_suite_add_1smb2_test(suite, "conflict", test_create_conflict);
 
        suite->description = talloc_strdup(suite, "SMB2-CREATE tests");