1 | /*
|
---|
2 | Unix SMB/CIFS implementation.
|
---|
3 |
|
---|
4 | show server properties
|
---|
5 |
|
---|
6 | Copyright (C) Andrew Tridgell 2004
|
---|
7 |
|
---|
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 3 of the License, or
|
---|
11 | (at your option) any later version.
|
---|
12 |
|
---|
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.
|
---|
17 |
|
---|
18 | You should have received a copy of the GNU General Public License
|
---|
19 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
20 | */
|
---|
21 |
|
---|
22 | #include "includes.h"
|
---|
23 | #include "libcli/libcli.h"
|
---|
24 | #include "torture/util.h"
|
---|
25 |
|
---|
26 | struct bitmapping {
|
---|
27 | const char *name;
|
---|
28 | uint32_t value;
|
---|
29 | };
|
---|
30 |
|
---|
31 | #define BIT_NAME(x) { #x, x }
|
---|
32 |
|
---|
33 | const static struct bitmapping fs_attr_bits[] = {
|
---|
34 | BIT_NAME(FS_ATTR_CASE_SENSITIVE_SEARCH),
|
---|
35 | BIT_NAME(FS_ATTR_CASE_PRESERVED_NAMES),
|
---|
36 | BIT_NAME(FS_ATTR_UNICODE_ON_DISK),
|
---|
37 | BIT_NAME(FS_ATTR_PERSISTANT_ACLS),
|
---|
38 | BIT_NAME(FS_ATTR_COMPRESSION),
|
---|
39 | BIT_NAME(FS_ATTR_QUOTAS),
|
---|
40 | BIT_NAME(FS_ATTR_SPARSE_FILES),
|
---|
41 | BIT_NAME(FS_ATTR_REPARSE_POINTS),
|
---|
42 | BIT_NAME(FS_ATTR_REMOTE_STORAGE),
|
---|
43 | BIT_NAME(FS_ATTR_LFN_SUPPORT),
|
---|
44 | BIT_NAME(FS_ATTR_IS_COMPRESSED),
|
---|
45 | BIT_NAME(FS_ATTR_OBJECT_IDS),
|
---|
46 | BIT_NAME(FS_ATTR_ENCRYPTION),
|
---|
47 | BIT_NAME(FS_ATTR_NAMED_STREAMS),
|
---|
48 | { NULL, 0 }
|
---|
49 | };
|
---|
50 |
|
---|
51 | const static struct bitmapping capability_bits[] = {
|
---|
52 | BIT_NAME(CAP_RAW_MODE),
|
---|
53 | BIT_NAME(CAP_MPX_MODE),
|
---|
54 | BIT_NAME(CAP_UNICODE),
|
---|
55 | BIT_NAME(CAP_LARGE_FILES),
|
---|
56 | BIT_NAME(CAP_NT_SMBS),
|
---|
57 | BIT_NAME(CAP_RPC_REMOTE_APIS),
|
---|
58 | BIT_NAME(CAP_STATUS32),
|
---|
59 | BIT_NAME(CAP_LEVEL_II_OPLOCKS),
|
---|
60 | BIT_NAME(CAP_LOCK_AND_READ),
|
---|
61 | BIT_NAME(CAP_NT_FIND),
|
---|
62 | BIT_NAME(CAP_DFS),
|
---|
63 | BIT_NAME(CAP_W2K_SMBS),
|
---|
64 | BIT_NAME(CAP_LARGE_READX),
|
---|
65 | BIT_NAME(CAP_LARGE_WRITEX),
|
---|
66 | BIT_NAME(CAP_UNIX),
|
---|
67 | BIT_NAME(CAP_EXTENDED_SECURITY),
|
---|
68 | { NULL, 0 }
|
---|
69 | };
|
---|
70 |
|
---|
71 | static void show_bits(const struct bitmapping *bm, uint32_t value)
|
---|
72 | {
|
---|
73 | int i;
|
---|
74 | for (i=0;bm[i].name;i++) {
|
---|
75 | if (value & bm[i].value) {
|
---|
76 | d_printf("\t%s\n", bm[i].name);
|
---|
77 | value &= ~bm[i].value;
|
---|
78 | }
|
---|
79 | }
|
---|
80 | if (value != 0) {
|
---|
81 | d_printf("\tunknown bits: 0x%08x\n", value);
|
---|
82 | }
|
---|
83 | }
|
---|
84 |
|
---|
85 |
|
---|
86 | /*
|
---|
87 | print out server properties
|
---|
88 | */
|
---|
89 | bool torture_test_properties(struct torture_context *torture,
|
---|
90 | struct smbcli_state *cli)
|
---|
91 | {
|
---|
92 | bool correct = true;
|
---|
93 | union smb_fsinfo fs;
|
---|
94 | NTSTATUS status;
|
---|
95 |
|
---|
96 | d_printf("Capabilities: 0x%08x\n", cli->transport->negotiate.capabilities);
|
---|
97 | show_bits(capability_bits, cli->transport->negotiate.capabilities);
|
---|
98 | d_printf("\n");
|
---|
99 |
|
---|
100 | fs.attribute_info.level = RAW_QFS_ATTRIBUTE_INFO;
|
---|
101 | status = smb_raw_fsinfo(cli->tree, cli, &fs);
|
---|
102 | if (!NT_STATUS_IS_OK(status)) {
|
---|
103 | d_printf("qfsinfo failed - %s\n", nt_errstr(status));
|
---|
104 | correct = false;
|
---|
105 | } else {
|
---|
106 | d_printf("Filesystem attributes: 0x%08x\n",
|
---|
107 | fs.attribute_info.out.fs_attr);
|
---|
108 | show_bits(fs_attr_bits, fs.attribute_info.out.fs_attr);
|
---|
109 | d_printf("max_file_component_length: %d\n",
|
---|
110 | fs.attribute_info.out.max_file_component_length);
|
---|
111 | d_printf("fstype: %s\n", fs.attribute_info.out.fs_type.s);
|
---|
112 | }
|
---|
113 |
|
---|
114 | return correct;
|
---|
115 | }
|
---|
116 |
|
---|
117 |
|
---|