From: Anoop C S Date: Wed, 29 May 2024 13:11:32 +0000 (+0530) Subject: s4/torture: Create test_dir with SEC_RIGHTS_DIR_ALL X-Git-Tag: tdb-1.4.11~394 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3b230769b02e7c9ecbe7eac05e0344b233b3ae39;p=thirdparty%2Fsamba.git s4/torture: Create test_dir with SEC_RIGHTS_DIR_ALL 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 Reviewed-by: Ralph Boehme --- diff --git a/source4/torture/smb2/delete-on-close.c b/source4/torture/smb2/delete-on-close.c index 05242876dcb..50c6c83c532 100644 --- a/source4/torture/smb2/delete-on-close.c +++ b/source4/torture/smb2/delete-on-close.c @@ -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; }