return ret;
}
-/* Renaming a directory with open file, should work for OS X AAPL clients */
-static bool test_rename_dir_openfile(struct torture_context *torture,
- struct smb2_tree *tree)
-{
- bool ret = true;
- NTSTATUS status;
- union smb_open io;
- union smb_close cl;
- union smb_setfileinfo sinfo;
- struct smb2_handle d1, h1;
- const char *renamedir = BASEDIR "-new";
- bool server_is_osx = torture_setting_bool(torture, "osx", false);
-
- smb2_deltree(tree, BASEDIR);
- smb2_util_rmdir(tree, BASEDIR);
- smb2_deltree(tree, renamedir);
-
- ZERO_STRUCT(io.smb2);
- io.generic.level = RAW_OPEN_SMB2;
- io.smb2.in.create_flags = 0;
- io.smb2.in.desired_access = 0x0017019f;
- io.smb2.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
- io.smb2.in.file_attributes = FILE_ATTRIBUTE_DIRECTORY;
- io.smb2.in.share_access = 0;
- io.smb2.in.alloc_size = 0;
- io.smb2.in.create_disposition = NTCREATEX_DISP_CREATE;
- io.smb2.in.impersonation_level = SMB2_IMPERSONATION_ANONYMOUS;
- io.smb2.in.security_flags = 0;
- io.smb2.in.fname = BASEDIR;
-
- status = smb2_create(tree, torture, &(io.smb2));
- torture_assert_ntstatus_ok(torture, status, "smb2_create dir");
- d1 = io.smb2.out.file.handle;
-
- ZERO_STRUCT(io.smb2);
- io.generic.level = RAW_OPEN_SMB2;
- io.smb2.in.create_flags = 0;
- io.smb2.in.desired_access = 0x0017019f;
- io.smb2.in.create_options = NTCREATEX_OPTIONS_NON_DIRECTORY_FILE;
- io.smb2.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
- io.smb2.in.share_access = 0;
- io.smb2.in.alloc_size = 0;
- io.smb2.in.create_disposition = NTCREATEX_DISP_CREATE;
- io.smb2.in.impersonation_level = SMB2_IMPERSONATION_ANONYMOUS;
- io.smb2.in.security_flags = 0;
- io.smb2.in.fname = BASEDIR "\\file.txt";
-
- status = smb2_create(tree, torture, &(io.smb2));
- torture_assert_ntstatus_ok(torture, status, "smb2_create file");
- h1 = io.smb2.out.file.handle;
-
- if (!server_is_osx) {
- torture_comment(torture, "Renaming directory without AAPL, must fail\n");
-
- ZERO_STRUCT(sinfo);
- sinfo.rename_information.level = RAW_SFILEINFO_RENAME_INFORMATION;
- sinfo.rename_information.in.file.handle = d1;
- sinfo.rename_information.in.overwrite = 0;
- sinfo.rename_information.in.root_fid = 0;
- sinfo.rename_information.in.new_name = renamedir;
- status = smb2_setinfo_file(tree, &sinfo);
-
- torture_assert_ntstatus_equal(torture, status,
- NT_STATUS_ACCESS_DENIED,
- "smb2_setinfo_file");
- }
-
- status = smb2_util_close(tree, d1);
- torture_assert_ntstatus_ok(torture, status, "smb2_util_close\n");
- ZERO_STRUCT(d1);
-
- torture_comment(torture, "Enabling AAPL\n");
-
- ret = enable_aapl(torture, tree);
- torture_assert(torture, ret == true, "enable_aapl failed");
-
- torture_comment(torture, "Renaming directory with AAPL\n");
-
- ZERO_STRUCT(io.smb2);
- io.generic.level = RAW_OPEN_SMB2;
- io.smb2.in.desired_access = 0x0017019f;
- io.smb2.in.file_attributes = FILE_ATTRIBUTE_DIRECTORY;
- io.smb2.in.share_access = 0;
- io.smb2.in.alloc_size = 0;
- io.smb2.in.create_disposition = NTCREATEX_DISP_OPEN;
- io.smb2.in.impersonation_level = SMB2_IMPERSONATION_ANONYMOUS;
- io.smb2.in.security_flags = 0;
- io.smb2.in.fname = BASEDIR;
-
- status = smb2_create(tree, torture, &(io.smb2));
- torture_assert_ntstatus_ok(torture, status, "smb2_create dir");
- d1 = io.smb2.out.file.handle;
-
- ZERO_STRUCT(sinfo);
- sinfo.rename_information.level = RAW_SFILEINFO_RENAME_INFORMATION;
- sinfo.rename_information.in.file.handle = d1;
- sinfo.rename_information.in.overwrite = 0;
- sinfo.rename_information.in.root_fid = 0;
- sinfo.rename_information.in.new_name = renamedir;
-
- status = smb2_setinfo_file(tree, &sinfo);
- torture_assert_ntstatus_ok(torture, status, "smb2_setinfo_file");
-
- ZERO_STRUCT(cl.smb2);
- cl.smb2.level = RAW_CLOSE_SMB2;
- cl.smb2.in.file.handle = d1;
- status = smb2_close(tree, &(cl.smb2));
- torture_assert_ntstatus_ok(torture, status, "smb2_close");
- ZERO_STRUCT(d1);
-
- cl.smb2.in.file.handle = h1;
- status = smb2_close(tree, &(cl.smb2));
- torture_assert_ntstatus_ok(torture, status, "smb2_close");
- ZERO_STRUCT(h1);
-
- torture_comment(torture, "Cleaning up\n");
-
- if (h1.data[0] || h1.data[1]) {
- ZERO_STRUCT(cl.smb2);
- cl.smb2.level = RAW_CLOSE_SMB2;
- cl.smb2.in.file.handle = h1;
- status = smb2_close(tree, &(cl.smb2));
- }
-
- smb2_util_unlink(tree, BASEDIR "\\file.txt");
- smb2_util_unlink(tree, BASEDIR "-new\\file.txt");
- smb2_deltree(tree, renamedir);
- smb2_deltree(tree, BASEDIR);
- return ret;
-}
-
static bool test_afpinfo_enoent(struct torture_context *tctx,
struct smb2_tree *tree)
{
torture_suite_add_1smb2_test(suite, "truncate resource fork to 0 bytes", test_rfork_truncate);
torture_suite_add_1smb2_test(suite, "opening and creating resource fork", test_rfork_create);
torture_suite_add_1smb2_test(suite, "fsync_resource_fork", test_rfork_fsync);
- torture_suite_add_1smb2_test(suite, "rename_dir_openfile", test_rename_dir_openfile);
torture_suite_add_1smb2_test(suite, "File without AFP_AfpInfo", test_afpinfo_enoent);
torture_suite_add_1smb2_test(suite, "create delete-on-close AFP_AfpInfo", test_create_delete_on_close);
torture_suite_add_1smb2_test(suite, "setinfo delete-on-close AFP_AfpInfo", test_setinfo_delete_on_close);