return status;
}
- torture_smb2_all_info(tree, handle);
+ torture_smb2_all_info(tctx, tree, handle);
status = smb2_write(tree, &w);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
- torture_smb2_all_info(tree, handle);
+ torture_smb2_all_info(tctx, tree, handle);
ZERO_STRUCT(f);
f.in.file.handle = handle;
smb2_util_close(tree, h1);
smb2_util_unlink(tree, fname);
- status = smb2_create_complex_file(tree, fname, &h1);
+ status = smb2_create_complex_file(tctx, tree, fname, &h1);
CHECK_STATUS(status, NT_STATUS_OK);
smb2_util_close(tree, h1);
status = torture_smb2_testdir(tree, DNAME, &h);
torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "");
- status = smb2_create_complex_file(tree, DNAME "\\torture_search.txt",
+ status = smb2_create_complex_file(tctx, tree, DNAME "\\torture_search.txt",
&h2);
torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "");
smb2_util_close(tree, create.out.file.handle);
files[num_files + 2].name = talloc_asprintf(mem_ctx, "T013-13.txt.3");
- status = smb2_create_complex_file(tree, DNAME "\\T013-13.txt.3", &h);
+ status = smb2_create_complex_file(tctx, tree, DNAME "\\T013-13.txt.3", &h);
torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "");
smb2_util_unlink(tree, DNAME "\\T014-14.txt");
DNAME "\n");
torture_comment(tctx, "Testing file info levels\n");
- torture_smb2_all_info(tree, hfile);
- torture_smb2_all_info(tree, hdir);
+ torture_smb2_all_info(tctx, tree, hfile);
+ torture_smb2_all_info(tctx, tree, hdir);
for (i=0;i<ARRAY_SIZE(file_levels);i++) {
if (file_levels[i].level == RAW_FILEINFO_SEC_DESC) {
/* basic testing of all SMB2 getinfo levels
*/
-static bool torture_smb2_getinfo(struct torture_context *torture)
+static bool torture_smb2_getinfo(struct torture_context *tctx)
{
struct smb2_tree *tree;
bool ret = true;
NTSTATUS status;
- ret = torture_smb2_connection(torture, &tree);
- torture_assert(torture, ret, "connection failed");
+ ret = torture_smb2_connection(tctx, &tree);
+ torture_assert(tctx, ret, "connection failed");
smb2_deltree(tree, FNAME);
smb2_deltree(tree, DNAME);
- status = torture_setup_complex_file(tree, FNAME);
- torture_assert_ntstatus_ok(torture, status,
+ status = torture_setup_complex_file(tctx, tree, FNAME);
+ torture_assert_ntstatus_ok(tctx, status,
"setup complex file " FNAME);
- status = torture_setup_complex_file(tree, FNAME ":streamtwo");
- torture_assert_ntstatus_ok(torture, status,
+ status = torture_setup_complex_file(tctx, tree, FNAME ":streamtwo");
+ torture_assert_ntstatus_ok(tctx, status,
"setup complex file " FNAME ":streamtwo");
- status = torture_setup_complex_dir(tree, DNAME);
- torture_assert_ntstatus_ok(torture, status,
+ status = torture_setup_complex_dir(tctx, tree, DNAME);
+ torture_assert_ntstatus_ok(tctx, status,
"setup complex dir " DNAME);
- status = torture_setup_complex_file(tree, DNAME ":streamtwo");
- torture_assert_ntstatus_ok(torture, status,
+ status = torture_setup_complex_file(tctx, tree, DNAME ":streamtwo");
+ torture_assert_ntstatus_ok(tctx, status,
"setup complex dir " DNAME ":streamtwo");
- ret &= torture_smb2_fileinfo(torture, tree);
+ ret &= torture_smb2_fileinfo(tctx, tree);
return ret;
}
}
}
- status = torture_setup_complex_file(tree, FNAME);
+ status = torture_setup_complex_file(torture, tree, FNAME);
CHECK_STATUS(status, NT_STATUS_OK);
status = smb2_notify_recv(req, torture, &n);
}
}
- status = torture_setup_complex_file(tree, FNAME);
+ status = torture_setup_complex_file(torture, tree, FNAME);
CHECK_STATUS(status, NT_STATUS_OK);
status = smb2_notify_recv(req, torture, &n);
}
}
- status = torture_setup_complex_file(tree, FNAME);
+ status = torture_setup_complex_file(torture, tree, FNAME);
CHECK_STATUS(status, NT_STATUS_OK);
status = smb2_notify_recv(req, torture, &n);
}
}
- status = torture_setup_complex_file(tree, FNAME);
+ status = torture_setup_complex_file(torture, tree, FNAME);
CHECK_STATUS(status, NT_STATUS_OK);
status = smb2_notify_recv(req, torture, &n);
}
}
- status = torture_setup_complex_file(tree, FNAME);
+ status = torture_setup_complex_file(torture, tree, FNAME);
CHECK_STATUS(status, NT_STATUS_OK);
status = smb2_notify_recv(req, torture, &n);
sinfo.basic_info.in.create_time = 0;
torture_comment(torture, "Testing set file create time\n");
NOTIFY_MASK_TEST("Testing set file create time",
- smb2_create_complex_file(tree2,
+ smb2_create_complex_file(torture, tree2,
BASEDIR "\\tname1", &h2);,
smb2_setinfo_file(tree2, &sinfo);,
(smb2_util_close(tree2, h2),
sinfo.basic_info.in.access_time = 0;
torture_comment(torture, "Testing set file access time\n");
NOTIFY_MASK_TEST("Testing set file access time",
- smb2_create_complex_file(tree2, BASEDIR "\\tname1", &h2);,
+ smb2_create_complex_file(torture, tree2, BASEDIR "\\tname1", &h2);,
smb2_setinfo_file(tree2, &sinfo);,
(smb2_util_close(tree2, h2),
smb2_util_unlink(tree2, BASEDIR "\\tname1"));,
sinfo.basic_info.in.change_time = 0;
torture_comment(torture, "Testing set file change time\n");
NOTIFY_MASK_TEST("Testing set file change time",
- smb2_create_complex_file(tree2, BASEDIR "\\tname1", &h2);,
+ smb2_create_complex_file(torture, tree2, BASEDIR "\\tname1", &h2);,
smb2_setinfo_file(tree2, &sinfo);,
(smb2_util_close(tree2, h2),
smb2_util_unlink(tree2, BASEDIR "\\tname1"));,
torture_comment(torture, "Testing write\n");
NOTIFY_MASK_TEST("Testing write",
- smb2_create_complex_file(tree2, BASEDIR "\\tname1", &h2);,
+ smb2_create_complex_file(torture, tree2, BASEDIR "\\tname1", &h2);,
smb2_util_write(tree2, h2, &c, 10000, 1);,
(smb2_util_close(tree2, h2),
smb2_util_unlink(tree2, BASEDIR "\\tname1"));,
return false;
}
- status = torture_setup_complex_file(tree, FNAME);
+ status = torture_setup_complex_file(tctx, tree, FNAME);
if (!NT_STATUS_IS_OK(status)) {
torture_comment(tctx, "Failed to setup complex file '%s': %s\n",
FNAME, nt_errstr(status));
return false;
}
- torture_setup_complex_file(tree, FNAME2);
+ torture_setup_complex_file(tctx, tree, FNAME2);
- status = torture_setup_complex_dir(tree, DNAME);
+ status = torture_setup_complex_dir(tctx, tree, DNAME);
if (!NT_STATUS_IS_OK(status)) {
torture_comment(tctx, "Failed to setup complex dir '%s': %s\n",
DNAME, nt_errstr(status));
smb2_util_unlink(tree, FNAME);
return false;
}
- torture_setup_complex_file(tree, DNAME2);
+ torture_setup_complex_file(tctx, tree, DNAME2);
torture_smb2_testfile(tree, FNAME, &fhandle);
torture_smb2_testdir(tree, DNAME, &dhandle);
return false;
}
- status = torture_setup_complex_file(tree, FNAME);
+ status = torture_setup_complex_file(tctx, tree, FNAME);
if (!NT_STATUS_IS_OK(status)) {
torture_comment(tctx, "Failed to setup complex file '%s': %s\n",
FNAME, nt_errstr(status));
return false;
}
- torture_setup_complex_file(tree, FNAME2);
+ torture_setup_complex_file(tctx, tree, FNAME2);
torture_smb2_testfile(tree, FNAME, &handle);
#define RECREATE_FILE(fname) do { \
smb2_util_close(tree, handle); \
- status = smb2_create_complex_file(tree, fname, &handle); \
+ status = smb2_create_complex_file(tctx, tree, fname, &handle); \
if (!NT_STATUS_IS_OK(status)) { \
torture_result(tctx, TORTURE_FAIL, "(%s) ERROR: open of %s failed (%s)\n", \
__location__, fname, nt_errstr(status)); \
torture_result(tctx, TORTURE_FAIL, "(%s) %s - %s/%s should be 0x%x - 0x%x\n", __location__, \
call_name, #stype, #field, \
(unsigned int)value, (unsigned int)finfo2.stype.out.field); \
- torture_smb2_all_info(tree, handle); \
+ torture_smb2_all_info(tctx, tree, handle); \
ret = false; \
goto done; \
}} while (0)
(unsigned int)nt_time_to_unix(finfo2.stype.out.field)); \
torture_warning(tctx, "\t%s", timestring(tctx, value)); \
torture_warning(tctx, "\t%s\n", nt_time_string(tctx, finfo2.stype.out.field)); \
- torture_smb2_all_info(tree, handle); \
+ torture_smb2_all_info(tctx, tree, handle); \
ret = false; \
goto done; \
}} while (0)
goto done; \
}} while (0)
- torture_smb2_all_info(tree, handle);
+ torture_smb2_all_info(tctx, tree, handle);
torture_comment(tctx, "Test basic_information level\n");
basetime += 86400;
/*
create a complex file/dir using the SMB2 protocol
*/
-static NTSTATUS smb2_create_complex(struct smb2_tree *tree, const char *fname,
- struct smb2_handle *handle, bool dir)
+static NTSTATUS smb2_create_complex(struct torture_context *tctx,
+ struct smb2_tree *tree,
+ const char *fname,
+ struct smb2_handle *handle,
+ bool dir)
{
TALLOC_CTX *tmp_ctx = talloc_new(tree);
char buf[7] = "abc";
status = smb2_setinfo_file(tree, &setfile);
if (!NT_STATUS_IS_OK(status)) {
- printf("Failed to setup file times - %s\n", nt_errstr(status));
+ torture_comment(tctx, "Failed to setup file times - %s\n", nt_errstr(status));
return status;
}
status = smb2_getinfo_file(tree, tree, &fileinfo);
if (!NT_STATUS_IS_OK(status)) {
- printf("Failed to query file times - %s\n", nt_errstr(status));
+ torture_comment(tctx, "Failed to query file times - %s\n", nt_errstr(status));
return status;
}
#define CHECK_TIME(field) do {\
if (setfile.basic_info.in.field != fileinfo.all_info2.out.field) { \
- printf("(%s) " #field " not setup correctly: %s(%llu) => %s(%llu)\n", \
+ torture_comment(tctx, "(%s) " #field " not setup correctly: %s(%llu) => %s(%llu)\n", \
__location__, \
nt_time_string(tree, setfile.basic_info.in.field), \
(unsigned long long)setfile.basic_info.in.field, \
/*
create a complex file using the SMB2 protocol
*/
-NTSTATUS smb2_create_complex_file(struct smb2_tree *tree, const char *fname,
- struct smb2_handle *handle)
+NTSTATUS smb2_create_complex_file(struct torture_context *tctx,
+ struct smb2_tree *tree, const char *fname,
+ struct smb2_handle *handle)
{
- return smb2_create_complex(tree, fname, handle, false);
+ return smb2_create_complex(tctx, tree, fname, handle, false);
}
/*
create a complex dir using the SMB2 protocol
*/
-NTSTATUS smb2_create_complex_dir(struct smb2_tree *tree, const char *fname,
+NTSTATUS smb2_create_complex_dir(struct torture_context *tctx,
+ struct smb2_tree *tree, const char *fname,
struct smb2_handle *handle)
{
- return smb2_create_complex(tree, fname, handle, true);
+ return smb2_create_complex(tctx, tree, fname, handle, true);
}
/*
show lots of information about a file
*/
-void torture_smb2_all_info(struct smb2_tree *tree, struct smb2_handle handle)
+void torture_smb2_all_info(struct torture_context *tctx,
+ struct smb2_tree *tree, struct smb2_handle handle)
{
NTSTATUS status;
TALLOC_CTX *tmp_ctx = talloc_new(tree);
return;
}
- d_printf("all_info for '%s'\n", io.all_info2.out.fname.s);
- d_printf("\tcreate_time: %s\n", nt_time_string(tmp_ctx, io.all_info2.out.create_time));
- d_printf("\taccess_time: %s\n", nt_time_string(tmp_ctx, io.all_info2.out.access_time));
- d_printf("\twrite_time: %s\n", nt_time_string(tmp_ctx, io.all_info2.out.write_time));
- d_printf("\tchange_time: %s\n", nt_time_string(tmp_ctx, io.all_info2.out.change_time));
- d_printf("\tattrib: 0x%x\n", io.all_info2.out.attrib);
- d_printf("\tunknown1: 0x%x\n", io.all_info2.out.unknown1);
- d_printf("\talloc_size: %llu\n", (long long)io.all_info2.out.alloc_size);
- d_printf("\tsize: %llu\n", (long long)io.all_info2.out.size);
- d_printf("\tnlink: %u\n", io.all_info2.out.nlink);
- d_printf("\tdelete_pending: %u\n", io.all_info2.out.delete_pending);
- d_printf("\tdirectory: %u\n", io.all_info2.out.directory);
- d_printf("\tfile_id: %llu\n", (long long)io.all_info2.out.file_id);
- d_printf("\tea_size: %u\n", io.all_info2.out.ea_size);
- d_printf("\taccess_mask: 0x%08x\n", io.all_info2.out.access_mask);
- d_printf("\tposition: 0x%llx\n", (long long)io.all_info2.out.position);
- d_printf("\tmode: 0x%llx\n", (long long)io.all_info2.out.mode);
+ torture_comment(tctx, "all_info for '%s'\n", io.all_info2.out.fname.s);
+ torture_comment(tctx, "\tcreate_time: %s\n", nt_time_string(tmp_ctx, io.all_info2.out.create_time));
+ torture_comment(tctx, "\taccess_time: %s\n", nt_time_string(tmp_ctx, io.all_info2.out.access_time));
+ torture_comment(tctx, "\twrite_time: %s\n", nt_time_string(tmp_ctx, io.all_info2.out.write_time));
+ torture_comment(tctx, "\tchange_time: %s\n", nt_time_string(tmp_ctx, io.all_info2.out.change_time));
+ torture_comment(tctx, "\tattrib: 0x%x\n", io.all_info2.out.attrib);
+ torture_comment(tctx, "\tunknown1: 0x%x\n", io.all_info2.out.unknown1);
+ torture_comment(tctx, "\talloc_size: %llu\n", (long long)io.all_info2.out.alloc_size);
+ torture_comment(tctx, "\tsize: %llu\n", (long long)io.all_info2.out.size);
+ torture_comment(tctx, "\tnlink: %u\n", io.all_info2.out.nlink);
+ torture_comment(tctx, "\tdelete_pending: %u\n", io.all_info2.out.delete_pending);
+ torture_comment(tctx, "\tdirectory: %u\n", io.all_info2.out.directory);
+ torture_comment(tctx, "\tfile_id: %llu\n", (long long)io.all_info2.out.file_id);
+ torture_comment(tctx, "\tea_size: %u\n", io.all_info2.out.ea_size);
+ torture_comment(tctx, "\taccess_mask: 0x%08x\n", io.all_info2.out.access_mask);
+ torture_comment(tctx, "\tposition: 0x%llx\n", (long long)io.all_info2.out.position);
+ torture_comment(tctx, "\tmode: 0x%llx\n", (long long)io.all_info2.out.mode);
/* short name, if any */
io.generic.level = RAW_FILEINFO_ALT_NAME_INFORMATION;
status = smb2_getinfo_file(tree, tmp_ctx, &io);
if (NT_STATUS_IS_OK(status)) {
- d_printf("\tshort name: '%s'\n", io.alt_name_info.out.fname.s);
+ torture_comment(tctx, "\tshort name: '%s'\n", io.alt_name_info.out.fname.s);
}
/* the EAs, if any */
if (NT_STATUS_IS_OK(status)) {
int i;
for (i=0;i<io.all_eas.out.num_eas;i++) {
- d_printf("\tEA[%d] flags=%d len=%d '%s'\n", i,
+ torture_comment(tctx, "\tEA[%d] flags=%d len=%d '%s'\n", i,
io.all_eas.out.eas[i].flags,
(int)io.all_eas.out.eas[i].value.length,
io.all_eas.out.eas[i].name.s);
if (NT_STATUS_IS_OK(status)) {
int i;
for (i=0;i<io.stream_info.out.num_streams;i++) {
- d_printf("\tstream %d:\n", i);
- d_printf("\t\tsize %ld\n",
+ torture_comment(tctx, "\tstream %d:\n", i);
+ torture_comment(tctx, "\t\tsize %ld\n",
(long)io.stream_info.out.streams[i].size);
- d_printf("\t\talloc size %ld\n",
+ torture_comment(tctx, "\t\talloc size %ld\n",
(long)io.stream_info.out.streams[i].alloc_size);
- d_printf("\t\tname %s\n", io.stream_info.out.streams[i].stream_name.s);
+ torture_comment(tctx, "\t\tname %s\n", io.stream_info.out.streams[i].stream_name.s);
}
}
status = smb2_session_setup_spnego(session, credentials,
previous_session_id);
if (!NT_STATUS_IS_OK(status)) {
- printf("session setup failed: %s\n", nt_errstr(status));
+ torture_comment(tctx, "session setup failed: %s\n", nt_errstr(status));
talloc_free(session);
return false;
}
lpcfg_gensec_settings(tctx, tctx->lp_ctx)
);
if (!NT_STATUS_IS_OK(status)) {
- printf("Failed to connect to SMB2 share \\\\%s\\%s - %s\n",
+ torture_comment(tctx, "Failed to connect to SMB2 share \\\\%s\\%s - %s\n",
host, share, nt_errstr(status));
return false;
}
lpcfg_smbcli_options(tctx->lp_ctx, &options);
if (share == NULL) {
- printf("No share for option %s\n", soption);
+ torture_comment(tctx, "No share for option %s\n", soption);
return false;
}
lpcfg_gensec_settings(tctx, tctx->lp_ctx)
);
if (!NT_STATUS_IS_OK(status)) {
- printf("Failed to connect to SMB2 share \\\\%s\\%s - %s\n",
+ torture_comment(tctx, "Failed to connect to SMB2 share \\\\%s\\%s - %s\n",
host, share, nt_errstr(status));
return false;
}
create a complex file using SMB2, to make it easier to
find fields in SMB2 getinfo levels
*/
-NTSTATUS torture_setup_complex_file(struct smb2_tree *tree, const char *fname)
+NTSTATUS torture_setup_complex_file(struct torture_context *tctx,
+ struct smb2_tree *tree, const char *fname)
{
struct smb2_handle handle;
- NTSTATUS status = smb2_create_complex_file(tree, fname, &handle);
+ NTSTATUS status = smb2_create_complex_file(tctx, tree, fname, &handle);
NT_STATUS_NOT_OK_RETURN(status);
return smb2_util_close(tree, handle);
}
create a complex dir using SMB2, to make it easier to
find fields in SMB2 getinfo levels
*/
-NTSTATUS torture_setup_complex_dir(struct smb2_tree *tree, const char *fname)
+NTSTATUS torture_setup_complex_dir(struct torture_context *tctx,
+ struct smb2_tree *tree, const char *fname)
{
struct smb2_handle handle;
- NTSTATUS status = smb2_create_complex_dir(tree, fname, &handle);
+ NTSTATUS status = smb2_create_complex_dir(tctx, tree, fname, &handle);
NT_STATUS_NOT_OK_RETURN(status);
return smb2_util_close(tree, handle);
}