summaryrefslogtreecommitdiff
path: root/source4/torture/raw/rename.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/torture/raw/rename.c')
-rw-r--r--source4/torture/raw/rename.c50
1 files changed, 43 insertions, 7 deletions
diff --git a/source4/torture/raw/rename.c b/source4/torture/raw/rename.c
index 15fed0e3d8..cf04769764 100644
--- a/source4/torture/raw/rename.c
+++ b/source4/torture/raw/rename.c
@@ -67,7 +67,7 @@ static bool test_mv(struct torture_context *tctx,
torture_comment(tctx, "Trying simple rename\n");
op.generic.level = RAW_OPEN_NTCREATEX;
- op.ntcreatex.in.root_fid = 0;
+ op.ntcreatex.in.root_fid.fnum = 0;
op.ntcreatex.in.flags = 0;
op.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
op.ntcreatex.in.create_options = 0;
@@ -208,7 +208,7 @@ static bool test_osxrename(struct torture_context *tctx,
return false;
}
op.generic.level = RAW_OPEN_NTCREATEX;
- op.ntcreatex.in.root_fid = 0;
+ op.ntcreatex.in.root_fid.fnum = 0;
op.ntcreatex.in.flags = 0;
op.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
op.ntcreatex.in.create_options = 0;
@@ -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,12 +564,20 @@ 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);
io.generic.level = RAW_OPEN_NTCREATEX;
io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED;
- io.ntcreatex.in.root_fid = 0;
+ io.ntcreatex.in.root_fid.fnum = 0;
io.ntcreatex.in.alloc_size = 0;
io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
@@ -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);
}