]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4/torture: Create test_dir with SEC_RIGHTS_DIR_ALL
authorAnoop C S <anoopcs@samba.org>
Wed, 29 May 2024 13:11:32 +0000 (18:41 +0530)
committerRalph Boehme <slow@samba.org>
Mon, 10 Jun 2024 12:16:32 +0000 (12:16 +0000)
In shares where acl_xattr vfs module is loaded with 'ignore system acls'
set, smb2.delete-on-close-perms.FIND_and_set_DOC fails to open test_dir
due to NT_STATUS_ACCESS_DENIED as it lacks few permissions for owner
when created using create_dir(). Test case aims to set delete-on-close
for which delete permission is necessary in first place. Therefore we
now perform the creation and subsequent opening of directory using
torture_smb2_testdir() so that the open handle comes with SEC_STD_DELETE
permission.

Signed-off-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source4/torture/smb2/delete-on-close.c

index 05242876dcbe486109ef068c7ae146a20fbfe942..50c6c83c532b61fb9045b51ca17ab589c70dc2fe 100644 (file)
@@ -518,45 +518,28 @@ static bool test_doc_create_if_exist(struct torture_context *tctx, struct smb2_t
 
 static bool test_doc_find_and_set_doc(struct torture_context *tctx, struct smb2_tree *tree)
 {
-       struct smb2_create io;
+       struct smb2_handle dir_handle;
        struct smb2_find find;
        NTSTATUS status;
        union smb_search_data *d;
        union smb_setfileinfo sfinfo;
        unsigned int count;
-       uint32_t perms = 0;
-
-       perms = SEC_STD_SYNCHRONIZE | SEC_STD_READ_CONTROL | SEC_STD_DELETE |
-               SEC_DIR_WRITE_ATTRIBUTE | SEC_DIR_READ_ATTRIBUTE |
-               SEC_DIR_WRITE_EA | SEC_FILE_APPEND_DATA |
-               SEC_FILE_WRITE_DATA | SEC_DIR_LIST;
 
        /* File should not exist for this first test, so make sure */
        set_dir_delete_perms(tctx, tree);
 
        smb2_deltree(tree, DNAME);
 
-       create_dir(tctx, tree);
-
        torture_comment(tctx, "FIND and delete directory\n");
        torture_comment(tctx, "We expect NT_STATUS_OK\n");
 
-       /* open the directory first */
-       ZERO_STRUCT(io);
-       io.in.desired_access     = perms;
-       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_DELETE;
-       io.in.create_options     = NTCREATEX_OPTIONS_DIRECTORY;
-       io.in.fname              = DNAME;
-
-       status = smb2_create(tree, tctx, &io);
+       /* create and open the directory first*/
+       status = torture_smb2_testdir(tree, DNAME, &dir_handle);
        CHECK_STATUS(status, NT_STATUS_OK);
 
        /* list directory */
        ZERO_STRUCT(find);
-       find.in.file.handle        = io.out.file.handle;
+       find.in.file.handle        = dir_handle;
        find.in.pattern            = "*";
        find.in.continue_flags     = SMB2_CONTINUE_FLAG_SINGLE;
        find.in.max_response_size  = 0x100;
@@ -570,12 +553,12 @@ static bool test_doc_find_and_set_doc(struct torture_context *tctx, struct smb2_
        ZERO_STRUCT(sfinfo);
        sfinfo.generic.level = RAW_SFILEINFO_DISPOSITION_INFORMATION;
        sfinfo.disposition_info.in.delete_on_close = 1;
-       sfinfo.generic.in.file.handle = io.out.file.handle;
+       sfinfo.generic.in.file.handle = dir_handle;
        status = smb2_setinfo_file(tree, &sfinfo);
        CHECK_STATUS(status, NT_STATUS_OK);
 
        /* close directory */
-       status = smb2_util_close(tree, io.out.file.handle);
+       status = smb2_util_close(tree, dir_handle);
        CHECK_STATUS(status, NT_STATUS_OK);
        return true;
 }