summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAravind Srinivasan <aravind.srinivasan@isilon.com>2009-02-13 13:06:44 -0800
committerTim Prouty <tprouty@samba.org>2009-02-13 13:18:54 -0800
commit4d83d3a286947754f1306c6493318a4ccdc869a3 (patch)
treedc7986872fb0be3f0a3cf22842ed2dae01e63097
parent5e5d2b2cfadaf3bf352dcc25b302b12c70803d1f (diff)
downloadsamba-4d83d3a286947754f1306c6493318a4ccdc869a3.tar.gz
samba-4d83d3a286947754f1306c6493318a4ccdc869a3.tar.bz2
samba-4d83d3a286947754f1306c6493318a4ccdc869a3.zip
s4 torture: Add rename test to imitate the way OS X renames files
This tests for mis-behaved case-insensitive get_real_filename implementations.
-rw-r--r--source4/torture/raw/rename.c83
1 files changed, 83 insertions, 0 deletions
diff --git a/source4/torture/raw/rename.c b/source4/torture/raw/rename.c
index 9765c04101..9d629f0bbf 100644
--- a/source4/torture/raw/rename.c
+++ b/source4/torture/raw/rename.c
@@ -188,6 +188,88 @@ done:
}
+static bool test_osxrename(struct torture_context *tctx,
+ struct smbcli_state *cli)
+{
+ union smb_rename io;
+ union smb_unlink io_un;
+ NTSTATUS status;
+ bool ret = true;
+ int fnum = -1;
+ const char *fname1 = BASEDIR "\\test1";
+ const char *FNAME1 = BASEDIR "\\TEST1";
+ union smb_fileinfo finfo;
+ union smb_open op;
+
+ printf("\nTesting OSX Rename\n");
+ if (!torture_setup_dir(cli, BASEDIR)) {
+ return false;
+ }
+ op.generic.level = RAW_OPEN_NTCREATEX;
+ op.ntcreatex.in.root_fid = 0;
+ op.ntcreatex.in.flags = 0;
+ op.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
+ op.ntcreatex.in.create_options = 0;
+ op.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
+ op.ntcreatex.in.share_access =
+ NTCREATEX_SHARE_ACCESS_READ |
+ NTCREATEX_SHARE_ACCESS_WRITE;
+ op.ntcreatex.in.alloc_size = 0;
+ op.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF;
+ op.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
+ op.ntcreatex.in.security_flags = 0;
+ op.ntcreatex.in.fname = fname1;
+
+ status = smb_raw_open(cli->tree, tctx, &op);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ fnum = op.ntcreatex.out.file.fnum;
+
+ io.generic.level = RAW_RENAME_RENAME;
+ io.rename.in.attrib = 0;
+
+ smbcli_close(cli->tree, fnum);
+
+ /* Rename by changing case. First check for the
+ * existence of the file with the "newname".
+ * If we find one and both the output and input are same case,
+ * delete it. */
+
+ printf("Checking os X rename (case changing)\n");
+
+ finfo.generic.level = RAW_FILEINFO_ALL_INFO;
+ finfo.all_info.in.file.path = FNAME1;
+ printf("Looking for file %s \n",FNAME1);
+ status = smb_raw_pathinfo(cli->tree, tctx, &finfo);
+
+ if (NT_STATUS_EQUAL(status, NT_STATUS_OK)) {
+ printf("Name of the file found %s \n", finfo.all_info.out.fname.s);
+ if (strcmp(finfo.all_info.out.fname.s, finfo.all_info.in.file.path) == 0) {
+ /* If file is found with the same case delete it */
+ printf("Deleting File %s \n", finfo.all_info.out.fname.s);
+ io_un.unlink.in.pattern = finfo.all_info.out.fname.s;
+ io_un.unlink.in.attrib = 0;
+ status = smb_raw_unlink(cli->tree, &io_un);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ }
+ }
+
+ io.rename.in.pattern1 = fname1;
+ io.rename.in.pattern2 = FNAME1;
+ status = smb_raw_rename(cli->tree, &io);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ finfo.generic.level = RAW_FILEINFO_ALL_INFO;
+ finfo.all_info.in.file.path = fname1;
+ status = smb_raw_pathinfo(cli->tree, tctx, &finfo);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ printf("File name after rename %s \n",finfo.all_info.out.fname.s);
+
+done:
+ smbcli_close(cli->tree, fnum);
+ smb_raw_exit(cli->session);
+ smbcli_deltree(cli->tree, BASEDIR);
+ return ret;
+}
/*
test SMBntrename ops
@@ -450,6 +532,7 @@ struct torture_suite *torture_raw_rename(TALLOC_CTX *mem_ctx)
torture_suite_add_2smb_test(suite, "trans2rename", test_trans2rename);
torture_suite_add_1smb_test(suite, "nttransrename", test_nttransrename);
torture_suite_add_1smb_test(suite, "ntrename", test_ntrename);
+ torture_suite_add_1smb_test(suite, "osxrename", test_osxrename);
return suite;
}