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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
|
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright (c) 2012, 2017 by Delphix. All rights reserved.
#
.PARALLEL: $(SUBDIRS)
SUBDIRS = $(shell find ./* -maxdepth 0 -type d)
include $(SRC)/test/Makefile.com
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright (c) 2016, 2017 by Delphix. All rights reserved.
# Copyright 2021 Tintri by DDN, Inc. All rights reserved.
#
# The following file name generation rules allow the addition of tests,
# libraries and other miscellaneous files without having to specify them
# all individually in lower level Makefiles.
# Hammerhead: Fix find syntax — \( must be on same line as first -name,
# not closed empty \( \) on its own line.
PROGS = $(shell find . -maxdepth 1 -type f \( \
-name "*.ksh" -o \
-name "*.py" -o \
-name "*.sh" \) )
FILES = $(shell find . -maxdepth 1 -type f \( \
-name "*.Z" -o \
-name "*.bz2" -o \
-name "*.cfg" -o \
-name "*.d" -o \
-name "*.err" -o \
-name "*.fio" -o \
-name "*.out" -o \
-name "*.run" -o \
-name "*shlib" -o \
-name "*.txt" -o \
-name "*.zcp" \) )
CMDS = $(PROGS:%.sh=$(TARGETDIR)/%)
CMDS += $(PROGS:%.ksh=$(TARGETDIR)/%)
CMDS += $(PROGS:%.py=$(TARGETDIR)/%)
$(CMDS) : FILEMODE = 0555
LIBS = $(FILES:%=$(TARGETDIR)/%)
$(LIBS) : FILEMODE = 0444
all clean clobber:
install: $(CMDS) $(LIBS)
$(CMDS): $(TARGETDIR)
$(LIBS): $(TARGETDIR)
$(TARGETDIR):
$(INS.dir)
$(TARGETDIR)/%: %.sh
$(INS.rename)
$(TARGETDIR)/%: %.ksh
$(INS.rename)
$(TARGETDIR)/%: %.py
$(INS.pyfile)
$(TARGETDIR)/%: %
$(INS.file)
.PARALLEL: $(SUBDIRS)
SUBDIRS = $(shell find ./* -maxdepth 0 -type d ; exit 0)
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright 2021 Tintri by DDN, Inc. All rights reserved.
#
include $(SRC)/Makefile.master
# The python code in here required python3 or later.
PYSHEBANG = $(PYTHON3)
PYVER = $(PYTHON3_VERSION)
PYSUFFIX = $(PYTHON3_SUFFIX)
ROOTOPTPKG = $(ROOT)/opt/smbsrv-tests
TARGETDIR = $(ROOTOPTPKG)/bin
include $(SRC)/test/smbsrv-tests/Makefile.com
#!@PYTHON@
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright 2022 Tintri by DDN, Inc. All rights reserved.
#
#
# Run tests provided by smbtorture.
#
import subprocess
import argparse
import re
import fnmatch
from enum import Enum
from datetime import datetime
from tempfile import TemporaryFile
def stripped_file(f):
"""Strips trailing whitespace from lines in f"""
for line in f:
yield line.strip()
def parse_tests(f):
"""Returns test names from f, skipping commented lines"""
yield from (line for line in f
if line and not line.startswith('#'))
def matched_suites(m):
"""Gets all smbtorture tests that match pattern m"""
with TemporaryFile('w+') as tmp:
subprocess.run(['smbtorture', '--list'], stdout=tmp,
universal_newlines=True)
tmp.seek(0)
yield from (line for line in stripped_file(tmp)
if not line.startswith('smbtorture') and
m.match(line))
class TestResult(Enum):
PASS = 0
FAIL = 1
UNKNOWN = 2
SKIP = 3
KILLED = 4
TEST_ERR = 5
def __str__(self):
return self.name
def __len__(self):
return len(self.name)
class TestCase:
"""A particular instance of an smbtorture test"""
__slots__ = 'name', 'result'
def __init__(self, name):
self.name = name
self.result = TestResult.UNKNOWN
def __str__(self):
return f'{self.name} | {self.result}'
def run(self, rfd, wfd, timeout, cmd):
"""Run cmd, setting the last element to the test name, and setting result
based on rfd. Output is sent to wfd, and the test is killed based on timeout."""
def finish(self, start, wfd):
timediff = datetime.now() - start
wfd.write(f'END | {self} | {timediff}\n')
return self.result
starttime = datetime.now()
wfd.write(f'START | {self.name} | {starttime.time()}\n')
if self.result == TestResult.SKIP:
return finish(self, starttime, wfd)
cmd[-1] = self.name
try:
subprocess.run(cmd, universal_newlines=True, stdout=wfd,
stderr=subprocess.STDOUT, timeout=timeout)
for line in stripped_file(rfd):
if self.result != TestResult.UNKNOWN:
continue
elif line.startswith('failure:') or line.startswith('error:'):
self.result = TestResult.FAIL
elif line.startswith('success:'):
self.result = TestResult.PASS
elif line.startswith('skip:'):
self.result = TestResult.SKIP
elif line.startswith('INTERNAL ERROR:'):
self.result = TestResult.TEST_ERR
except subprocess.TimeoutExpired:
self.result = TestResult.KILLED
wfd.write('\nKilled due to timeout\n')
rfd.read()
return finish(self, starttime, wfd)
class TestSet:
"""Class to track state associated with the entire test set"""
__slots__ = 'excluded', 'tests'
def __init__(self, tests, skip_pat, verbose):
self.excluded = 0
def should_skip(self, test, pattern, verbose):
"""Returns whether test matches pattern, indicating it should be
skipped."""
if not pattern or not pattern.match(test):
return False
if verbose:
print(f'{test} matches exception pattern; marking as skipped')
self.excluded += 1
return True
self.tests = [TestCase(line) for line in tests
if not should_skip(self, line, skip_pat, verbose)]
def __iter__(self):
return iter(self.tests)
def __len__(self):
return len(self.tests)
def fnm2regex(fnm_pat):
"""Maps an fnmatch(7) pattern to a regex pattern that will match against
any suite that encapsulates the test name"""
rpat = fnmatch.translate(fnm_pat)
#
# If the pattern doesn't end with '*', we also need it to match against
# any sub-module; '*test' needs to also match 'smb2.test.first', but
# not 'smb2.test-other.second'.
#
if not fnm_pat.endswith('*'):
rpat += '|' + fnmatch.translate(fnm_pat + '.*')
return rpat
def verbose_fnm2regex(fnm_pat):
"""fnm2regex(), but prints the input and output patterns"""
ret_pat = fnm2regex(fnm_pat)
print(f'fnmatch: {fnm_pat} regex: {ret_pat}')
return ret_pat
def combine_patterns(iterable, verbose):
"""Combines patterns in an iterable into a single REGEX"""
if verbose > 1:
func = verbose_fnm2regex
else:
func = fnm2regex
fnmatch_pat = '|'.join(map(func, iterable))
if not fnmatch_pat:
pat = None;
else:
pat = re.compile(fnmatch_pat, flags=re.DEBUG if verbose > 2 else 0)
if verbose > 1:
print(f'final pattern: {pat.pattern if pat else "<None>"}')
return pat
class ArgumentFile(argparse.FileType):
"""argparse.FileType, but wrapped in stripped_file()"""
def __call__(self, *args, **kwargs):
return stripped_file(argparse.FileType.__call__(self, *args, **kwargs))
def main():
parser = argparse.ArgumentParser(description=
'Run a set of smbtorture tests, parsing the results.')
parser.add_argument('server', help='The target server')
parser.add_argument('share', help='The target share')
parser.add_argument('user', help='Username for smbtorture')
parser.add_argument('password', help='Password for user')
parser.add_argument('--except', '-e',
type=ArgumentFile('r'), metavar='EXCEPTIONS_FILE', dest='skip_list',
help='A file containing fnmatch(7) patterns of tests to skip')
parser.add_argument('--list', '-l',
type=ArgumentFile('r'), metavar='LIST_FILE',
help='A file containing the list of tests to run')
parser.add_argument('--match', '-m',
action='append', metavar='FNMATCH',
help='An fnmatch(7) pattern to select tests from smbtorture --list')
parser.add_argument('--output', '-o',
default='/tmp/lastrun.log', metavar='LOG_FILE',
help='Location to store full smbtorture output')
parser.add_argument('--seed', '-s',
type=int,
help='Seed passed to smbtorture')
parser.add_argument('--timeout', '-t',
default=120, type=float,
help='Timeout after which test is killed')
parser.add_argument('--verbose', '-v',
action='count', default=0,
help='Verbose output')
args = parser.parse_args()
if (args.match == None) == (args.list == None):
print('Must provide one of -l and -m')
return
server = args.server
share = args.share
user = args.user
pswd = args.password
fout = args.output
if args.match != None:
if args.verbose > 1:
print('Patterns to match:')
print(*args.match)
testgen = matched_suites(combine_patterns(args.match, args.verbose))
else:
testgen = args.list
if args.skip_list != None:
skip_pat = combine_patterns(parse_tests(args.skip_list), args.verbose)
if args.verbose > 1:
exc_pat = skip_pat.pattern if skip_pat else '<NONE>'
print(f'Exceptions pattern (in REGEX): {exc_pat}')
else:
skip_pat = None
tests = TestSet(parse_tests(testgen), skip_pat, args.verbose)
if args.verbose:
print('Tests to run:')
for test in tests:
print(test.name)
outw = open(fout, 'w', buffering=1)
outr = open(fout, 'r')
cmd = f'smbtorture //{server}/{share} -U{user}%{pswd}'.split()
if args.seed != None:
cmd.append(f'--seed={args.seed}')
cmd.append('TEST_HERE')
if args.verbose:
print('Command to run:')
print(*cmd)
results = {res: 0 for res in TestResult}
for test in tests:
print(test.name, end=': ', flush=True)
res = test.run(outr, outw, args.timeout, cmd)
results[res] += 1
print(res, flush=True)
print('\n\nRESULTS:')
print('=' * 22)
for res in TestResult:
print(f'{res}: {results[res]:>{20 - len(res)}}')
print('=' * 22)
print(f'Total: {len(tests):>15}')
print(f'Excluded: {tests.excluded:>12}')
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
print('Terminated by KeyboardInterrupt.')
#!/usr/bin/ksh
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright 2022 Tintri by DDN, Inc. All rights reserved.
#
# Run all the smbsrv-tests
export PATH="/usr/bin"
export SMBSRV_TESTS="/opt/smbsrv-tests"
export CFGFILE=$SMBSRV_TESTS/include/default.cfg
export OUTDIR=/var/tmp/test_results/smbsrv-tests
function fail
{
echo $1
exit ${2:-1}
}
while getopts c:o:t: c; do
case $c in
'c')
CFGFILE=$OPTARG
[[ -f $CFGFILE ]] || fail "Cannot read file: $CFGFILE"
;;
'o')
OUTDIR=$OPTARG
;;
't')
export TIMEOUT=$OPTARG
;;
esac
done
shift $((OPTIND - 1))
set -x
$SMBSRV_TESTS/tests/smbtorture/runst-smb2
$SMBSRV_TESTS/tests/smbtorture/runst-rpc
$SMBSRV_TESTS/tests/smb_sid/large_sids_lib
$SMBSRV_TESTS/tests/smb_sid/large_sids_kern
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright (c) 2012 by Delphix. All rights reserved.
# Copyright 2021 Tintri by DDN, Inc. All rights reserved.
#
include $(SRC)/Makefile.master
READMES = README
ROOTOPTPKG = $(ROOT)/opt/smbsrv-tests
FILES = $(READMES:%=$(ROOTOPTPKG)/%)
$(FILES) : FILEMODE = 0444
all: $(READMES)
install: $(ROOTOPTPKG) $(FILES)
clean clobber:
$(ROOTOPTPKG):
$(INS.dir)
$(ROOTOPTPKG)/%: %
$(INS.file)
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright 2021 Tintri by DDN, Inc. All rights reserved.
#
SMB Server Test Suite README
1. Building and installing the SMB Server Test Suite
2. Running the SMB Server Test Suite
3. Test Results
--------------------------------------------------------------------------------
1. Building and installing the SMB Server Test Suite
The SMB Server test suite uses external programs including:
smbtorture (and more to come)
which is installed via a package dependency on:
service/network/samba
Those are run by python and ksh wrappers found here.
To build, just do:
cd $SRC/test/smbsrv-tests
make install
To install the full suite, run:
pkg install pkg:/system/test/smbsrvtest
--------------------------------------------------------------------------------
2. Preparing the SMB Server Share
When workgroup mode is used, make sure the pam_smb_passwd module is
configured in /etc/pam.conf or in /etc/pam.d:
other password required pam_smb_passwd.so.1 nowarn
Add test user:
# useradd test
# smbadm enable-user test
# passwd test
If needed, add admin user as shown above, and add it to smb group:
# smbadm add-member -m admin@<hostname> administrators
Set smb default settings:
# sharectl set -p signing_required=false smb
# sharectl set -p signing_enabled=true smb
# svcadm restart network/smb/server
Create dataset(s):
Some smbtorture tests do rely on recordsize 4k.
# zfs create -o recordsize=4k -o casesensitivity=mixed -o nbmand=on \
<pool>/test
Set permissions:
# chmod A=everyone@:full_set:fd:allow /<path to mounpoint>/test
Create required snapshots (WPTS needs exactly 3 snapshots):
# zfs snapshot <pool>/test@a
# zfs snapshot <pool>/test@b
# zfs snapshot <pool>/test@c
Activate smb share:
# zfs set sharesmb=name=test <pool>/test
--------------------------------------------------------------------------------
3. Running the SMB Server Test Suite
The default configuration:
/opt/smbsrv-tests/include/default.cfg
runs tests against a server instance on "localhost",
using a share named "test" and user=test, pw=test
It's common to copy that default.cfg to something new
and modify the SMBT_... variables to specify different
host, share, user, etc.
To run all tests using the default configuration run:
/opt/smbsrv-tests/bin/smbsrvtests
To run all tests using a different configuration:
/opt/smbsrv-tests/bin/smbsrvtests -c config_file
You can also run individual tests found under:
/opt/smbsrv-tests/tests/*
For example:
/opt/smbsrv-tests/tests/smbtorture/runst-smb2
These take similar options (eg. -c config_file).
To run only a subset of the tests, you can pass match patterns
as additional arguments to the individual test, eg
/opt/smbsrv-tests/tests/smbtorture/runst-smb2 smb2.lease
--------------------------------------------------------------------------------
4. Test Results
While the SMB Server Test Suite is running, one informational line is
printed for each test, ending with one of:
PASS, FAIL, SKIP, KILLED, UNKNOWN
The test outputs can be found in:
/var/tmp/test_results/smbsrv-tests/
For example:
smbtor-smb2-20210317T162827.summary
smbtor-smb2-20210317T162827.log
The *.summary file is the same as what's shown while the test runs.
The *.log file is the detailed output from the test program(s).
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright 2021 Tintri by DDN, Inc. All rights reserved.
#
include $(SRC)/Makefile.master
ROOTOPTPKG = $(ROOT)/opt/smbsrv-tests
TARGETDIR = $(ROOTOPTPKG)/include
include $(SRC)/test/smbsrv-tests/Makefile.com
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright 2021 Tintri by DDN, Inc. All rights reserved.
#
# Sample configuration. Either edit this,
# provide your own with: smbsrvtest -c ...
export SMBT_HOST="localhost"
export SMBT_SHARE="test"
export SMBT_USER="test"
export SMBT_PASS="test"
export SMBTOR="/usr/bin/smbtorture"
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright 2021 Tintri by DDN, Inc. All rights reserved.
#
# smbtorture tests we choose to skip, either because the
# tests hang, or we disagree with the test, or whatever.
#
#Disabled by default
rpc.spoolss
###Unimplemented Services/Features
rpc.atsvc
rpc.autoidl
rpc.backupkey
rpc.bind
rpc.browser
rpc.clusapi
rpc.cracknames
rpc.drsuapi
rpc.drsuapi_wk28
rpc.dsgetinfo
rpc.echo
rpc.epmapper
rpc.frsapi
rpc.fsrvp
rpc.handles.drsuapi
rpc.initshutdown
rpc.iremotewinspool
rpc.mgmt
rpc.ntsvcs
rpc.oxidresolve
rpc.remact
rpc.scanner
rpc.unixinfo
rpc.witness
###Unimplemented functions
#GetDcAddress
rpc.dfs.netdfs.DcAddress
#FlushFtTable
rpc.dfs.netdfs.FtRoot
#ManagerInitialize
rpc.dfs.netdfs.ManagerInitialize
#QueryTrustedomainInfoByName
rpc.lsa.forest
#CreateAccount
rpc.lsa.privileges
#CreatedTrustedDomain, QueryInfoPolicy2 unimplemented
#EnumTrustedDomains(Ex) are stubbed
rpc.lsa.trusted
#GetAliasMembership
rpc.samba3.getaliasmembership
#Connect5
rpc.samr.accessmask.samr.Connect5
rpc.samr.accessmask.samr.LookupDomain
rpc.samr.accessmask.samr.OpenDomain
rpc.samr.EnumDomains
#Namesake function is unimplemented
rpc.srvsvc.srvsvc (admin access).NetCharDevQEnum
rpc.srvsvc.srvsvc (admin access).NetCharDevEnum
rpc.srvsvc.srvsvc (admin access).NetDiskEnum
rpc.srvsvc.srvsvc (admin access).NetTransportEnum
rpc.wkssvc.wkssvc.NetWkstaEnumUsers
rpc.wkssvc.wkssvc.NetrAddAlternateComputerName
rpc.wkssvc.wkssvc.NetrEnumerateComputerNames
rpc.wkssvc.wkssvc.NetrGetJoinInformation
rpc.wkssvc.wkssvc.NetrGetJoinableOus
rpc.wkssvc.wkssvc.NetrGetJoinableOus2
rpc.wkssvc.wkssvc.NetrJoinDomain
rpc.wkssvc.wkssvc.NetrLogonDomainNameAdd
rpc.wkssvc.wkssvc.NetrLogonDomainNameDel
rpc.wkssvc.wkssvc.NetrMessageBufferSend
rpc.wkssvc.wkssvc.NetrRemoveAlternateComputerName
rpc.wkssvc.wkssvc.NetrUnjoinDomain
rpc.wkssvc.wkssvc.NetrUseAdd
rpc.wkssvc.wkssvc.NetrUseDel
rpc.wkssvc.wkssvc.NetrUseEnum
rpc.wkssvc.wkssvc.NetrUseGetInfo
rpc.wkssvc.wkssvc.NetrValidateName
rpc.wkssvc.wkssvc.NetrValidateName2
rpc.wkssvc.wkssvc.NetrWkstaTransportAdd
rpc.wkssvc.wkssvc.NetrWkstaTransportDel
rpc.wkssvc.wkssvc.NetrWkstaUserGetInfo
rpc.wkssvc.wkssvc.NetrWorkstationStatisticsGet
###Benchmarks
rpc.bench-rpc
rpc.bench-schannel1
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright 2021 Tintri by DDN, Inc. All rights reserved.
# Copyright 2022 RackTop Systems, Inc.
#
#
# smbtorture tests we choose to skip, either because the
# tests hang, or we disagree with the test, or whatever.
#
smb2.aio_delay
smb2.bench-oplock
smb2.change_notify_disabled
smb2.check-sharemode
smb2.hold-sharemode
smb2.hold-oplock
smb2.maxfid
smb2.multichannel
smb2.notify.invalid-reauth
smb2.replay
smb2.scan
smb2.session.reauth*
smb2.timestamps
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright 2021 Tintri by DDN, Inc. All rights reserved.
#
include $(SRC)/test/smbsrv-tests/Makefile.com
include $(SRC)/test/Makefile.com
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
# Copyright 2022 Tintri by DDN, Inc. All rights reserved.
#
include $(SRC)/cmd/Makefile.cmd
include $(SRC)/test/Makefile.com
PROG = large_sids_lib large_sids_kern
KERN_OBJS = smb_sid.o
large_sids_lib : LDLIBS += -L$(ROOT)/usr/lib/smbsrv -lsmb
large_sids_lib : LDFLAGS += -R/usr/lib/smbsrv
large_sids_kern : LDLIBS64 += -lfakekernel
smb_sid.o : CPPFLAGS.first += -I $(SRC)/lib/libfakekernel/common -D_FAKE_KERNEL
ROOTOPTPKG = $(ROOT)/opt/smbsrv-tests
TESTDIR = $(ROOTOPTPKG)/tests/smb_sid
CMDS = $(PROG:%=$(TESTDIR)/%)
$(CMDS) : FILEMODE = 0555
CSTD = $(CSTD_GNU99)
all: $(PROG)
$(TESTDIR):
$(INS.dir)
$(TESTDIR)/%: %
$(INS.file)
%_lib: %.c
$(LINK.c) -o $@ $< $(LDLIBS)
$(POST_PROCESS)
%_kern: %.c $(KERN_OBJS)
$(LINK64.c) -o $@ $^ $(LDLIBS64)
$(POST_PROCESS)
smb_sid.c: $(SRC)/common/smbsrv/smb_sid.c
$(CP) $^ $@
%.o: %.c
$(COMPILE64.c) $<
install: all $(CMDS)
clobber: clean
-$(RM) $(PROG)
clean:
-$(RM) $(KERN_OBJS)
$(CMDS): $(TESTDIR) $(PROG)
/*
* This file and its contents are supplied under the terms of the
* Common Development and Distribution License ("CDDL"), version 1.0.
* You may only use this file in accordance with the terms of version
* 1.0 of the CDDL.
*
* A full copy of the text of the CDDL should have accompanied this
* source. A copy of the CDDL is also available via the Internet at
* http://www.illumos.org/license/CDDL.
*/
/*
* Copyright 2022 Tintri by DDN, Inc. All rights reserved.
*/
/*
* Test usr/src/common/smbsrv/smb_sid.c with large SIDs
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <smbsrv/smb_sid.h>
#include <limits.h>
void
test_sid(const char *sidstr, uint8_t idauth, const uint32_t *subauths,
size_t subauth_cnt)
{
char newstr[1024];
smb_sid_t *sid;
int i;
sid = smb_sid_fromstr(sidstr);
if (!smb_sid_isvalid(sid)) {
fprintf(stderr, "SID %s not valid: %p\n", sidstr, sid);
exit(1);
}
smb_sid_tostr(sid, newstr);
if (strncmp(sidstr, newstr, sizeof (newstr)) != 0) {
fprintf(stderr, "SID %s did not match decoded SID %s\n",
sidstr, newstr);
exit(5);
}
if (subauths == NULL) {
smb_sid_free(sid);
return;
}
if (sid->sid_authority[5] != idauth) {
fprintf(stderr, "Wrong SID authority %u (expected %u): %s\n",
sid->sid_authority, idauth, sidstr);
exit(2);
}
if (sid->sid_subauthcnt != subauth_cnt) {
fprintf(stderr, "Wrong subauthcnt %u (expected %u): %s\n",
sid->sid_subauthcnt, subauth_cnt, sidstr);
exit(3);
}
for (i = 0; i < subauth_cnt; i++) {
if (sid->sid_subauth[i] != subauths[i]) {
fprintf(stderr,
"Wrong subauthcnt %u (expected %u): %s\n",
sid->sid_subauthcnt, subauth_cnt, sidstr);
exit(4);
}
}
smb_sid_free(sid);
}
int
main(int argc, char *argv[])
{
char sid[1024];
uint32_t subauths[NT_SID_SUBAUTH_MAX];
size_t len = sizeof (sid);
int off = 0;
int i, idauth;
if (argc > 1) {
test_sid(argv[1], 0, NULL, 0);
goto out;
}
for (idauth = 2; idauth <= UINT8_MAX; idauth += 11) {
off = snprintf(&sid[0], len, "S-1-%u", idauth);
for (i = 0; i < NT_SID_SUBAUTH_MAX; i++) {
subauths[i] = arc4random();
off += snprintf(&sid[off], len - off,
"-%u", subauths[i]);
}
test_sid(sid, idauth, subauths, NT_SID_SUBAUTH_MAX);
}
out:
printf("success!\n");
return (0);
}
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright 2021 Tintri by DDN, Inc. All rights reserved.
#
include $(SRC)/Makefile.master
ROOTOPTPKG = $(ROOT)/opt/smbsrv-tests
TARGETDIR = $(ROOTOPTPKG)/tests/smbtorture
include $(SRC)/test/smbsrv-tests/Makefile.com
include $(SRC)/test/Makefile.com
#!/usr/bin/ksh
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright 2021 Tintri by DDN, Inc. All rights reserved.
#
export SMBSRV_TESTS="/opt/smbsrv-tests"
export SMBTOR="/usr/bin/smbtorture"
runsmbtor=$SMBSRV_TESTS/bin/run_smbtorture
excl_file=$SMBSRV_TESTS/include/smbtor-excl-rpc.txt
cfgfile=${CFGFILE:-$SMBSRV_TESTS/include/default.cfg}
outdir=${OUTDIR:-/var/tmp/test_results/smbsrv-tests}
function fail
{
echo $1
exit ${2:-1}
}
while getopts c:o:t: c; do
case $c in
'c')
cfgfile=$OPTARG
[[ -f $cfgfile ]] || fail "Cannot read file: $cfgfile"
;;
'o')
outdir=$OPTARG
;;
't')
timeout="-t $OPTARG"
;;
esac
done
shift $((OPTIND - 1))
. $cfgfile
export PATH="$(dirname $SMBTOR):$PATH"
mkdir -p $outdir
cd $outdir || fail "Could not cd to $outdir"
tstamp=$(date +'%Y%m%dT%H%M%S')
logfile=$outdir/smbtor-rpc-${tstamp}.log
outfile=$outdir/smbtor-rpc-${tstamp}.summary
if [[ -z "$timeout" && -n "$TIMEOUT" ]]; then
timeout="-t $TIMEOUT"
fi
# Non-option args taken as list of match patterns
if [ -z "$1" ] ; then
match="-m rpc"
fi
for m
do
match="$match -m $m"
done
#It would be nice to have a generic 'Can I connect to this server/share?' test
$SMBTOR -U "$SMBT_USER%${SMBT_PASS}" //$SMBT_HOST/IPC\$ \
rpc.wkssvc.wkssvc.NetWkstaGetInfo > /dev/null 2>&1 || \
fail "Cannot connect to //$SMBT_HOST/IPC\$"
echo "Running smbtorture/RPC tests with //$SMBT_HOST/IPC\$"
$runsmbtor $match -e $excl_file -o $logfile $timeout \
"$SMBT_HOST" "IPC\$" "$SMBT_USER" "${SMBT_PASS}" |
tee $outfile
exit 0
#!/usr/bin/ksh
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright 2021 Tintri by DDN, Inc. All rights reserved.
#
export SMBSRV_TESTS="/opt/smbsrv-tests"
export SMBTOR="/usr/bin/smbtorture"
runsmbtor=$SMBSRV_TESTS/bin/run_smbtorture
excl_file=$SMBSRV_TESTS/include/smbtor-excl-smb2.txt
cfgfile=${CFGFILE:-$SMBSRV_TESTS/include/default.cfg}
outdir=${OUTDIR:-/var/tmp/test_results/smbsrv-tests}
function fail
{
echo $1
exit ${2:-1}
}
while getopts c:o:t: c; do
case $c in
'c')
cfgfile=$OPTARG
[[ -f $cfgfile ]] || fail "Cannot read file: $cfgfile"
;;
'o')
outdir=$OPTARG
;;
't')
timeout="-t $OPTARG"
;;
esac
done
shift $((OPTIND - 1))
. $cfgfile
export PATH="$(dirname $SMBTOR):$PATH"
mkdir -p $outdir
cd $outdir || fail "Could not cd to $outdir"
tstamp=$(date +'%Y%m%dT%H%M%S')
logfile=$outdir/smbtor-smb2-${tstamp}.log
outfile=$outdir/smbtor-smb2-${tstamp}.summary
if [[ -z "$timeout" && -n "$TIMEOUT" ]]; then
timeout="-t $TIMEOUT"
fi
# Non-option args taken as list of match patterns
if [ -z "$1" ] ; then
match="-m smb2"
fi
for m
do
match="$match -m $m"
done
# Make sure we can connect, otherwise we'll report every test as failing.
$SMBTOR -U "$SMBT_USER%${SMBT_PASS}" //$SMBT_HOST/$SMBT_SHARE smb2.dir.find \
> /dev/null 2>&1 || \
fail "Cannot connect to //$SMBT_HOST/$SMBT_SHARE"
echo "Running smbtorture/smb2 tests with //$SMBT_HOST/$SMBT_SHARE"
$runsmbtor $match -e $excl_file -o $logfile $timeout \
"$SMBT_HOST" "$SMBT_SHARE" "$SMBT_USER" "${SMBT_PASS}" |
tee $outfile
exit 0
|