*/
#include "includes.h"
+#include "system/time.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(int dummy)
+BOOL torture_raw_sfileinfo(void)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
BOOL ret = True;
TALLOC_CTX *mem_ctx;
int fnum_saved, d_fnum, fnum2, fnum = -1;
mem_ctx = talloc_init("torture_sfileinfo");
- cli_deltree(cli->tree, BASEDIR);
- cli_mkdir(cli->tree, BASEDIR);
+ if (!torture_setup_dir(cli, BASEDIR)) {
+ return False;
+ }
#define RECREATE_FILE(fname) do { \
- if (fnum != -1) cli_close(cli->tree, fnum); \
+ 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, cli_errstr(cli->tree)); \
+ printf("(%s) ERROR: open of %s failed (%s)\n", \
+ __location__, fname, smbcli_errstr(cli->tree)); \
ret = False; \
goto done; \
}} while (0)
#define RECREATE_BOTH do { \
RECREATE_FILE(path_fname); \
- cli_close(cli->tree, fnum); \
+ smbcli_close(cli->tree, fnum); \
RECREATE_FILE(fnum_fname); \
} while (0)
sfinfo.generic.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.in.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)
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; \
} \
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)
#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); \
#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__, \
+ if (NT_STATUS_IS_OK(status) && NT_STATUS_IS_OK(status2) && nt_time_to_unix(finfo2.stype.out.field) != value) { \
+ 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)); \
+ (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)); \
+ printf("\t%s\n", nt_time_string(mem_ctx, finfo2.stype.out.field)); \
dump_all_info(mem_ctx, &finfo1); \
}} 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); \
CHECK_VALUE(MODE_INFORMATION, mode_information, mode, 0);
#if 1
printf("finally the rename_information level\n");
- cli_close(cli->tree, create_complex_file(cli, mem_ctx, fnum_fname_new));
- cli_close(cli->tree, create_complex_file(cli, mem_ctx, path_fname_new));
+ smbcli_close(cli->tree, create_complex_file(cli, mem_ctx, fnum_fname_new));
+ smbcli_close(cli->tree, create_complex_file(cli, mem_ctx, path_fname_new));
sfinfo.rename_information.in.overwrite = 0;
sfinfo.rename_information.in.root_fid = 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);
- cli_close(cli->tree, fnum2);
+ smbcli_close(cli->tree, fnum2);
CHECK_CALL_FNUM(RENAME_INFORMATION, NT_STATUS_OK);
CHECK_STR(NAME_INFO, name_info, fname.s, fnum_fname);
sfinfo.rename_information.in.overwrite = 0;
CHECK_CALL_FNUM(RENAME_INFORMATION, NT_STATUS_OK);
CHECK_STR(NAME_INFO, name_info, fname.s, fnum_fname_new);
- cli_close(cli->tree, fnum2);
+ smbcli_close(cli->tree, fnum2);
sfinfo.rename_information.in.new_name = fnum_fname+strlen(BASEDIR)+1;
sfinfo.rename_information.in.overwrite = 0;
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);
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);
done:
smb_raw_exit(cli->session);
- cli_close(cli->tree, fnum);
- if (NT_STATUS_IS_ERR(cli_unlink(cli->tree, fnum_fname))) {
- printf("Failed to delete %s - %s\n", fnum_fname, cli_errstr(cli->tree));
+ smbcli_close(cli->tree, fnum);
+ if (NT_STATUS_IS_ERR(smbcli_unlink(cli->tree, fnum_fname))) {
+ printf("Failed to delete %s - %s\n", fnum_fname, smbcli_errstr(cli->tree));
}
- if (NT_STATUS_IS_ERR(cli_unlink(cli->tree, path_fname))) {
- printf("Failed to delete %s - %s\n", path_fname, cli_errstr(cli->tree));
+ if (NT_STATUS_IS_ERR(smbcli_unlink(cli->tree, path_fname))) {
+ printf("Failed to delete %s - %s\n", path_fname, smbcli_errstr(cli->tree));
}
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(int dummy)
+BOOL torture_raw_sfileinfo_bug(void)
{
- struct cli_state *cli;
+ struct smbcli_state *cli;
TALLOC_CTX *mem_ctx;
const char *fname = "\\bug3.txt";
union smb_setfileinfo sfinfo;
NTSTATUS status;
int fnum;
+ if (!lp_parm_bool(-1, "torture", "dangerous", False)) {
+ printf("torture_raw_sfileinfo_bug disabled - enable dangerous tests to use\n");
+ return True;
+ }
+
if (!torture_open_connection(&cli)) {
return False;
}
mem_ctx = talloc_init("torture_sfileinfo");
fnum = create_complex_file(cli, mem_ctx, fname);
- cli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
sfinfo.generic.level = RAW_SFILEINFO_STANDARD;
sfinfo.generic.file.fname = fname;