summaryrefslogtreecommitdiff
path: root/source4/torture/basic/properties.c
blob: 6a8e84cc2f414fd2f6155a5683532c5fd74a0810 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/* 
   Unix SMB/CIFS implementation.

   show server properties

   Copyright (C) Andrew Tridgell 2004
   
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.
   
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   
   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#include "includes.h"
#include "torture/torture.h"
#include "libcli/raw/libcliraw.h"
#include "libcli/libcli.h"
#include "torture/util.h"

struct bitmapping {
	const char *name;
	uint32_t value;
};

#define BIT_NAME(x) { #x, x }

const static struct bitmapping fs_attr_bits[] = {
	BIT_NAME(FS_ATTR_CASE_SENSITIVE_SEARCH),
	BIT_NAME(FS_ATTR_CASE_PRESERVED_NAMES),
	BIT_NAME(FS_ATTR_UNICODE_ON_DISK),
	BIT_NAME(FS_ATTR_PERSISTANT_ACLS),
	BIT_NAME(FS_ATTR_COMPRESSION),
	BIT_NAME(FS_ATTR_QUOTAS),
	BIT_NAME(FS_ATTR_SPARSE_FILES),
	BIT_NAME(FS_ATTR_REPARSE_POINTS),
	BIT_NAME(FS_ATTR_REMOTE_STORAGE),
	BIT_NAME(FS_ATTR_LFN_SUPPORT),
	BIT_NAME(FS_ATTR_IS_COMPRESSED),
	BIT_NAME(FS_ATTR_OBJECT_IDS),
	BIT_NAME(FS_ATTR_ENCRYPTION),
	BIT_NAME(FS_ATTR_NAMED_STREAMS),
	{ NULL, 0 }
};

const static struct bitmapping capability_bits[] = {
	BIT_NAME(CAP_RAW_MODE),
	BIT_NAME(CAP_MPX_MODE),
	BIT_NAME(CAP_UNICODE),
	BIT_NAME(CAP_LARGE_FILES),
	BIT_NAME(CAP_NT_SMBS),
	BIT_NAME(CAP_RPC_REMOTE_APIS),
	BIT_NAME(CAP_STATUS32),
	BIT_NAME(CAP_LEVEL_II_OPLOCKS),
	BIT_NAME(CAP_LOCK_AND_READ),
	BIT_NAME(CAP_NT_FIND),
	BIT_NAME(CAP_DFS),
	BIT_NAME(CAP_W2K_SMBS),
	BIT_NAME(CAP_LARGE_READX),
	BIT_NAME(CAP_LARGE_WRITEX),
	BIT_NAME(CAP_UNIX),
	BIT_NAME(CAP_EXTENDED_SECURITY),
	{ NULL, 0 }
};

static void show_bits(const struct bitmapping *bm, uint32_t value)
{
	int i;
	for (i=0;bm[i].name;i++) {
		if (value & bm[i].value) {
			d_printf("\t%s\n", bm[i].name);
			value &= ~bm[i].value;
		}
	}
	if (value != 0) {
		d_printf("\tunknown bits: 0x%08x\n", value);
	}
}


/*
  print out server properties
 */
BOOL torture_test_properties(struct torture_context *torture, 
							 struct smbcli_state *cli)
{
	BOOL correct = True;
	union smb_fsinfo fs;
	NTSTATUS status;
	
	d_printf("Capabilities: 0x%08x\n", cli->transport->negotiate.capabilities);
	show_bits(capability_bits, cli->transport->negotiate.capabilities);
	d_printf("\n");

	fs.attribute_info.level = RAW_QFS_ATTRIBUTE_INFO;
	status = smb_raw_fsinfo(cli->tree, cli, &fs);
	if (!NT_STATUS_IS_OK(status)) {
		d_printf("qfsinfo failed - %s\n", nt_errstr(status));
		correct = False;
	} else {
		d_printf("Filesystem attributes: 0x%08x\n", 
			 fs.attribute_info.out.fs_attr);
		show_bits(fs_attr_bits, fs.attribute_info.out.fs_attr);
		d_printf("max_file_component_length: %d\n", 
			 fs.attribute_info.out.max_file_component_length);
		d_printf("fstype: %s\n", fs.attribute_info.out.fs_type.s);
	}

	return correct;
}