return False;
}
- if (!torture_setup_complex_file(FNAME)) {
+ status = torture_setup_complex_file(tree, FNAME);
+ if (!NT_STATUS_IS_OK(status)) {
printf("Failed to setup complex file '%s'\n", FNAME);
+ return False;
}
- torture_setup_complex_file(FNAME ":2ndstream");
+ torture_setup_complex_file(tree, FNAME ":2ndstream");
- if (!torture_setup_complex_dir(DNAME)) {
+ status = torture_setup_complex_dir(tree, DNAME);
+ if (!NT_STATUS_IS_OK(status)) {
printf("Failed to setup complex dir '%s'\n", DNAME);
+ return False;
}
- torture_setup_complex_file(DNAME ":2ndstream");
+ torture_setup_complex_file(tree, DNAME ":2ndstream");
torture_smb2_testfile(tree, FNAME, &fhandle);
torture_smb2_testdir(tree, DNAME, &dhandle);
return False;
}
- if (!torture_setup_complex_file(FNAME)) {
+ status = torture_setup_complex_file(tree, FNAME);
+ if (!NT_STATUS_IS_OK(status)) {
printf("Failed to setup complex file '%s'\n", FNAME);
+ return False;
}
- torture_setup_complex_file(FNAME ":2ndstream");
+ torture_setup_complex_file(tree, FNAME ":2ndstream");
torture_smb2_testfile(tree, FNAME, &handle);
}
/*
- create a complex file using the SMB2 protocol
+ create a complex file/dir using the SMB2 protocol
*/
-NTSTATUS smb2_create_complex_file(struct smb2_tree *tree, const char *fname, struct smb2_handle *handle)
+static NTSTATUS smb2_create_complex(struct smb2_tree *tree, const char *fname,
+ struct smb2_handle *handle, BOOL dir)
{
TALLOC_CTX *tmp_ctx = talloc_new(tree);
char buf[7] = "abc";
time_t t = (time(NULL) & ~1);
NTSTATUS status;
+ smb2_util_unlink(tree, fname);
ZERO_STRUCT(io);
io.in.access_mask = SEC_RIGHTS_FILE_ALL;
io.in.file_attr = FILE_ATTRIBUTE_NORMAL;
NTCREATEX_SHARE_ACCESS_WRITE;
io.in.create_options = 0;
io.in.fname = fname;
+ if (dir) {
+ io.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
+ io.in.share_access &= ~NTCREATEX_SHARE_ACCESS_DELETE;
+ io.in.file_attr = FILE_ATTRIBUTE_DIRECTORY;
+ io.in.open_disposition = NTCREATEX_DISP_CREATE;
+ }
io.in.sd = security_descriptor_create(tmp_ctx,
NULL, NULL,
*handle = io.out.handle;
- status = smb2_util_write(tree, *handle, buf, 0, sizeof(buf));
- NT_STATUS_NOT_OK_RETURN(status);
+ if (!dir) {
+ status = smb2_util_write(tree, *handle, buf, 0, sizeof(buf));
+ NT_STATUS_NOT_OK_RETURN(status);
+ }
/* make sure all the timestamps aren't the same, and are also
in different DST zones*/
return NT_STATUS_OK;
}
+/*
+ create a complex file using the SMB2 protocol
+*/
+NTSTATUS smb2_create_complex_file(struct smb2_tree *tree, const char *fname,
+ struct smb2_handle *handle)
+{
+ return smb2_create_complex(tree, fname, handle, False);
+}
+
+/*
+ create a complex dir using the SMB2 protocol
+*/
+NTSTATUS smb2_create_complex_dir(struct smb2_tree *tree, const char *fname,
+ struct smb2_handle *handle)
+{
+ return smb2_create_complex(tree, fname, handle, True);
+}
+
/*
show lots of information about a file
*/
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("\taccess_mask: 0x%08x\n", io.all_info2.out.access_mask);
d_printf("\tunknown2: 0x%llx\n", io.all_info2.out.unknown2);
d_printf("\tunknown3: 0x%llx\n", io.all_info2.out.unknown3);
- d_printf("\tfname: '%s'\n", io.all_info2.out.fname.s);
/* short name, if any */
io.generic.level = RAW_FILEINFO_ALT_NAME_INFORMATION;
create a complex file using the old SMB protocol, to make it easier to
find fields in SMB2 getinfo levels
*/
-BOOL torture_setup_complex_file(const char *fname)
+NTSTATUS torture_setup_complex_file(struct smb2_tree *tree, const char *fname)
{
- struct smbcli_state *cli;
- int fnum;
-
- if (!torture_open_connection(&cli)) {
- return False;
- }
-
- fnum = create_complex_file(cli, cli, fname);
-
- if (DEBUGLVL(1)) {
- torture_all_info(cli->tree, fname);
- }
-
- talloc_free(cli);
- return fnum != -1;
+ struct smb2_handle handle;
+ NTSTATUS status = smb2_create_complex_file(tree, fname, &handle);
+ NT_STATUS_NOT_OK_RETURN(status);
+ return smb2_util_close(tree, handle);
}
+
/*
- create a complex directory using the old SMB protocol, to make it easier to
+ create a complex dir using the old SMB protocol, to make it easier to
find fields in SMB2 getinfo levels
*/
-BOOL torture_setup_complex_dir(const char *dname)
+NTSTATUS torture_setup_complex_dir(struct smb2_tree *tree, const char *fname)
{
- struct smbcli_state *cli;
- int fnum;
-
- if (!torture_open_connection(&cli)) {
- return False;
- }
-
- fnum = create_complex_dir(cli, cli, dname);
-
- if (DEBUGLVL(1)) {
- torture_all_info(cli->tree, dname);
- }
-
- talloc_free(cli);
- return fnum != -1;
+ struct smb2_handle handle;
+ NTSTATUS status = smb2_create_complex_dir(tree, fname, &handle);
+ NT_STATUS_NOT_OK_RETURN(status);
+ return smb2_util_close(tree, handle);
}
+