*/
#include "includes.h"
+#include "torture/torture.h"
+#include "system/time.h"
+#include "libcli/raw/libcliraw.h"
+#include "libcli/libcli.h"
+#include "torture/util.h"
#define BASEDIR "\\testsfileinfo"
for each call we test that it succeeds, and where possible test
for consistency between the calls.
*/
-BOOL torture_raw_sfileinfo(void)
+BOOL torture_raw_sfileinfo(struct torture_context *torture)
{
struct smbcli_state *cli;
BOOL ret = True;
asprintf(&fnum_fname, BASEDIR "\\fnum_test_%d.txt", n);
asprintf(&fnum_fname_new, BASEDIR "\\fnum_test_new_%d.txt", n);
- if (!torture_open_connection(&cli)) {
+ if (!torture_open_connection(&cli, 0)) {
return False;
}
mem_ctx = talloc_init("torture_sfileinfo");
- smbcli_deltree(cli->tree, BASEDIR);
- smbcli_mkdir(cli->tree, BASEDIR);
+ if (!torture_setup_dir(cli, BASEDIR)) {
+ return False;
+ }
#define RECREATE_FILE(fname) do { \
if (fnum != -1) smbcli_close(cli->tree, fnum); \
fnum = create_complex_file(cli, mem_ctx, fname); \
if (fnum == -1) { \
- printf("(%d) ERROR: open of %s failed (%s)\n", \
- __LINE__, fname, smbcli_errstr(cli->tree)); \
+ printf("(%s) ERROR: open of %s failed (%s)\n", \
+ __location__, fname, smbcli_errstr(cli->tree)); \
ret = False; \
goto done; \
}} while (0)
check_fnum = True; \
call_name = #call; \
sfinfo.generic.level = RAW_SFILEINFO_ ## call; \
- sfinfo.generic.file.fnum = fnum; \
+ sfinfo.generic.in.file.fnum = fnum; \
status = smb_raw_setfileinfo(cli->tree, &sfinfo); \
if (!NT_STATUS_EQUAL(status, rightstatus)) { \
- printf("(%d) %s - %s (should be %s)\n", __LINE__, #call, \
+ printf("(%s) %s - %s (should be %s)\n", __location__, #call, \
nt_errstr(status), nt_errstr(rightstatus)); \
ret = False; \
} \
finfo1.generic.level = RAW_FILEINFO_ALL_INFO; \
- finfo1.generic.in.fnum = fnum; \
+ finfo1.generic.in.file.fnum = fnum; \
status2 = smb_raw_fileinfo(cli->tree, mem_ctx, &finfo1); \
if (!NT_STATUS_IS_OK(status2)) { \
- printf("(%d) %s pathinfo - %s\n", __LINE__, #call, nt_errstr(status)); \
+ printf("(%s) %s pathinfo - %s\n", __location__, #call, nt_errstr(status)); \
ret = False; \
}} while (0)
check_fnum = False; \
call_name = #call; \
sfinfo.generic.level = RAW_SFILEINFO_ ## call; \
- sfinfo.generic.file.fname = path_fname; \
+ sfinfo.generic.in.file.path = path_fname; \
status = smb_raw_setpathinfo(cli->tree, &sfinfo); \
if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) { \
- sfinfo.generic.file.fname = path_fname_new; \
+ sfinfo.generic.in.file.path = path_fname_new; \
status = smb_raw_setpathinfo(cli->tree, &sfinfo); \
} \
if (!NT_STATUS_EQUAL(status, rightstatus)) { \
- printf("(%d) %s - %s (should be %s)\n", __LINE__, #call, \
+ printf("(%s) %s - %s (should be %s)\n", __location__, #call, \
nt_errstr(status), nt_errstr(rightstatus)); \
ret = False; \
} \
finfo1.generic.level = RAW_FILEINFO_ALL_INFO; \
- finfo1.generic.in.fname = path_fname; \
+ finfo1.generic.in.file.path = path_fname; \
status2 = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo1); \
if (NT_STATUS_EQUAL(status2, NT_STATUS_OBJECT_NAME_NOT_FOUND)) { \
- finfo1.generic.in.fname = path_fname_new; \
+ finfo1.generic.in.file.path = path_fname_new; \
status2 = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo1); \
} \
if (!NT_STATUS_IS_OK(status2)) { \
- printf("(%d) %s pathinfo - %s\n", __LINE__, #call, nt_errstr(status2)); \
+ printf("(%s) %s pathinfo - %s\n", __location__, #call, nt_errstr(status2)); \
ret = False; \
}} while (0)
do { if (NT_STATUS_IS_OK(status)) { \
finfo2.generic.level = RAW_FILEINFO_ ## call; \
if (check_fnum) { \
- finfo2.generic.in.fnum = fnum; \
+ finfo2.generic.in.file.fnum = fnum; \
status2 = smb_raw_fileinfo(cli->tree, mem_ctx, &finfo2); \
} else { \
- finfo2.generic.in.fname = path_fname; \
+ finfo2.generic.in.file.path = path_fname; \
status2 = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo2); \
if (NT_STATUS_EQUAL(status2, NT_STATUS_OBJECT_NAME_NOT_FOUND)) { \
- finfo2.generic.in.fname = path_fname_new; \
+ finfo2.generic.in.file.path = path_fname_new; \
status2 = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo2); \
} \
} \
if (!NT_STATUS_IS_OK(status2)) { \
printf("%s - %s\n", #call, nt_errstr(status2)); \
+ ret = False; \
} \
}} while (0)
#define CHECK_VALUE(call, stype, field, value) do { \
CHECK1(call); \
if (NT_STATUS_IS_OK(status) && NT_STATUS_IS_OK(status2) && finfo2.stype.out.field != value) { \
- printf("(%d) %s - %s/%s should be 0x%x - 0x%x\n", __LINE__, \
+ printf("(%s) %s - %s/%s should be 0x%x - 0x%x\n", __location__, \
call_name, #stype, #field, \
(uint_t)value, (uint_t)finfo2.stype.out.field); \
dump_all_info(mem_ctx, &finfo1); \
+ ret = False; \
}} while (0)
#define CHECK_TIME(call, stype, field, value) do { \
CHECK1(call); \
if (NT_STATUS_IS_OK(status) && NT_STATUS_IS_OK(status2) && nt_time_to_unix(finfo2.stype.out.field) != value) { \
- printf("(%d) %s - %s/%s should be 0x%x - 0x%x\n", __LINE__, \
+ printf("(%s) %s - %s/%s should be 0x%x - 0x%x\n", __location__, \
call_name, #stype, #field, \
(uint_t)value, \
(uint_t)nt_time_to_unix(finfo2.stype.out.field)); \
printf("\t%s", timestring(mem_ctx, value)); \
printf("\t%s\n", nt_time_string(mem_ctx, finfo2.stype.out.field)); \
dump_all_info(mem_ctx, &finfo1); \
+ ret = False; \
}} while (0)
#define CHECK_STR(call, stype, field, value) do { \
CHECK1(call); \
if (NT_STATUS_IS_OK(status) && NT_STATUS_IS_OK(status2) && strcmp(finfo2.stype.out.field, value) != 0) { \
- printf("(%d) %s - %s/%s should be '%s' - '%s'\n", __LINE__, \
+ printf("(%s) %s - %s/%s should be '%s' - '%s'\n", __location__, \
call_name, #stype, #field, \
value, \
finfo2.stype.out.field); \
dump_all_info(mem_ctx, &finfo1); \
+ ret = False; \
+ }} while (0)
+
+#define CHECK_STATUS(status, correct) do { \
+ if (!NT_STATUS_EQUAL(status, correct)) { \
+ printf("(%s) Incorrect status %s - should be %s\n", \
+ __location__, nt_errstr(status), nt_errstr(correct)); \
+ ret = False; \
+ goto done; \
}} while (0)
unix_to_nt_time(&sfinfo.basic_info.in.access_time, 0);
unix_to_nt_time(&sfinfo.basic_info.in.write_time, 0);
unix_to_nt_time(&sfinfo.basic_info.in.change_time, 0);
- sfinfo.basic_info.in.attrib = FILE_ATTRIBUTE_NORMAL;
+ sfinfo.basic_info.in.attrib = 0;
CHECK_CALL_FNUM(BASIC_INFO, NT_STATUS_OK);
CHECK_TIME(ALL_INFO, all_info, create_time, basetime + 100);
CHECK_TIME(ALL_INFO, all_info, access_time, basetime + 200);
CHECK_TIME(ALL_INFO, all_info, write_time, basetime + 300);
CHECK_TIME(ALL_INFO, all_info, change_time, basetime + 400);
- CHECK_VALUE(ALL_INFO, all_info, attrib, FILE_ATTRIBUTE_NORMAL);
+ CHECK_VALUE(ALL_INFO, all_info, attrib, FILE_ATTRIBUTE_READONLY);
printf("test basic_information level\n");
basetime += 86400;
unix_to_nt_time(&sfinfo.basic_info.in.access_time, basetime + 200);
unix_to_nt_time(&sfinfo.basic_info.in.write_time, basetime + 300);
unix_to_nt_time(&sfinfo.basic_info.in.change_time, basetime + 400);
- sfinfo.basic_info.in.attrib = FILE_ATTRIBUTE_READONLY;
+ sfinfo.basic_info.in.attrib = FILE_ATTRIBUTE_NORMAL;
CHECK_CALL_FNUM(BASIC_INFORMATION, NT_STATUS_OK);
CHECK_TIME(ALL_INFO, all_info, create_time, basetime + 100);
CHECK_TIME(ALL_INFO, all_info, access_time, basetime + 200);
CHECK_TIME(ALL_INFO, all_info, write_time, basetime + 300);
CHECK_TIME(ALL_INFO, all_info, change_time, basetime + 400);
- CHECK_VALUE(ALL_INFO, all_info, attrib, FILE_ATTRIBUTE_READONLY);
+ CHECK_VALUE(ALL_INFO, all_info, attrib, FILE_ATTRIBUTE_NORMAL);
CHECK_CALL_PATH(BASIC_INFORMATION, NT_STATUS_OK);
CHECK_TIME(ALL_INFO, all_info, create_time, basetime + 100);
CHECK_TIME(ALL_INFO, all_info, access_time, basetime + 200);
CHECK_TIME(ALL_INFO, all_info, write_time, basetime + 300);
CHECK_TIME(ALL_INFO, all_info, change_time, basetime + 400);
- CHECK_VALUE(ALL_INFO, all_info, attrib, FILE_ATTRIBUTE_READONLY);
+ CHECK_VALUE(ALL_INFO, all_info, attrib, FILE_ATTRIBUTE_NORMAL);
printf("a zero time means don't change\n");
unix_to_nt_time(&sfinfo.basic_info.in.create_time, 0);
fnum = fnum_saved;
printf("Trying rename with dest file open and delete_on_close\n");
+ sfinfo.rename_information.in.new_name = fnum_fname+strlen(BASEDIR)+1;
+ sfinfo.rename_information.in.overwrite = 1;
CHECK_CALL_FNUM(RENAME_INFORMATION, NT_STATUS_ACCESS_DENIED);
smbcli_close(cli->tree, fnum2);
CHECK_STR(NAME_INFO, name_info, fname.s, path_fname);
printf("Trying rename with a root fid\n");
- d_fnum = create_directory_handle(cli->tree, BASEDIR);
+ status = create_directory_handle(cli->tree, BASEDIR, &d_fnum);
+ CHECK_STATUS(status, NT_STATUS_OK);
sfinfo.rename_information.in.new_name = fnum_fname_new+strlen(BASEDIR)+1;
sfinfo.rename_information.in.root_fid = d_fnum;
CHECK_CALL_FNUM(RENAME_INFORMATION, NT_STATUS_INVALID_PARAMETER);
}
torture_close_connection(cli);
- talloc_destroy(mem_ctx);
+ talloc_free(mem_ctx);
return ret;
}
/*
look for the w2k3 setpathinfo STANDARD bug
*/
-BOOL torture_raw_sfileinfo_bug(void)
+BOOL torture_raw_sfileinfo_bug(struct torture_context *torture)
{
struct smbcli_state *cli;
TALLOC_CTX *mem_ctx;
NTSTATUS status;
int fnum;
- if (lp_parm_int(-1, "torture", "dangerous") != 1) {
+ if (!torture_setting_bool(torture, "dangerous", False)) {
printf("torture_raw_sfileinfo_bug disabled - enable dangerous tests to use\n");
return True;
}
- if (!torture_open_connection(&cli)) {
+ if (!torture_open_connection(&cli, 0)) {
return False;
}
smbcli_close(cli->tree, fnum);
sfinfo.generic.level = RAW_SFILEINFO_STANDARD;
- sfinfo.generic.file.fname = fname;
+ sfinfo.generic.in.file.path = fname;
sfinfo.standard.in.create_time = 0;
sfinfo.standard.in.access_time = 0;