summaryrefslogtreecommitdiff
path: root/source4/torture
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2009-10-07 16:52:29 -0700
committerJeremy Allison <jra@samba.org>2009-10-07 16:52:29 -0700
commit46d193324082000f19221f1b1ac679512aff96ed (patch)
tree4efdc8f50a9ce0670d2d3d52ee22bfdfaaff27af /source4/torture
parent14dc32a4f58c3336c8ecf2d918b443768d94451e (diff)
downloadsamba-46d193324082000f19221f1b1ac679512aff96ed.tar.gz
samba-46d193324082000f19221f1b1ac679512aff96ed.tar.bz2
samba-46d193324082000f19221f1b1ac679512aff96ed.zip
Exteded RAW-RENAME test to catch regressions in bug 6781.
Jeremy.
Diffstat (limited to 'source4/torture')
-rw-r--r--source4/torture/raw/rename.c44
1 files changed, 40 insertions, 4 deletions
diff --git a/source4/torture/raw/rename.c b/source4/torture/raw/rename.c
index 15fed0e3d8..5402feda55 100644
--- a/source4/torture/raw/rename.c
+++ b/source4/torture/raw/rename.c
@@ -528,8 +528,9 @@ static bool test_dir_rename(struct torture_context *tctx, struct smbcli_state *c
NTSTATUS status;
const char *dname1 = BASEDIR "\\dir_for_rename";
const char *dname2 = BASEDIR "\\renamed_dir";
+ const char *dname1_long = BASEDIR "\\dir_for_rename_long";
const char *fname = BASEDIR "\\dir_for_rename\\file.txt";
- const char *sname = BASEDIR "\\dir_for_rename:a stream:$DATA";
+ const char *sname = BASEDIR "\\renamed_dir:a stream:$DATA";
bool ret = true;
int fnum = -1;
@@ -542,8 +543,10 @@ static bool test_dir_rename(struct torture_context *tctx, struct smbcli_state *c
/* create a directory */
smbcli_rmdir(cli->tree, dname1);
smbcli_rmdir(cli->tree, dname2);
+ smbcli_rmdir(cli->tree, dname1_long);
smbcli_unlink(cli->tree, dname1);
smbcli_unlink(cli->tree, dname2);
+ smbcli_unlink(cli->tree, dname1_long);
ZERO_STRUCT(io);
io.generic.level = RAW_OPEN_NTCREATEX;
@@ -561,6 +564,14 @@ static bool test_dir_rename(struct torture_context *tctx, struct smbcli_state *c
fnum = io.ntcreatex.out.file.fnum;
smbcli_close(cli->tree, fnum);
+ /* create the longname directory */
+ io.ntcreatex.in.fname = dname1_long;
+ status = smb_raw_open(cli->tree, tctx, &io);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ fnum = io.ntcreatex.out.file.fnum;
+ smbcli_close(cli->tree, fnum);
+
/* Now create and hold open a file. */
ZERO_STRUCT(io);
@@ -625,6 +636,31 @@ static bool test_dir_rename(struct torture_context *tctx, struct smbcli_state *c
/* close our handle to the directory. */
smbcli_close(cli->tree, fnum);
+ /* Open a handle on the long name, and then
+ * try a rename. This would catch a regression
+ * in bug #6781.
+ */
+ io.ntcreatex.in.fname = dname1_long;
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF;
+
+ io.ntcreatex.in.access_mask = SEC_STD_READ_CONTROL |
+ SEC_FILE_READ_ATTRIBUTE | SEC_FILE_READ_EA | SEC_FILE_READ_DATA;
+
+ status = smb_raw_open(cli->tree, tctx, &io);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ fnum = io.ntcreatex.out.file.fnum;
+
+ ren_io.generic.level = RAW_RENAME_RENAME;
+ ren_io.rename.in.pattern1 = dname1;
+ ren_io.rename.in.pattern2 = dname2;
+ ren_io.rename.in.attrib = 0;
+
+ status = smb_raw_rename(cli->tree, &ren_io);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ /* close our handle to the longname directory. */
+ smbcli_close(cli->tree, fnum);
+
/*
* Now try opening a stream on the directory and holding it open
* across a rename. This should be allowed.
@@ -636,15 +672,15 @@ static bool test_dir_rename(struct torture_context *tctx, struct smbcli_state *c
fnum = io.ntcreatex.out.file.fnum;
ren_io.generic.level = RAW_RENAME_RENAME;
- ren_io.rename.in.pattern1 = dname1;
- ren_io.rename.in.pattern2 = dname2;
+ ren_io.rename.in.pattern1 = dname2;
+ ren_io.rename.in.pattern2 = dname1;
ren_io.rename.in.attrib = 0;
status = smb_raw_rename(cli->tree, &ren_io);
CHECK_STATUS(status, NT_STATUS_OK);
done:
-
+
if (fnum != -1) {
smbcli_close(cli->tree, fnum);
}