mirror of
https://github.com/samba-team/samba.git
synced 2025-01-07 17:18:11 +03:00
s4/torture/fruit: enhance zero AFP_AfpInfo stream test
This test more operations in the zeroed out FinderInfo test, ensuring
after zeroing out FinderInfo, operations on the filehandle still work
and that enumerating streams doesn't return the stream anymore.
Bug: https://bugzilla.samba.org/show_bug.cgi?id=13181
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(backported from commit df31e94eb6
)
This commit is contained in:
parent
26da45be00
commit
d95b278b00
2
selftest/knownfail.d/samba3.vfs.fruit
Normal file
2
selftest/knownfail.d/samba3.vfs.fruit
Normal file
@ -0,0 +1,2 @@
|
||||
^samba3.vfs.fruit metadata_stream.delete AFP_AfpInfo by writing all 0\(nt4_dc\)
|
||||
^samba3.vfs.fruit streams_depot.delete AFP_AfpInfo by writing all 0\(nt4_dc\)
|
@ -3340,11 +3340,17 @@ static bool test_afpinfo_all0(struct torture_context *tctx,
|
||||
{
|
||||
bool ret = true;
|
||||
NTSTATUS status;
|
||||
struct smb2_handle h1;
|
||||
struct smb2_create create;
|
||||
struct smb2_handle h1 = {{0}};
|
||||
struct smb2_handle baseh = {{0}};
|
||||
union smb_setfileinfo setfinfo;
|
||||
union smb_fileinfo getfinfo;
|
||||
TALLOC_CTX *mem_ctx = talloc_new(tctx);
|
||||
const char *fname = BASEDIR "\\file";
|
||||
const char *sname = BASEDIR "\\file" AFPINFO_STREAM;
|
||||
const char *type_creator = "SMB,OLE!";
|
||||
AfpInfo *info = NULL;
|
||||
char *infobuf = NULL;
|
||||
const char *streams_basic[] = {
|
||||
"::$DATA"
|
||||
};
|
||||
@ -3375,13 +3381,88 @@ static bool test_afpinfo_all0(struct torture_context *tctx,
|
||||
|
||||
/* Write all 0 to AFP_AfpInfo */
|
||||
memset(info->afpi_FinderInfo, 0, AFP_FinderSize);
|
||||
ret = torture_write_afpinfo(tree, tctx, mem_ctx, fname, info);
|
||||
torture_assert_goto(tctx, ret == true, ret, done, "torture_write_afpinfo failed");
|
||||
infobuf = torture_afpinfo_pack(mem_ctx, info);
|
||||
torture_assert_not_null_goto(tctx, infobuf, ret, done,
|
||||
"torture_afpinfo_pack failed\n");
|
||||
|
||||
ZERO_STRUCT(create);
|
||||
create.in.desired_access = SEC_FILE_ALL;
|
||||
create.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
|
||||
create.in.create_disposition = NTCREATEX_DISP_OPEN;
|
||||
create.in.share_access = NTCREATEX_SHARE_ACCESS_MASK;
|
||||
create.in.fname = fname;
|
||||
|
||||
status = smb2_create(tree, mem_ctx, &create);
|
||||
torture_assert_goto(tctx, ret == true, ret, done,
|
||||
"smb2_create failed\n");
|
||||
baseh = create.out.file.handle;
|
||||
|
||||
ZERO_STRUCT(create);
|
||||
create.in.desired_access = SEC_FILE_ALL;
|
||||
create.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
|
||||
create.in.create_disposition = NTCREATEX_DISP_OVERWRITE_IF;
|
||||
create.in.fname = sname;
|
||||
|
||||
status = smb2_create(tree, mem_ctx, &create);
|
||||
torture_assert_goto(tctx, ret == true, ret, done,
|
||||
"smb2_create failed\n");
|
||||
h1 = create.out.file.handle;
|
||||
|
||||
status = smb2_util_write(tree, h1, infobuf, 0, AFP_INFO_SIZE);
|
||||
torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
|
||||
"smb2_util_write failed\n");
|
||||
|
||||
/*
|
||||
* Get stream information on open handle, must return only default
|
||||
* stream, the AFP_AfpInfo stream must not be returned.
|
||||
*/
|
||||
|
||||
ZERO_STRUCT(getfinfo);
|
||||
getfinfo.generic.level = RAW_FILEINFO_STREAM_INFORMATION;
|
||||
getfinfo.generic.in.file.handle = baseh;
|
||||
|
||||
status = smb2_getinfo_file(tree, tctx, &getfinfo);
|
||||
torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
|
||||
"get stream info\n");
|
||||
|
||||
torture_assert_int_equal_goto(tctx, getfinfo.stream_info.out.num_streams,
|
||||
1, ret, done, "stream count");
|
||||
|
||||
smb2_util_close(tree, baseh);
|
||||
ZERO_STRUCT(baseh);
|
||||
|
||||
/*
|
||||
* Try to set some file-basic-info (time) on the stream. This catches
|
||||
* naive implementation mistakes that simply deleted the backing store
|
||||
* from the filesystem in the zero-out step.
|
||||
*/
|
||||
|
||||
ZERO_STRUCT(setfinfo);
|
||||
unix_to_nt_time(&setfinfo.basic_info.in.write_time, time(NULL));
|
||||
setfinfo.basic_info.in.attrib = 0x20;
|
||||
setfinfo.generic.level = RAW_SFILEINFO_BASIC_INFORMATION;
|
||||
setfinfo.generic.in.file.handle = h1;
|
||||
|
||||
status = smb2_setinfo_file(tree, &setfinfo);
|
||||
torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
|
||||
"smb2_getinfo_file failed\n");
|
||||
|
||||
ret = check_stream_list(tree, tctx, fname, 1, streams_basic, false);
|
||||
torture_assert_goto(tctx, ret == true, ret, done, "check_stream_list");
|
||||
|
||||
smb2_util_close(tree, h1);
|
||||
ZERO_STRUCT(h1);
|
||||
|
||||
ret = check_stream_list(tree, tctx, fname, 1, streams_basic, false);
|
||||
torture_assert_goto(tctx, ret == true, ret, done, "Bad streams");
|
||||
|
||||
done:
|
||||
if (!smb2_util_handle_empty(h1)) {
|
||||
smb2_util_close(tree, h1);
|
||||
}
|
||||
if (!smb2_util_handle_empty(baseh)) {
|
||||
smb2_util_close(tree, baseh);
|
||||
}
|
||||
smb2_util_unlink(tree, fname);
|
||||
smb2_util_rmdir(tree, BASEDIR);
|
||||
return ret;
|
||||
|
Loading…
Reference in New Issue
Block a user