summaryrefslogtreecommitdiff
path: root/source4/torture
diff options
context:
space:
mode:
Diffstat (limited to 'source4/torture')
-rw-r--r--source4/torture/smb2/connect.c47
-rw-r--r--source4/torture/smb2/scan.c73
-rw-r--r--source4/torture/torture.c1
3 files changed, 100 insertions, 21 deletions
diff --git a/source4/torture/smb2/connect.c b/source4/torture/smb2/connect.c
index 6a9a803155..54991e27ba 100644
--- a/source4/torture/smb2/connect.c
+++ b/source4/torture/smb2/connect.c
@@ -46,14 +46,16 @@ static NTSTATUS torture_smb2_close(struct smb2_tree *tree, struct smb2_handle ha
return status;
}
- printf("Close gave:\n");
- printf("create_time = %s\n", nt_time_string(tmp_ctx, io.out.create_time));
- printf("access_time = %s\n", nt_time_string(tmp_ctx, io.out.access_time));
- printf("write_time = %s\n", nt_time_string(tmp_ctx, io.out.write_time));
- printf("change_time = %s\n", nt_time_string(tmp_ctx, io.out.change_time));
- printf("alloc_size = %lld\n", io.out.alloc_size);
- printf("size = %lld\n", io.out.size);
- printf("file_attr = 0x%x\n", io.out.file_attr);
+ if (DEBUGLVL(1)) {
+ printf("Close gave:\n");
+ printf("create_time = %s\n", nt_time_string(tmp_ctx, io.out.create_time));
+ printf("access_time = %s\n", nt_time_string(tmp_ctx, io.out.access_time));
+ printf("write_time = %s\n", nt_time_string(tmp_ctx, io.out.write_time));
+ printf("change_time = %s\n", nt_time_string(tmp_ctx, io.out.change_time));
+ printf("alloc_size = %lld\n", io.out.alloc_size);
+ printf("size = %lld\n", io.out.size);
+ printf("file_attr = 0x%x\n", io.out.file_attr);
+ }
talloc_free(tmp_ctx);
@@ -90,25 +92,28 @@ static struct smb2_handle torture_smb2_create(struct smb2_tree *tree,
return io.out.handle;
}
- printf("Open gave:\n");
- printf("oplock_flags = 0x%x\n", io.out.oplock_flags);
- printf("create_action = 0x%x\n", io.out.create_action);
- printf("create_time = %s\n", nt_time_string(tmp_ctx, io.out.create_time));
- printf("access_time = %s\n", nt_time_string(tmp_ctx, io.out.access_time));
- printf("write_time = %s\n", nt_time_string(tmp_ctx, io.out.write_time));
- printf("change_time = %s\n", nt_time_string(tmp_ctx, io.out.change_time));
- printf("alloc_size = %lld\n", io.out.alloc_size);
- printf("size = %lld\n", io.out.size);
- printf("file_attr = 0x%x\n", io.out.file_attr);
- printf("handle = %016llx%016llx\n",
- io.out.handle.data[0],
- io.out.handle.data[1]);
+ if (DEBUGLVL(1)) {
+ printf("Open gave:\n");
+ printf("oplock_flags = 0x%x\n", io.out.oplock_flags);
+ printf("create_action = 0x%x\n", io.out.create_action);
+ printf("create_time = %s\n", nt_time_string(tmp_ctx, io.out.create_time));
+ printf("access_time = %s\n", nt_time_string(tmp_ctx, io.out.access_time));
+ printf("write_time = %s\n", nt_time_string(tmp_ctx, io.out.write_time));
+ printf("change_time = %s\n", nt_time_string(tmp_ctx, io.out.change_time));
+ printf("alloc_size = %lld\n", io.out.alloc_size);
+ printf("size = %lld\n", io.out.size);
+ printf("file_attr = 0x%x\n", io.out.file_attr);
+ printf("handle = %016llx%016llx\n",
+ io.out.handle.data[0],
+ io.out.handle.data[1]);
+ }
talloc_free(tmp_ctx);
return io.out.handle;
}
+
/*
basic testing of SMB2 connection calls
*/
diff --git a/source4/torture/smb2/scan.c b/source4/torture/smb2/scan.c
index 0fcd3250fb..3946d19496 100644
--- a/source4/torture/smb2/scan.c
+++ b/source4/torture/smb2/scan.c
@@ -29,6 +29,79 @@
/*
+ scan for valid SMB2 getinfo levels
+*/
+BOOL torture_smb2_getinfo_scan(void)
+{
+ TALLOC_CTX *mem_ctx = talloc_new(NULL);
+ struct smb2_tree *tree;
+ const char *host = lp_parm_string(-1, "torture", "host");
+ const char *share = lp_parm_string(-1, "torture", "share");
+ struct cli_credentials *credentials = cmdline_credentials;
+ NTSTATUS status;
+ struct smb2_getinfo io;
+ struct smb2_create cr;
+ struct smb2_handle handle;
+ int c, i;
+ const char *fname = "scan-getinfo.dat";
+
+ status = smb2_connect(mem_ctx, host, share, credentials, &tree,
+ event_context_find(mem_ctx));
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Connection failed - %s\n", nt_errstr(status));
+ return False;
+ }
+
+ ZERO_STRUCT(cr);
+ cr.in.buffer_code = 0x39;
+ cr.in.oplock_flags = 0;
+ cr.in.access_mask = SEC_RIGHTS_FILE_ALL;
+ cr.in.file_attr = FILE_ATTRIBUTE_NORMAL;
+ cr.in.open_disposition = NTCREATEX_DISP_OPEN_IF;
+ cr.in.share_access =
+ NTCREATEX_SHARE_ACCESS_DELETE|
+ NTCREATEX_SHARE_ACCESS_READ|
+ NTCREATEX_SHARE_ACCESS_WRITE;
+ cr.in.create_options = NTCREATEX_OPTIONS_WRITE_THROUGH;
+ cr.in.fname = fname;
+
+ status = smb2_create(tree, &cr);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("create of '%s' failed - %s\n", fname, nt_errstr(status));
+ return False;
+ }
+
+ handle = cr.out.handle;
+
+
+ ZERO_STRUCT(io);
+ io.in.buffer_code = 0x29;
+ io.in.max_response_size = 0xFFFF;
+ io.in.handle = handle;
+
+ for (c=0;c<5;c++) {
+ for (i=0;i<0x100;i++) {
+ io.in.level = (i<<8) | c;
+ status = smb2_getinfo(tree, mem_ctx, &io);
+ if (NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER) ||
+ NT_STATUS_EQUAL(status, NT_STATUS_INVALID_INFO_CLASS) ||
+ NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) {
+ continue;
+ }
+ if (NT_STATUS_IS_OK(status)) {
+ printf("level 0x%04x is %d bytes\n",
+ io.in.level, io.out.blob.length);
+ dump_data(1, io.out.blob.data, io.out.blob.length);
+ }
+ }
+ }
+
+ talloc_free(mem_ctx);
+
+ return True;
+}
+
+/*
scan for valid SMB2 opcodes
*/
BOOL torture_smb2_scan(void)
diff --git a/source4/torture/torture.c b/source4/torture/torture.c
index 021c4b3ab4..ff9584ed5c 100644
--- a/source4/torture/torture.c
+++ b/source4/torture/torture.c
@@ -2254,6 +2254,7 @@ static struct {
/* SMB2 tests */
{"SMB2-CONNECT", torture_smb2_connect, 0},
{"SMB2-SCAN", torture_smb2_scan, 0},
+ {"SMB2-SCANGETINFO", torture_smb2_getinfo_scan, 0},
/* protocol scanners */
{"SCAN-TRANS2", torture_trans2_scan, 0},