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 "torture/torture.h" 24#include "libcli/raw/libcliraw.h" 25#include "libcli/libcli.h" 26#include "torture/util.h" 27 28struct bitmapping { 29 const char *name; 30 uint32_t value; 31}; 32 33#define BIT_NAME(x) { #x, x } 34 35const static struct bitmapping fs_attr_bits[] = { 36 BIT_NAME(FS_ATTR_CASE_SENSITIVE_SEARCH), 37 BIT_NAME(FS_ATTR_CASE_PRESERVED_NAMES), 38 BIT_NAME(FS_ATTR_UNICODE_ON_DISK), 39 BIT_NAME(FS_ATTR_PERSISTANT_ACLS), 40 BIT_NAME(FS_ATTR_COMPRESSION), 41 BIT_NAME(FS_ATTR_QUOTAS), 42 BIT_NAME(FS_ATTR_SPARSE_FILES), 43 BIT_NAME(FS_ATTR_REPARSE_POINTS), 44 BIT_NAME(FS_ATTR_REMOTE_STORAGE), 45 BIT_NAME(FS_ATTR_LFN_SUPPORT), 46 BIT_NAME(FS_ATTR_IS_COMPRESSED), 47 BIT_NAME(FS_ATTR_OBJECT_IDS), 48 BIT_NAME(FS_ATTR_ENCRYPTION), 49 BIT_NAME(FS_ATTR_NAMED_STREAMS), 50 { NULL, 0 } 51}; 52 53const static struct bitmapping capability_bits[] = { 54 BIT_NAME(CAP_RAW_MODE), 55 BIT_NAME(CAP_MPX_MODE), 56 BIT_NAME(CAP_UNICODE), 57 BIT_NAME(CAP_LARGE_FILES), 58 BIT_NAME(CAP_NT_SMBS), 59 BIT_NAME(CAP_RPC_REMOTE_APIS), 60 BIT_NAME(CAP_STATUS32), 61 BIT_NAME(CAP_LEVEL_II_OPLOCKS), 62 BIT_NAME(CAP_LOCK_AND_READ), 63 BIT_NAME(CAP_NT_FIND), 64 BIT_NAME(CAP_DFS), 65 BIT_NAME(CAP_W2K_SMBS), 66 BIT_NAME(CAP_LARGE_READX), 67 BIT_NAME(CAP_LARGE_WRITEX), 68 BIT_NAME(CAP_UNIX), 69 BIT_NAME(CAP_EXTENDED_SECURITY), 70 { NULL, 0 } 71}; 72 73static void show_bits(const struct bitmapping *bm, uint32_t value) 74{ 75 int i; 76 for (i=0;bm[i].name;i++) { 77 if (value & bm[i].value) { 78 d_printf("\t%s\n", bm[i].name); 79 value &= ~bm[i].value; 80 } 81 } 82 if (value != 0) { 83 d_printf("\tunknown bits: 0x%08x\n", value); 84 } 85} 86 87 88/* 89 print out server properties 90 */ 91bool torture_test_properties(struct torture_context *torture, 92 struct smbcli_state *cli) 93{ 94 bool correct = true; 95 union smb_fsinfo fs; 96 NTSTATUS status; 97 98 d_printf("Capabilities: 0x%08x\n", cli->transport->negotiate.capabilities); 99 show_bits(capability_bits, cli->transport->negotiate.capabilities); 100 d_printf("\n"); 101 102 fs.attribute_info.level = RAW_QFS_ATTRIBUTE_INFO; 103 status = smb_raw_fsinfo(cli->tree, cli, &fs); 104 if (!NT_STATUS_IS_OK(status)) { 105 d_printf("qfsinfo failed - %s\n", nt_errstr(status)); 106 correct = false; 107 } else { 108 d_printf("Filesystem attributes: 0x%08x\n", 109 fs.attribute_info.out.fs_attr); 110 show_bits(fs_attr_bits, fs.attribute_info.out.fs_attr); 111 d_printf("max_file_component_length: %d\n", 112 fs.attribute_info.out.max_file_component_length); 113 d_printf("fstype: %s\n", fs.attribute_info.out.fs_type.s); 114 } 115 116 return correct; 117} 118 119 120