summaryrefslogtreecommitdiff
path: root/source4/torture/smb2
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-11-17 11:06:13 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:46:23 -0500
commiteedb92ce724e505f94ed49f9b238be617c52ccb4 (patch)
tree7f9d9bb9f44419beafd7122ca534b0fd510ce4ac /source4/torture/smb2
parentace255a54b46e04a453f955b72bca4313150eaa7 (diff)
downloadsamba-eedb92ce724e505f94ed49f9b238be617c52ccb4.tar.gz
samba-eedb92ce724e505f94ed49f9b238be617c52ccb4.tar.bz2
samba-eedb92ce724e505f94ed49f9b238be617c52ccb4.zip
r11758: unified the parse code for the SMB and SMB2 qfsinfo and qfileinfo calls
(This used to be commit ba897e537b9a1544dc214e9d5504c87fee6fced2)
Diffstat (limited to 'source4/torture/smb2')
-rw-r--r--source4/torture/smb2/getinfo.c157
-rw-r--r--source4/torture/smb2/util.c73
2 files changed, 146 insertions, 84 deletions
diff --git a/source4/torture/smb2/getinfo.c b/source4/torture/smb2/getinfo.c
index f175b19f89..327ca8a12b 100644
--- a/source4/torture/smb2/getinfo.c
+++ b/source4/torture/smb2/getinfo.c
@@ -23,63 +23,63 @@
#include "includes.h"
#include "libcli/smb2/smb2.h"
#include "libcli/smb2/smb2_calls.h"
+#include "librpc/gen_ndr/security.h"
static struct {
const char *name;
uint16_t level;
NTSTATUS fstatus;
NTSTATUS dstatus;
- union smb2_fileinfo finfo;
- union smb2_fileinfo dinfo;
-} levels[] = {
+ union smb_fileinfo finfo;
+ union smb_fileinfo dinfo;
+} file_levels[] = {
#define LEVEL(x) #x, x
- { LEVEL(SMB2_GETINFO_FS_VOLUME_INFO) },
- { LEVEL(SMB2_GETINFO_FS_SIZE_INFO) },
- { LEVEL(SMB2_GETINFO_FS_DEVICE_INFO) },
- { LEVEL(SMB2_GETINFO_FS_ATTRIBUTE_INFO) },
- { LEVEL(SMB2_GETINFO_FS_QUOTA_INFO) },
- { LEVEL(SMB2_GETINFO_FS_FULL_SIZE_INFO) },
- { LEVEL(SMB2_GETINFO_FS_OBJECTID_INFO) },
- { LEVEL(SMB2_GETINFO_SECURITY) },
- { LEVEL(SMB2_GETINFO_FILE_BASIC_INFO) },
- { LEVEL(SMB2_GETINFO_FILE_SIZE_INFO) },
- { LEVEL(SMB2_GETINFO_FILE_ID) },
- { LEVEL(SMB2_GETINFO_FILE_EA_SIZE) },
- { LEVEL(SMB2_GETINFO_FILE_ACCESS_INFO) },
- { LEVEL(SMB2_GETINFO_FILE_0E) },
- { LEVEL(SMB2_GETINFO_FILE_ALL_EAS) },
- { LEVEL(SMB2_GETINFO_FILE_10) },
- { LEVEL(SMB2_GETINFO_FILE_11) },
- { LEVEL(SMB2_GETINFO_FILE_ALL_INFO) },
- { LEVEL(SMB2_GETINFO_FILE_SHORT_INFO) },
- { LEVEL(SMB2_GETINFO_FILE_STREAM_INFO) },
- { LEVEL(SMB2_GETINFO_FILE_EOF_INFO) },
- { LEVEL(SMB2_GETINFO_FILE_STANDARD_INFO) },
- { LEVEL(SMB2_GETINFO_FILE_ATTRIB_INFO) }
+ { LEVEL(RAW_FILEINFO_BASIC_INFORMATION) },
+ { LEVEL(RAW_FILEINFO_STANDARD_INFORMATION) },
+ { LEVEL(RAW_FILEINFO_INTERNAL_INFORMATION) },
+ { LEVEL(RAW_FILEINFO_EA_INFORMATION) },
+ { LEVEL(RAW_FILEINFO_ACCESS_INFORMATION) },
+ { LEVEL(RAW_FILEINFO_POSITION_INFORMATION) },
+ { LEVEL(RAW_FILEINFO_MODE_INFORMATION) },
+ { LEVEL(RAW_FILEINFO_ALIGNMENT_INFORMATION) },
+ { LEVEL(RAW_FILEINFO_ALL_INFORMATION) },
+ { LEVEL(RAW_FILEINFO_ALT_NAME_INFORMATION) },
+ { LEVEL(RAW_FILEINFO_STREAM_INFORMATION) },
+ { LEVEL(RAW_FILEINFO_COMPRESSION_INFORMATION) },
+ { LEVEL(RAW_FILEINFO_NETWORK_OPEN_INFORMATION) },
+ { LEVEL(RAW_FILEINFO_ATTRIBUTE_TAG_INFORMATION) },
+ { LEVEL(RAW_FILEINFO_SMB2_ALL_EAS) },
+ { LEVEL(RAW_FILEINFO_SMB2_ALL_INFORMATION) },
+ { LEVEL(RAW_FILEINFO_SEC_DESC) }
+};
+
+static struct {
+ const char *name;
+ uint16_t level;
+ NTSTATUS status;
+ union smb_fsinfo info;
+} fs_levels[] = {
+ { LEVEL(RAW_QFS_VOLUME_INFORMATION) },
+ { LEVEL(RAW_QFS_SIZE_INFORMATION) },
+ { LEVEL(RAW_QFS_DEVICE_INFORMATION) },
+ { LEVEL(RAW_QFS_ATTRIBUTE_INFORMATION) },
+ { LEVEL(RAW_QFS_QUOTA_INFORMATION) },
+ { LEVEL(RAW_QFS_FULL_SIZE_INFORMATION) },
+ { LEVEL(RAW_QFS_OBJECTID_INFORMATION) }
};
#define FNAME "testsmb2_file.dat"
#define DNAME "testsmb2_dir"
-/* basic testing of all SMB2 getinfo levels
+/*
+ test fileinfo levels
*/
-BOOL torture_smb2_getinfo(void)
+static BOOL torture_smb2_fileinfo(struct smb2_tree *tree)
{
- TALLOC_CTX *mem_ctx = talloc_new(NULL);
struct smb2_handle hfile, hdir;
- struct smb2_tree *tree;
NTSTATUS status;
int i;
- if (!torture_smb2_connection(mem_ctx, &tree)) {
- goto failed;
- }
-
- torture_setup_complex_file(FNAME);
- torture_setup_complex_file(FNAME ":streamtwo");
- torture_setup_complex_dir(DNAME);
- torture_setup_complex_file(DNAME ":streamtwo");
-
status = torture_smb2_testfile(tree, FNAME, &hfile);
if (!NT_STATUS_IS_OK(status)) {
printf("Unable to create test file '%s' - %s\n", FNAME, nt_errstr(status));
@@ -95,22 +95,81 @@ BOOL torture_smb2_getinfo(void)
torture_smb2_all_info(tree, hfile);
torture_smb2_all_info(tree, hdir);
- for (i=0;i<ARRAY_SIZE(levels);i++) {
- levels[i].fstatus = smb2_getinfo_level(tree, mem_ctx, hfile,
- levels[i].level, &levels[i].finfo);
- if (!NT_STATUS_IS_OK(levels[i].fstatus)) {
- printf("%s failed on file - %s\n", levels[i].name, nt_errstr(levels[i].fstatus));
+ for (i=0;i<ARRAY_SIZE(file_levels);i++) {
+ if (file_levels[i].level == RAW_FILEINFO_SEC_DESC) {
+ file_levels[i].finfo.query_secdesc.secinfo_flags = 0x7;
+ file_levels[i].dinfo.query_secdesc.secinfo_flags = 0x7;
}
- levels[i].dstatus = smb2_getinfo_level(tree, mem_ctx, hdir,
- levels[i].level, &levels[i].dinfo);
- if (!NT_STATUS_IS_OK(levels[i].dstatus)) {
- printf("%s failed on dir - %s\n", levels[i].name, nt_errstr(levels[i].dstatus));
+ file_levels[i].finfo.generic.level = file_levels[i].level;
+ file_levels[i].finfo.generic.in.handle = hfile;
+ file_levels[i].fstatus = smb2_getinfo_file(tree, tree, &file_levels[i].finfo);
+ if (!NT_STATUS_IS_OK(file_levels[i].fstatus)) {
+ printf("%s failed on file - %s\n", file_levels[i].name, nt_errstr(file_levels[i].fstatus));
+ }
+ file_levels[i].dinfo.generic.level = file_levels[i].level;
+ file_levels[i].dinfo.generic.in.handle = hdir;
+ file_levels[i].dstatus = smb2_getinfo_file(tree, tree, &file_levels[i].dinfo);
+ if (!NT_STATUS_IS_OK(file_levels[i].dstatus)) {
+ printf("%s failed on dir - %s\n", file_levels[i].name, nt_errstr(file_levels[i].dstatus));
}
}
return True;
failed:
- talloc_free(mem_ctx);
return False;
}
+
+
+/*
+ test fsinfo levels
+*/
+static BOOL torture_smb2_fsinfo(struct smb2_tree *tree)
+{
+ int i;
+ NTSTATUS status;
+ struct smb2_handle handle;
+
+ status = torture_smb2_testdir(tree, DNAME, &handle);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Unable to create test directory '%s' - %s\n", DNAME, nt_errstr(status));
+ return False;
+ }
+
+ for (i=0;i<ARRAY_SIZE(fs_levels);i++) {
+ fs_levels[i].info.generic.level = fs_levels[i].level;
+ fs_levels[i].info.generic.handle = handle;
+ fs_levels[i].status = smb2_getinfo_fs(tree, tree, &fs_levels[i].info);
+ if (!NT_STATUS_IS_OK(fs_levels[i].status)) {
+ printf("%s failed - %s\n", fs_levels[i].name, nt_errstr(fs_levels[i].status));
+ }
+ }
+
+ return True;
+}
+
+
+/* basic testing of all SMB2 getinfo levels
+*/
+BOOL torture_smb2_getinfo(void)
+{
+ TALLOC_CTX *mem_ctx = talloc_new(NULL);
+ struct smb2_tree *tree;
+ BOOL ret = True;
+
+ 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");
+
+ ret &= torture_smb2_fileinfo(tree);
+ ret &= torture_smb2_fsinfo(tree);
+
+ talloc_free(mem_ctx);
+
+ return ret;
+}
diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c
index 6cbc230630..95624220f7 100644
--- a/source4/torture/smb2/util.c
+++ b/source4/torture/smb2/util.c
@@ -34,65 +34,68 @@ void torture_smb2_all_info(struct smb2_tree *tree, struct smb2_handle handle)
{
NTSTATUS status;
TALLOC_CTX *tmp_ctx = talloc_new(tree);
- union smb2_fileinfo io;
+ union smb_fileinfo io;
- status = smb2_getinfo_level(tree, tmp_ctx, handle, SMB2_GETINFO_FILE_ALL_INFO, &io);
+ io.generic.level = RAW_FILEINFO_SMB2_ALL_INFORMATION;
+ io.generic.in.handle = handle;
+
+ status = smb2_getinfo_file(tree, tmp_ctx, &io);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("getinfo failed - %s\n", nt_errstr(status)));
talloc_free(tmp_ctx);
return;
}
- d_printf("\tcreate_time: %s\n", nt_time_string(tmp_ctx, io.all_info.create_time));
- d_printf("\taccess_time: %s\n", nt_time_string(tmp_ctx, io.all_info.access_time));
- d_printf("\twrite_time: %s\n", nt_time_string(tmp_ctx, io.all_info.write_time));
- d_printf("\tchange_time: %s\n", nt_time_string(tmp_ctx, io.all_info.change_time));
- d_printf("\tattrib: 0x%x\n", io.all_info.file_attr);
- d_printf("\tunknown1: 0x%x\n", io.all_info.unknown1);
- d_printf("\talloc_size: %llu\n", (uint64_t)io.all_info.alloc_size);
- d_printf("\tsize: %llu\n", (uint64_t)io.all_info.size);
- d_printf("\tnlink: %u\n", io.all_info.nlink);
- d_printf("\tdelete_pending: %u\n", io.all_info.delete_pending);
- d_printf("\tdirectory: %u\n", io.all_info.directory);
- d_printf("\tfile_id: %llu\n", io.all_info.file_id);
- d_printf("\tea_size: %u\n", io.all_info.ea_size);
- d_printf("\taccess_mask: 0x%08x\n", io.all_info.access_mask);
- d_printf("\tunknown5: 0x%llx\n", io.all_info.unknown5);
- d_printf("\tunknown6: 0x%llx\n", io.all_info.unknown6);
- d_printf("\tfname: '%s'\n", io.all_info.fname);
+ 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("\tchange_time: %s\n", nt_time_string(tmp_ctx, io.all_info2.out.change_time));
+ d_printf("\tattrib: 0x%x\n", io.all_info2.out.attrib);
+ d_printf("\tunknown1: 0x%x\n", io.all_info2.out.unknown1);
+ d_printf("\talloc_size: %llu\n", (uint64_t)io.all_info2.out.alloc_size);
+ d_printf("\tsize: %llu\n", (uint64_t)io.all_info2.out.size);
+ d_printf("\tnlink: %u\n", io.all_info2.out.nlink);
+ d_printf("\tdelete_pending: %u\n", io.all_info2.out.delete_pending);
+ d_printf("\tdirectory: %u\n", io.all_info2.out.directory);
+ d_printf("\tfile_id: %llu\n", io.all_info2.out.file_id);
+ d_printf("\tea_size: %u\n", io.all_info2.out.ea_size);
+ 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 */
- status = smb2_getinfo_level(tree, tmp_ctx, handle,
- SMB2_GETINFO_FILE_SHORT_INFO, &io);
+ io.generic.level = RAW_FILEINFO_ALT_NAME_INFORMATION;
+ status = smb2_getinfo_file(tree, tmp_ctx, &io);
if (NT_STATUS_IS_OK(status)) {
- d_printf("\tshort name: '%s'\n", io.short_info.short_name);
+ d_printf("\tshort name: '%s'\n", io.alt_name_info.out.fname.s);
}
/* the EAs, if any */
- status = smb2_getinfo_level(tree, tmp_ctx, handle,
- SMB2_GETINFO_FILE_ALL_EAS, &io);
+ io.generic.level = RAW_FILEINFO_SMB2_ALL_EAS;
+ status = smb2_getinfo_file(tree, tmp_ctx, &io);
if (NT_STATUS_IS_OK(status)) {
int i;
- for (i=0;i<io.all_eas.num_eas;i++) {
+ for (i=0;i<io.all_eas.out.num_eas;i++) {
d_printf("\tEA[%d] flags=%d len=%d '%s'\n", i,
- io.all_eas.eas[i].flags,
- (int)io.all_eas.eas[i].value.length,
- io.all_eas.eas[i].name.s);
+ io.all_eas.out.eas[i].flags,
+ (int)io.all_eas.out.eas[i].value.length,
+ io.all_eas.out.eas[i].name.s);
}
}
/* streams, if available */
- status = smb2_getinfo_level(tree, tmp_ctx, handle,
- SMB2_GETINFO_FILE_STREAM_INFO, &io);
+ io.generic.level = RAW_FILEINFO_STREAM_INFORMATION;
+ status = smb2_getinfo_file(tree, tmp_ctx, &io);
if (NT_STATUS_IS_OK(status)) {
int i;
- for (i=0;i<io.stream_info.num_streams;i++) {
+ for (i=0;i<io.stream_info.out.num_streams;i++) {
d_printf("\tstream %d:\n", i);
d_printf("\t\tsize %ld\n",
- (long)io.stream_info.streams[i].size);
+ (long)io.stream_info.out.streams[i].size);
d_printf("\t\talloc size %ld\n",
- (long)io.stream_info.streams[i].alloc_size);
- d_printf("\t\tname %s\n", io.stream_info.streams[i].stream_name.s);
+ (long)io.stream_info.out.streams[i].alloc_size);
+ d_printf("\t\tname %s\n", io.stream_info.out.streams[i].stream_name.s);
}
}
@@ -173,7 +176,7 @@ NTSTATUS torture_smb2_testdir(struct smb2_tree *tree, const char *fname,
io.in.access_mask = SEC_RIGHTS_DIR_ALL;
io.in.file_attr = FILE_ATTRIBUTE_DIRECTORY;
io.in.open_disposition = NTCREATEX_DISP_OPEN_IF;
- io.in.share_access = NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE;
+ io.in.share_access = NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE;
io.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
io.in.fname = fname;
io.in.blob = data_blob(NULL, 0);