2 Unix SMB/CIFS implementation.
4 SMB2 getinfo test suite
6 Copyright (C) Andrew Tridgell 2005
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include "libcli/smb2/smb2.h"
25 #include "libcli/smb2/smb2_calls.h"
26 #include "librpc/gen_ndr/security.h"
33 union smb_fileinfo finfo;
34 union smb_fileinfo dinfo;
36 #define LEVEL(x) #x, x
37 { LEVEL(RAW_FILEINFO_BASIC_INFORMATION) },
38 { LEVEL(RAW_FILEINFO_STANDARD_INFORMATION) },
39 { LEVEL(RAW_FILEINFO_INTERNAL_INFORMATION) },
40 { LEVEL(RAW_FILEINFO_EA_INFORMATION) },
41 { LEVEL(RAW_FILEINFO_ACCESS_INFORMATION) },
42 { LEVEL(RAW_FILEINFO_POSITION_INFORMATION) },
43 { LEVEL(RAW_FILEINFO_MODE_INFORMATION) },
44 { LEVEL(RAW_FILEINFO_ALIGNMENT_INFORMATION) },
45 { LEVEL(RAW_FILEINFO_ALL_INFORMATION) },
46 { LEVEL(RAW_FILEINFO_ALT_NAME_INFORMATION) },
47 { LEVEL(RAW_FILEINFO_STREAM_INFORMATION) },
48 { LEVEL(RAW_FILEINFO_COMPRESSION_INFORMATION) },
49 { LEVEL(RAW_FILEINFO_NETWORK_OPEN_INFORMATION) },
50 { LEVEL(RAW_FILEINFO_ATTRIBUTE_TAG_INFORMATION) },
51 { LEVEL(RAW_FILEINFO_SMB2_ALL_EAS) },
52 { LEVEL(RAW_FILEINFO_SMB2_ALL_INFORMATION) },
53 { LEVEL(RAW_FILEINFO_SEC_DESC) }
60 union smb_fsinfo info;
62 { LEVEL(RAW_QFS_VOLUME_INFORMATION) },
63 { LEVEL(RAW_QFS_SIZE_INFORMATION) },
64 { LEVEL(RAW_QFS_DEVICE_INFORMATION) },
65 { LEVEL(RAW_QFS_ATTRIBUTE_INFORMATION) },
66 { LEVEL(RAW_QFS_QUOTA_INFORMATION) },
67 { LEVEL(RAW_QFS_FULL_SIZE_INFORMATION) },
68 { LEVEL(RAW_QFS_OBJECTID_INFORMATION) }
71 #define FNAME "testsmb2_file.dat"
72 #define DNAME "testsmb2_dir"
77 static BOOL torture_smb2_fileinfo(struct smb2_tree *tree)
79 struct smb2_handle hfile, hdir;
83 status = torture_smb2_testfile(tree, FNAME, &hfile);
84 if (!NT_STATUS_IS_OK(status)) {
85 printf("Unable to create test file '%s' - %s\n", FNAME, nt_errstr(status));
89 status = torture_smb2_testdir(tree, DNAME, &hdir);
90 if (!NT_STATUS_IS_OK(status)) {
91 printf("Unable to create test directory '%s' - %s\n", DNAME, nt_errstr(status));
95 torture_smb2_all_info(tree, hfile);
96 torture_smb2_all_info(tree, hdir);
98 for (i=0;i<ARRAY_SIZE(file_levels);i++) {
99 if (file_levels[i].level == RAW_FILEINFO_SEC_DESC) {
100 file_levels[i].finfo.query_secdesc.secinfo_flags = 0x7;
101 file_levels[i].dinfo.query_secdesc.secinfo_flags = 0x7;
103 file_levels[i].finfo.generic.level = file_levels[i].level;
104 file_levels[i].finfo.generic.in.handle = hfile;
105 file_levels[i].fstatus = smb2_getinfo_file(tree, tree, &file_levels[i].finfo);
106 if (!NT_STATUS_IS_OK(file_levels[i].fstatus)) {
107 printf("%s failed on file - %s\n", file_levels[i].name, nt_errstr(file_levels[i].fstatus));
109 file_levels[i].dinfo.generic.level = file_levels[i].level;
110 file_levels[i].dinfo.generic.in.handle = hdir;
111 file_levels[i].dstatus = smb2_getinfo_file(tree, tree, &file_levels[i].dinfo);
112 if (!NT_STATUS_IS_OK(file_levels[i].dstatus)) {
113 printf("%s failed on dir - %s\n", file_levels[i].name, nt_errstr(file_levels[i].dstatus));
127 static BOOL torture_smb2_fsinfo(struct smb2_tree *tree)
131 struct smb2_handle handle;
133 status = torture_smb2_testdir(tree, DNAME, &handle);
134 if (!NT_STATUS_IS_OK(status)) {
135 printf("Unable to create test directory '%s' - %s\n", DNAME, nt_errstr(status));
139 for (i=0;i<ARRAY_SIZE(fs_levels);i++) {
140 fs_levels[i].info.generic.level = fs_levels[i].level;
141 fs_levels[i].info.generic.handle = handle;
142 fs_levels[i].status = smb2_getinfo_fs(tree, tree, &fs_levels[i].info);
143 if (!NT_STATUS_IS_OK(fs_levels[i].status)) {
144 printf("%s failed - %s\n", fs_levels[i].name, nt_errstr(fs_levels[i].status));
152 /* basic testing of all SMB2 getinfo levels
154 BOOL torture_smb2_getinfo(void)
156 TALLOC_CTX *mem_ctx = talloc_new(NULL);
157 struct smb2_tree *tree;
160 if (!torture_smb2_connection(mem_ctx, &tree)) {
164 torture_setup_complex_file(FNAME);
165 torture_setup_complex_file(FNAME ":streamtwo");
166 torture_setup_complex_dir(DNAME);
167 torture_setup_complex_file(DNAME ":streamtwo");
169 ret &= torture_smb2_fileinfo(tree);
170 ret &= torture_smb2_fsinfo(tree);
172 talloc_free(mem_ctx);