summaryrefslogtreecommitdiff
path: root/source4/torture/smb2
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-11-18 09:51:13 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:46:25 -0500
commit1692b2e571d4c692eae020522d298b6fca3f1804 (patch)
tree9b7719182dec4abec89f27712f24618db93256cb /source4/torture/smb2
parentc8c7fb2492d3f19939df67f98e4ea6ad423274da (diff)
downloadsamba-1692b2e571d4c692eae020522d298b6fca3f1804.tar.gz
samba-1692b2e571d4c692eae020522d298b6fca3f1804.tar.bz2
samba-1692b2e571d4c692eae020522d298b6fca3f1804.zip
r11776: no need to call out to SMB to setup test files for SMB2 any more
(This used to be commit dae70c5baed7d5613d793dca15dda3007c1a690a)
Diffstat (limited to 'source4/torture/smb2')
-rw-r--r--source4/torture/smb2/getinfo.c15
-rw-r--r--source4/torture/smb2/scan.c18
-rw-r--r--source4/torture/smb2/util.c84
3 files changed, 69 insertions, 48 deletions
diff --git a/source4/torture/smb2/getinfo.c b/source4/torture/smb2/getinfo.c
index 327ca8a12b..b8e61ebe34 100644
--- a/source4/torture/smb2/getinfo.c
+++ b/source4/torture/smb2/getinfo.c
@@ -156,15 +156,22 @@ BOOL torture_smb2_getinfo(void)
TALLOC_CTX *mem_ctx = talloc_new(NULL);
struct smb2_tree *tree;
BOOL ret = True;
+ NTSTATUS status;
if (!torture_smb2_connection(mem_ctx, &tree)) {
return False;
}
- torture_setup_complex_file(FNAME);
- torture_setup_complex_file(FNAME ":streamtwo");
- torture_setup_complex_dir(DNAME);
- torture_setup_complex_file(DNAME ":streamtwo");
+ status = torture_setup_complex_file(tree, FNAME);
+ if (!NT_STATUS_IS_OK(status)) {
+ return False;
+ }
+ torture_setup_complex_file(tree, FNAME ":streamtwo");
+ status = torture_setup_complex_dir(tree, DNAME);
+ if (!NT_STATUS_IS_OK(status)) {
+ return False;
+ }
+ torture_setup_complex_file(tree, DNAME ":streamtwo");
ret &= torture_smb2_fileinfo(tree);
ret &= torture_smb2_fsinfo(tree);
diff --git a/source4/torture/smb2/scan.c b/source4/torture/smb2/scan.c
index 908dac3e11..81e0bea69a 100644
--- a/source4/torture/smb2/scan.c
+++ b/source4/torture/smb2/scan.c
@@ -48,15 +48,19 @@ BOOL torture_smb2_getinfo_scan(void)
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);
@@ -112,10 +116,12 @@ BOOL torture_smb2_setinfo_scan(void)
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);
diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c
index 56309929ad..776714da9e 100644
--- a/source4/torture/smb2/util.c
+++ b/source4/torture/smb2/util.c
@@ -88,9 +88,10 @@ NTSTATUS smb2_util_write(struct smb2_tree *tree,
}
/*
- 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";
@@ -100,6 +101,7 @@ NTSTATUS smb2_create_complex_file(struct smb2_tree *tree, const char *fname, str
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;
@@ -110,6 +112,12 @@ NTSTATUS smb2_create_complex_file(struct smb2_tree *tree, const char *fname, str
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,
@@ -141,8 +149,10 @@ NTSTATUS smb2_create_complex_file(struct smb2_tree *tree, const char *fname, str
*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*/
@@ -183,6 +193,24 @@ NTSTATUS smb2_create_complex_file(struct smb2_tree *tree, const char *fname, str
}
/*
+ 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
*/
void torture_smb2_all_info(struct smb2_tree *tree, struct smb2_handle handle)
@@ -201,6 +229,7 @@ void torture_smb2_all_info(struct smb2_tree *tree, struct smb2_handle handle)
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));
@@ -217,7 +246,6 @@ void torture_smb2_all_info(struct smb2_tree *tree, struct smb2_handle handle)
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;
@@ -347,44 +375,24 @@ NTSTATUS torture_smb2_testdir(struct smb2_tree *tree, const char *fname,
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);
}
+