s4:torture/vfs/fruit: expand test "setinfo eof stream"
authorRalph Boehme <slow@samba.org>
Mon, 22 Oct 2018 10:43:16 +0000 (12:43 +0200)
committerJeremy Allison <jra@samba.org>
Wed, 31 Oct 2018 20:27:20 +0000 (21:27 +0100)
o Adds checks verifying that after setting eof to 0 on a stream, a
  subsequent open gets ENOENT, before and after closing the handle that
  had been used to set eof to 0.

o Verify that a write to a handle succeeds after that handle has been
  used to set eof to 0 on a stream.

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>
selftest/knownfail.d/samba3.vfs.fruit
source4/torture/vfs/fruit.c

index 6307e2b34043b5f960a67ad7861eeb004b5bed3e..5ecba522d4acbc92db2afc70df20ba3dbb93699f 100644 (file)
@@ -1,2 +1,5 @@
 ^samba3.vfs.fruit streams_depot.OS X AppleDouble file conversion\(nt4_dc\)
 ^samba3.vfs.fruit streams_depot.OS X AppleDouble file conversion without embedded xattr\(nt4_dc\)
+^samba3.vfs.fruit metadata_netatalk.setinfo eof stream\(nt4_dc\)
+^samba3.vfs.fruit metadata_stream.setinfo eof stream\(nt4_dc\)
+^samba3.vfs.fruit streams_depot.setinfo eof stream\(nt4_dc\)
index 8dd34e39294b47fd462e03b5b00fafc89d3a4174..ebe11bc44db66b4fd6bbc2446de87097ae772f5b 100644 (file)
@@ -4981,8 +4981,32 @@ static bool test_setinfo_stream_eof(struct torture_context *tctx,
        torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
                                        "set eof 0 failed\n");
 
+       ZERO_STRUCT(create);
+       create.in.desired_access = SEC_FILE_READ_ATTRIBUTE;
+       create.in.share_access = NTCREATEX_SHARE_ACCESS_MASK;
+       create.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
+       create.in.create_disposition = NTCREATEX_DISP_OPEN;
+       create.in.fname = sname;
+
+       status = smb2_create(tree, tctx, &create);
+       torture_assert_ntstatus_equal_goto(
+               tctx, status, NT_STATUS_OBJECT_NAME_NOT_FOUND, ret, done,
+               "Unexpected status\n");
+
        smb2_util_close(tree, h1);
 
+       ZERO_STRUCT(create);
+       create.in.desired_access = SEC_FILE_READ_ATTRIBUTE;
+       create.in.share_access = NTCREATEX_SHARE_ACCESS_MASK;
+       create.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
+       create.in.create_disposition = NTCREATEX_DISP_OPEN;
+       create.in.fname = sname;
+
+       status = smb2_create(tree, tctx, &create);
+       torture_assert_ntstatus_equal_goto(
+               tctx, status, NT_STATUS_OBJECT_NAME_NOT_FOUND, ret, done,
+               "Unexpected status\n");
+
        status = torture_smb2_testfile_access(tree, sname, &h1,
                                              SEC_FILE_WRITE_DATA);
        torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
@@ -5061,6 +5085,18 @@ static bool test_setinfo_stream_eof(struct torture_context *tctx,
        torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
                                        "set eof 0 failed\n");
 
+       ZERO_STRUCT(create);
+       create.in.desired_access = SEC_FILE_READ_ATTRIBUTE;
+       create.in.share_access = NTCREATEX_SHARE_ACCESS_MASK;
+       create.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
+       create.in.create_disposition = NTCREATEX_DISP_OPEN;
+       create.in.fname = sname;
+
+       status = smb2_create(tree, tctx, &create);
+       torture_assert_ntstatus_equal_goto(
+               tctx, status, NT_STATUS_OBJECT_NAME_NOT_FOUND, ret, done,
+               "Unexpected status\n");
+
        smb2_util_close(tree, h1);
 
        ZERO_STRUCT(create);
@@ -5120,6 +5156,31 @@ static bool test_setinfo_stream_eof(struct torture_context *tctx,
        torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
                                        "torture_smb2_testfile failed\n");
        smb2_util_close(tree, h1);
+
+       torture_comment(tctx, "Writing to stream after setting EOF to 0\n");
+       status = torture_smb2_testfile_access(tree, sname, &h1,
+                                             SEC_FILE_WRITE_DATA);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "torture_smb2_testfile failed\n");
+
+       status = smb2_util_write(tree, h1, "1234567890", 0, 10);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb2_util_write failed\n");
+
+       ZERO_STRUCT(sfinfo);
+       sfinfo.generic.in.file.handle = h1;
+       sfinfo.generic.level = RAW_SFILEINFO_END_OF_FILE_INFORMATION;
+       sfinfo.position_information.in.position = 0;
+       status = smb2_setinfo_file(tree, &sfinfo);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "set eof 0 failed\n");
+
+       status = smb2_util_write(tree, h1, "1234567890", 0, 10);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb2_util_write failed\n");
+
+       smb2_util_close(tree, h1);
+
 done:
        smb2_util_unlink(tree, fname);
        smb2_util_rmdir(tree, BASEDIR);