source3/client: Fix typo in help message displayed by default
[garming/samba-autobuild/.git] / source3 / script / tests / test_smbclient_s3.sh
1 #!/bin/sh
2
3 # this runs the file serving tests that are expected to pass with samba3
4
5 if [ $# -lt 13 ]; then
6 cat <<EOF
7 Usage: test_smbclient_s3.sh SERVER SERVER_IP DOMAIN USERNAME PASSWORD USERID LOCAL_PATH PREFIX SMBCLIENT WBINFO NET CONFIGURATION PROTOCOL
8 EOF
9 exit 1;
10 fi
11
12 SERVER="${1}"
13 SERVER_IP="${2}"
14 DOMAIN="${3}"
15 USERNAME="${4}"
16 PASSWORD="${5}"
17 USERID="${6}"
18 LOCAL_PATH="${7}"
19 PREFIX="${8}"
20 SMBCLIENT="${9}"
21 WBINFO="${10}"
22 NET="${11}"
23 CONFIGURATION="${12}"
24 PROTOCOL="${13}"
25 SMBCLIENT="$VALGRIND ${SMBCLIENT}"
26 WBINFO="$VALGRIND ${WBINFO}"
27 shift 13
28 RAWARGS="${CONFIGURATION} -m${PROTOCOL}"
29 ADDARGS="${RAWARGS} $*"
30
31 incdir=`dirname $0`/../../../testprogs/blackbox
32 . $incdir/subunit.sh
33
34 failed=0
35
36 # Test that a noninteractive smbclient does not prompt
37 test_noninteractive_no_prompt()
38 {
39     prompt="smb"
40
41     cmd='echo du | $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS 2>&1'
42     eval echo "$cmd"
43     out=`eval $cmd`
44
45     if [ $? != 0 ] ; then
46         echo "$out"
47         echo "command failed"
48         return 1
49     fi
50
51     echo "$out" | grep $prompt >/dev/null 2>&1
52
53     if [ $? = 0 ] ; then
54         # got a prompt .. fail
55         echo matched interactive prompt in non-interactive mode
56         return 1
57     fi
58
59     return 0
60 }
61
62 # Test that an interactive smbclient prompts to stdout
63 test_interactive_prompt_stdout()
64 {
65     prompt="smb"
66     tmpfile=$PREFIX/smbclient_interactive_prompt_commands
67
68     cat > $tmpfile <<EOF
69 du
70 quit
71 EOF
72
73     cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
74     eval echo "$cmd"
75     out=`eval $cmd`
76     ret=$?
77     rm -f $tmpfile
78
79     if [ $ret != 0 ] ; then
80         echo "$out"
81         echo "command failed"
82         return 1
83     fi
84
85     echo "$out" | grep $prompt >/dev/null 2>&1
86
87     if [ $? != 0 ] ; then
88         echo failed to match interactive prompt on stdout
89         return 1
90     fi
91
92     return 0
93 }
94
95 # Test creating a bad symlink and deleting it.
96 test_bad_symlink()
97 {
98     prompt="posix_unlink deleted file /newname"
99     tmpfile=$PREFIX/smbclient_bad_symlinks_commands
100
101     cat > $tmpfile <<EOF
102 posix
103 posix_unlink newname
104 symlink badname newname
105 posix_unlink newname
106 quit
107 EOF
108
109     cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
110     eval echo "$cmd"
111     out=`eval $cmd`
112     ret=$?
113     rm -f $tmpfile
114
115     if [ $ret != 0 ] ; then
116         echo "$out"
117         echo "failed create then delete bad symlink with error $ret"
118         return 1
119     fi
120
121     echo "$out" | grep "$prompt" >/dev/null 2>&1
122
123     ret=$?
124     if [ $ret != 0 ] ; then
125         echo "$out"
126         echo "failed create then delete bad symlink - grep failed with $ret"
127         return 1
128     fi
129
130     return 0
131 }
132
133 # Test creating a good symlink and deleting it by path.
134 test_good_symlink()
135 {
136     tmpfile=$PREFIX/smbclient.in.$$
137     slink_name="$LOCAL_PATH/slink"
138     slink_target="$LOCAL_PATH/slink_target"
139
140     touch $slink_target
141     ln -s $slink_target $slink_name
142     cat > $tmpfile <<EOF
143 del slink
144 quit
145 EOF
146
147     cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
148     eval echo "$cmd"
149     out=`eval $cmd`
150     ret=$?
151     rm -f $tmpfile
152
153     if [ $ret != 0 ] ; then
154         echo "$out"
155         echo "failed delete good symlink with error $ret"
156         rm $slink_target
157         rm $slink_name
158         return 1
159     fi
160
161     if [ ! -e $slink_target ] ; then
162         echo "failed delete good symlink - symlink target deleted !"
163         rm $slink_target
164         rm $slink_name
165         return 1
166     fi
167
168     if [ -e $slink_name ] ; then
169         echo "failed delete good symlink - symlink still exists"
170         rm $slink_target
171         rm $slink_name
172         return 1
173     fi
174
175     rm $slink_target
176     return 0
177 }
178
179 # Test writing into a read-only directory (logon as guest) fails.
180 test_read_only_dir()
181 {
182     prompt="NT_STATUS_ACCESS_DENIED making remote directory"
183     tmpfile=$PREFIX/smbclient.in.$$
184
185 ##
186 ## We can't do this as non-root. We always have rights to
187 ## create the directory.
188 ##
189     if [ "$USERID" != 0 ] ; then
190         echo "skipping test_read_only_dir as non-root"
191         return 0
192     fi
193
194 ##
195 ## We can't do this with an encrypted connection. No credentials
196 ## to set up the channel.
197 ##
198     if [ "$ADDARGS" = "-e" ] ; then
199         echo "skipping test_read_only_dir with encrypted connection"
200         return 0
201     fi
202
203     cat > $tmpfile <<EOF
204 mkdir a_test_dir
205 quit
206 EOF
207
208     cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT -U% "//$SERVER/$1" -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
209     eval echo "$cmd"
210     out=`eval $cmd`
211     ret=$?
212     rm -f $tmpfile
213
214     if [ $ret != 0 ] ; then
215         echo "$out"
216         echo "failed writing into read-only directory with error $ret"
217
218         return 1
219     fi
220
221     echo "$out" | grep "$prompt" >/dev/null 2>&1
222
223     ret=$?
224     if [ $ret != 0 ] ; then
225         echo "$out"
226         echo "failed writing into read-only directory - grep failed with $ret"
227         return 1
228     fi
229
230     return 0
231 }
232
233
234 # Test sending a message
235 test_message()
236 {
237     tmpfile=$PREFIX/message_in.$$
238
239     cat > $tmpfile <<EOF
240 Test message from pid $$
241 EOF
242
243     cmd='$SMBCLIENT "$@" -U$USERNAME%$PASSWORD -M $SERVER -p 139 $ADDARGS -n msgtest < $tmpfile 2>&1'
244     eval echo "$cmd"
245     out=`eval $cmd`
246     ret=$?
247
248     if [ $ret != 0 ] ; then
249         echo "$out"
250         echo "failed sending message to $SERVER with error $ret"
251         rm -f $tmpfile
252         return 1
253     fi
254
255     # The server writes this into a file message.msgtest, via message.%m to test the % sub code
256     cmd='$SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmpguest -p 139 $ADDARGS -c "get message.msgtest $PREFIX/message_out.$$" 2>&1'
257     eval echo "$cmd"
258     out=`eval $cmd`
259     ret=$?
260
261     if [ $ret != 0 ] ; then
262         echo "$out"
263         echo "failed getting sent message from $SERVER with error $ret"
264         return 1
265     fi
266
267     if [ cmp $PREFIX/message_out.$$ $tmpfile != 0 ] ; then
268         echo "failed comparison of message from $SERVER"
269         return 1
270     fi
271
272     return 0
273 }
274
275 # Test reading an owner-only file (logon as guest) fails.
276 test_owner_only_file()
277 {
278     prompt="NT_STATUS_ACCESS_DENIED opening remote file"
279     tmpfile=$PREFIX/smbclient.in.$$
280
281 ##
282 ## We can't do this as non-root. We always have rights to
283 ## read the file.
284 ##
285     if [ "$USERID" != 0 ] ; then
286         echo "skipping test_owner_only_file as non-root"
287         return 0
288     fi
289
290 ##
291 ## We can't do this with an encrypted connection. No credentials
292 ## to set up the channel.
293 ##
294     if [ "$ADDARGS" = "-e" ] ; then
295         echo "skipping test_owner_only_file with encrypted connection"
296         return 0
297     fi
298
299     cat > $tmpfile <<EOF
300 get unreadable_file
301 quit
302 EOF
303
304     cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U% //$SERVER/ro-tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
305     eval echo "$cmd"
306     out=`eval $cmd`
307     ret=$?
308     rm -f $tmpfile
309
310     if [ $ret != 0 ] ; then
311         echo "$out"
312         echo "failed reading owner-only file with error $ret"
313         return 1
314     fi
315
316     echo "$out" | grep "$prompt" >/dev/null 2>&1
317
318     ret=$?
319     if [ $ret != 0 ] ; then
320         echo "$out"
321         echo "failed reading owner-only file - grep failed with $ret"
322         return 1
323     fi
324
325     return 0
326 }
327
328 # Test accessing an msdfs path.
329 test_msdfs_link()
330 {
331     tmpfile=$PREFIX/smbclient.in.$$
332     prompt="  msdfs-target  "
333
334     cmd='$SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/msdfs-share -I $SERVER_IP $ADDARGS -m nt1 -c dir 2>&1'
335     out=`eval $cmd`
336     ret=$?
337
338     if [ $ret != 0 ] ; then
339         echo "$out"
340         echo "failed listing msfds-share\ with error $ret"
341         return 1
342     fi
343
344     cat > $tmpfile <<EOF
345 ls
346 cd \\msdfs-src1
347 ls msdfs-target
348 quit
349 EOF
350
351     cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/msdfs-share -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
352     eval echo "$cmd"
353     out=`eval $cmd`
354     ret=$?
355     rm -f $tmpfile
356
357     if [ $ret != 0 ] ; then
358         echo "$out"
359         echo "failed accessing \\msdfs-src1 link with error $ret"
360         return 1
361     fi
362
363     echo "$out" | grep "$prompt" >/dev/null 2>&1
364
365     ret=$?
366     if [ $ret != 0 ] ; then
367         echo "$out"
368         echo "failed listing \\msdfs-src1 - grep failed with $ret"
369         return 1
370     fi
371
372     cat > $tmpfile <<EOF
373 ls
374 cd \\deeppath\\msdfs-src2
375 ls msdfs-target
376 quit
377 EOF
378
379     cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/msdfs-share -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
380     eval echo "$cmd"
381     out=`eval $cmd`
382     ret=$?
383     rm -f $tmpfile
384
385     if [ $ret != 0 ] ; then
386         echo "$out"
387         echo "failed accessing \\deeppath\\msdfs-src2 link with error $ret"
388         return 1
389     fi
390
391     echo "$out" | grep "$prompt" >/dev/null 2>&1
392
393     ret=$?
394     if [ $ret != 0 ] ; then
395         echo "$out"
396         echo "failed listing \\deeppath\\msdfs-src2 - grep failed with $ret"
397         return 1
398     fi
399
400     return 0
401 }
402
403 # Archive bits are correctly set on file/dir creation and rename.
404 test_rename_archive_bit()
405 {
406     prompt_file="attributes: A (20)"
407     prompt_dir="attributes: D (10)"
408     tmpfile="$PREFIX/smbclient.in.$$"
409     filename="foo.$$"
410     filename_ren="bar.$$"
411     dirname="foodir.$$"
412     dirname_ren="bardir.$$"
413     filename_path="$PREFIX/$filename"
414     local_name1="$LOCAL_PATH/$filename"
415     local_name2="$LOCAL_PATH/$filename_ren"
416     local_dir_name1="$LOCAL_PATH/$dirname"
417     local_dir_name2="$LOCAL_PATH/$dirname_ren"
418
419     rm -f $filename_path
420     rm -f $local_name1
421     rm -f $local_name2
422
423 # Create a new file, ensure it has 'A' attributes.
424     touch $filename_path
425
426     cat > $tmpfile <<EOF
427 lcd $PREFIX
428 put $filename
429 allinfo $filename
430 quit
431 EOF
432
433     cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
434     eval echo "$cmd"
435     out=`eval $cmd`
436     ret=$?
437     rm -f $tmpfile
438
439     if [ $ret != 0 ] ; then
440         echo "$out"
441         echo "failed creating file $filename with error $ret"
442         return 1
443     fi
444
445     echo "$out" | grep "$prompt_file" >/dev/null 2>&1
446
447     ret=$?
448
449     rm -f $filename_path
450     rm -f $local_name1
451     rm -f $local_name2
452
453     if [ $ret != 0 ] ; then
454         echo "$out"
455         echo "Attributes incorrect on new file $ret"
456         return 1
457     fi
458
459 # Now check if we remove 'A' and rename, the A comes back.
460     touch $filename_path
461
462     cat > $tmpfile <<EOF
463 lcd $PREFIX
464 put $filename
465 setmode $filename -a
466 ren $filename $filename_ren
467 allinfo $filename_ren
468 quit
469 EOF
470
471     cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
472     eval echo "$cmd"
473     out=`eval $cmd`
474     ret=$?
475     rm -f $tmpfile
476
477     if [ $ret != 0 ] ; then
478         echo "$out"
479         echo "failed creating file and renaming $filename with error $ret"
480         return 1
481     fi
482
483     echo "$out" | grep "$prompt_file" >/dev/null 2>&1
484
485     ret=$?
486
487     rm -f $filename_path
488     rm -f $local_name1
489     rm -f $local_name2
490
491     if [ $ret != 0 ] ; then
492         echo "$out"
493         echo "Attributes incorrect on renamed file $ret"
494         return 1
495     fi
496
497     rm -rf $local_dir_name1
498     rm -rf $local_dir_name2
499
500 # Create a new directory, ensure it has 'D' but not 'A' attributes.
501
502     cat > $tmpfile <<EOF
503 mkdir $dirname
504 allinfo $dirname
505 quit
506 EOF
507
508     cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
509     eval echo "$cmd"
510     out=`eval $cmd`
511     ret=$?
512     rm -f $tmpfile
513
514     if [ $ret != 0 ] ; then
515         echo "$out"
516         echo "failed creating directory $dirname with error $ret"
517         return 1
518     fi
519
520     echo "$out" | grep "$prompt_dir" >/dev/null 2>&1
521
522     ret=$?
523
524     rm -rf $local_dir_name1
525     rm -rf $local_dir_name2
526
527     if [ $ret != 0 ] ; then
528         echo "$out"
529         echo "Attributes incorrect on new directory $ret"
530         return 1
531     fi
532
533 # Now check if we rename, we still only have 'D' attributes
534
535     cat > $tmpfile <<EOF
536 mkdir $dirname
537 ren $dirname $dirname_ren
538 allinfo $dirname_ren
539 quit
540 EOF
541
542     cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
543     eval echo "$cmd"
544     out=`eval $cmd`
545     ret=$?
546     rm -f $tmpfile
547
548     if [ $ret != 0 ] ; then
549         echo "$out"
550         echo "failed creating directory $dirname and renaming with error $ret"
551         return 1
552     fi
553
554     echo "$out" | grep "$prompt_dir" >/dev/null 2>&1
555
556     ret=$?
557
558     rm -f $local_name1
559     rm -f $local_name2
560
561     if [ $ret != 0 ] ; then
562         echo "$out"
563         echo "Attributes incorrect on renamed directory $ret"
564         return 1
565     fi
566
567     return 0
568 }
569
570 # Test authenticating using the winbind ccache
571 test_ccache_access()
572 {
573     $WBINFO --ccache-save="${USERNAME}%${PASSWORD}"
574     ret=$?
575
576     if [ $ret != 0 ] ; then
577         echo "wbinfo failed to store creds in cache (user='${USERNAME}', pass='${PASSWORD}')"
578         return 1
579     fi
580
581     $SMBCLIENT //$SERVER_IP/tmp -C -U "${USERNAME}" $ADDARGS -c quit 2>&1
582     ret=$?
583
584     if [ $ret != 0 ] ; then
585         echo "smbclient failed to use cached credentials"
586         return 1
587     fi
588
589     $WBINFO --ccache-save="${USERNAME}%GarBage"
590     ret=$?
591
592     if [ $ret != 0 ] ; then
593         echo "wbinfo failed to store creds in cache (user='${USERNAME}', pass='GarBage')"
594         return 1
595     fi
596
597     $SMBCLIENT //$SERVER_IP/tmp -C -U "${USERNAME}" $ADDARGS -c quit 2>&1
598     ret=$?
599
600     if [ $ret -eq 0 ] ; then
601         echo "smbclient succeeded with wrong cached credentials"
602         return 1
603     fi
604
605     $WBINFO --logoff
606 }
607
608 # Test authenticating using the winbind ccache
609 test_auth_file()
610 {
611     tmpfile=$PREFIX/smbclient.in.$$
612     cat > $tmpfile <<EOF
613 username=${USERNAME}
614 password=${PASSWORD}
615 domain=${DOMAIN}
616 EOF
617     $SMBCLIENT //$SERVER_IP/tmp --authentication-file=$tmpfile $ADDARGS -c quit 2>&1
618     ret=$?
619     rm $tmpfile
620
621     if [ $ret != 0 ] ; then
622         echo "smbclient failed to use auth file"
623         return 1
624     fi
625
626     cat > $tmpfile <<EOF
627 username=${USERNAME}
628 password=xxxx
629 domain=${DOMAIN}
630 EOF
631     $SMBCLIENT //$SERVER_IP/tmp --authentication-file=$tmpfile $ADDARGS -c quit 2>&1
632     ret=$?
633     rm $tmpfile
634
635     if [ $ret -eq 0 ] ; then
636         echo "smbclient succeeded with wrong auth file credentials"
637         return 1
638     fi
639 }
640
641 # Test doing a directory listing with backup privilege.
642 test_backup_privilege_list()
643 {
644     tmpfile=$PREFIX/smbclient_backup_privilege_list
645
646     # If we don't have a DOMAIN component to the username, add it.
647     echo "$USERNAME" | grep '\\' 2>&1
648     ret=$?
649     if [ $ret != 0 ] ; then
650         priv_username="$DOMAIN\\$USERNAME"
651     else
652         priv_username=$USERNAME
653     fi
654
655     $NET sam rights grant $priv_username SeBackupPrivilege 2>&1
656     ret=$?
657     if [ $ret != 0 ] ; then
658         echo "Failed to add SeBackupPrivilege to user $priv_username - $ret"
659         return 1
660     fi
661
662     cat > $tmpfile <<EOF
663 backup
664 ls
665 quit
666 EOF
667
668     cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
669     eval echo "$cmd"
670     out=`eval $cmd`
671     ret=$?
672     rm -f $tmpfile
673
674     if [ $ret != 0 ] ; then
675         echo "$out"
676         echo "failed backup privilege list $ret"
677         return 1
678     fi
679
680 # Now remove all privileges from this SID.
681     $NET sam rights revoke $priv_username SeBackupPrivilege 2>&1
682     ret=$?
683     if [ $ret != 0 ] ; then
684         echo "failed to remove SeBackupPrivilege from user $priv_username - $ret"
685         return 1
686     fi
687 }
688
689 # Test accessing an share with bad names (won't convert).
690 test_bad_names()
691 {
692     # First with SMB1
693     cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/badname-tmp -I $SERVER_IP $ADDARGS -mNT1 -c ls 2>&1'
694     eval echo "$cmd"
695     out=`eval $cmd`
696     ret=$?
697
698     if [ $ret != 0 ] ; then
699         echo "$out"
700         echo "failed accessing badname-tmp (SMB1) with error $ret"
701         return 1
702     fi
703
704     echo "$out" | wc -l 2>&1 | grep 5
705     ret=$?
706     if [ $ret != 0 ] ; then
707         echo "$out"
708         echo "failed listing \\badname-tmp - grep of number of lines (1) failed with $ret"
709         return 1
710     fi
711
712     echo "$out" | grep '^  \. *D'
713     ret=$?
714     if [ $ret != 0 ] ; then
715         echo "$out"
716         echo "failed listing \\badname-tmp - grep (1) failed with $ret"
717         return 1
718     fi
719
720     echo "$out" | grep '^  \.\. *D'
721     ret=$?
722     if [ $ret != 0 ] ; then
723         echo "$out"
724         echo "failed listing \\badname-tmp - grep (2) failed with $ret"
725         return 1
726     fi
727
728     echo "$out" | grep '^  blank.txt *N'
729     ret=$?
730     if [ $ret != 0 ] ; then
731         echo "$out"
732         echo "failed listing \\badname-tmp - grep (3) failed with $ret"
733         return 1
734     fi
735
736     echo "$out" | grep '^ *$'
737     ret=$?
738     if [ $ret != 0 ] ; then
739         echo "$out"
740         echo "failed listing \\badname-tmp - grep (4) failed with $ret"
741         return 1
742     fi
743
744     echo "$out" | grep 'blocks of size.*blocks available'
745     ret=$?
746     if [ $ret != 0 ] ; then
747         echo "$out"
748         echo "failed listing \\badname-tmp - grep (5) failed with $ret"
749         return 1
750     fi
751
752     # Now check again with -mSMB3
753     cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/badname-tmp -I $SERVER_IP $ADDARGS -mSMB3 -c ls 2>&1'
754     eval echo "$cmd"
755     out=`eval $cmd`
756     ret=$?
757
758     if [ $ret != 0 ] ; then
759         echo "$out"
760         echo "failed accessing badname-tmp (SMB3) with error $ret"
761         return 1
762     fi
763
764     echo "$out" | wc -l 2>&1 | grep 5
765     ret=$?
766     if [ $ret != 0 ] ; then
767         echo "$out"
768         echo "failed listing \\badname-tmp - SMB3 grep of number of lines (1) failed with $ret"
769         return 1
770     fi
771
772     echo "$out" | grep '^  \. *D'
773     ret=$?
774     if [ $ret != 0 ] ; then
775         echo "$out"
776         echo "failed listing \\badname-tmp - SMB3 grep (1) failed with $ret"
777         return 1
778     fi
779
780     echo "$out" | grep '^  \.\. *D'
781     ret=$?
782     if [ $ret != 0 ] ; then
783         echo "$out"
784         echo "failed listing \\badname-tmp - SMB3 grep (2) failed with $ret"
785         return 1
786     fi
787
788     echo "$out" | grep '^  blank.txt *N'
789     ret=$?
790     if [ $ret != 0 ] ; then
791         echo "$out"
792         echo "failed listing \\badname-tmp - SMB3 grep (3) failed with $ret"
793         return 1
794     fi
795
796     echo "$out" | grep '^ *$'
797     ret=$?
798     if [ $ret != 0 ] ; then
799         echo "$out"
800         echo "failed listing \\badname-tmp - SMB3 grep (4) failed with $ret"
801         return 1
802     fi
803
804     echo "$out" | grep 'blocks of size.*blocks available'
805     ret=$?
806     if [ $ret != 0 ] ; then
807         echo "$out"
808         echo "failed listing \\badname-tmp - SMB3 grep (5) failed with $ret"
809         return 1
810     fi
811 }
812
813 # Test accessing an share with a name that must be mangled - with acl_xattrs.
814 # We know foo:bar gets mangled to FF4GBY~Q with the default name-mangling algorithm (hash2).
815 test_mangled_names()
816 {
817     tmpfile=$PREFIX/smbclient_interactive_prompt_commands
818     cat > $tmpfile <<EOF
819 ls
820 cd FF4GBY~Q
821 ls
822 quit
823 EOF
824     cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/manglenames_share -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
825     eval echo "$cmd"
826     out=`eval $cmd`
827     ret=$?
828     rm -f $tmpfile
829
830     if [ $ret != 0 ] ; then
831         echo "$out"
832         echo "failed accessing manglenames_share with error $ret"
833         return 1
834     fi
835
836     echo "$out" | grep 'NT_STATUS'
837     ret=$?
838     if [ $ret == 0 ] ; then
839         echo "$out"
840         echo "failed - NT_STATUS_XXXX listing \\manglenames_share\\FF4GBY~Q"
841         return 1
842     fi
843 }
844
845 # Test using scopy to copy a file on the server.
846 test_scopy()
847 {
848     tmpfile=$PREFIX/smbclient_interactive_prompt_commands
849     scopy_file=$PREFIX/scopy_file
850
851     rm -f $scopy_file
852     cat > $tmpfile <<EOF
853 put ${SMBCLIENT}
854 scopy smbclient scopy_file
855 lcd ${PREFIX}
856 get scopy_file
857 del smbclient
858 del scopy_file
859 quit
860 EOF
861     # First SMB3
862     cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS -mSMB3 < $tmpfile 2>&1'
863     eval echo "$cmd"
864     out=`eval $cmd`
865     ret=$?
866     out1=`md5sum ${SMBCLIENT} | sed -e 's/ .*//'`
867     out2=`md5sum ${scopy_file} | sed -e 's/ .*//'`
868     rm -f $tmpfile
869     rm -f $scopy_file
870
871     if [ $ret != 0 ] ; then
872         echo "$out"
873         echo "failed scopy test (1) with output $ret"
874         return 1
875     fi
876
877     if [ $out1 != $out2 ] ; then
878         echo "$out1 $out2"
879         echo "failed md5sum (1)"
880         return 1
881     fi
882
883 #
884 # Now do again using SMB1
885 # to force client-side fallback.
886 #
887
888     cat > $tmpfile <<EOF
889 put ${SMBCLIENT}
890 scopy smbclient scopy_file
891 lcd ${PREFIX}
892 get scopy_file
893 del smbclient
894 del scopy_file
895 quit
896 EOF
897     cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS -mNT1 < $tmpfile 2>&1'
898     eval echo "$cmd"
899     out=`eval $cmd`
900     ret=$?
901     out1=`md5sum ${SMBCLIENT} | sed -e 's/ .*//'`
902     out2=`md5sum ${scopy_file} | sed -e 's/ .*//'`
903     rm -f $tmpfile
904     rm -f $scopy_file
905
906     if [ $ret != 0 ] ; then
907         echo "$out"
908         echo "failed scopy test (2) with output $ret"
909         return 1
910     fi
911
912     if [ $out1 != $out2 ] ; then
913         echo "$out1 $out2"
914         echo "failed md5sum (2)"
915         return 1
916     fi
917 }
918
919 # Test creating a stream on the root of the share directory filname - :foobar
920 test_toplevel_stream()
921 {
922     tmpfile=$PREFIX/smbclient_interactive_prompt_commands
923     cat > $tmpfile <<EOF
924 put ${PREFIX}/smbclient_interactive_prompt_commands :foobar
925 allinfo \\
926 setmode \\ -a
927 quit
928 EOF
929     # Only with SMB3???
930     cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS -mSMB3 < $tmpfile 2>&1'
931     eval echo "$cmd"
932     out=`eval $cmd`
933     ret=$?
934     rm -f $tmpfile
935
936     if [ $ret != 0 ] ; then
937         echo "$out"
938         echo "failed creating toplevel stream :foobar with error $ret"
939         return 1
940     fi
941
942     echo "$out" | grep '^stream:.*:foobar'
943     ret=$?
944     if [ $ret != 0 ] ; then
945         echo "$out"
946         echo "failed creating toplevel stream :foobar"
947         return 1
948     fi
949 }
950
951 # Test wide links are restricted.
952 test_widelinks()
953 {
954     tmpfile=$PREFIX/smbclient_interactive_prompt_commands
955     cat > $tmpfile <<EOF
956 cd dot
957 ls
958 quit
959 EOF
960     cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/widelinks_share -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
961     eval echo "$cmd"
962     out=`eval $cmd`
963     ret=$?
964     rm -f $tmpfile
965
966     if [ $ret != 0 ] ; then
967         echo "$out"
968         echo "failed accessing widelinks_share with error $ret"
969         return 1
970     fi
971
972     echo "$out" | grep 'NT_STATUS'
973     ret=$?
974     if [ $ret == 0 ] ; then
975         echo "$out"
976         echo "failed - NT_STATUS_XXXX listing \\widelinks_share\\dot"
977         return 1
978     fi
979
980     cat > $tmpfile <<EOF
981 allinfo source
982 quit
983 EOF
984     cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/widelinks_share -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
985     eval echo "$cmd"
986     out=`eval $cmd`
987     ret=$?
988     rm -f $tmpfile
989
990     if [ $ret != 0 ] ; then
991         echo "$out"
992         echo "failed accessing widelinks_share with error $ret"
993         return 1
994     fi
995
996 # This should fail with NT_STATUS_ACCESS_DENIED
997     echo "$out" | grep 'NT_STATUS_ACCESS_DENIED'
998     ret=$?
999     if [ $ret != 0 ] ; then
1000         echo "$out"
1001         echo "failed - should get NT_STATUS_ACCESS_DENIED listing \\widelinks_share\\source"
1002         return 1
1003     fi
1004 }
1005
1006 # Test creating then deleting a stream file doesn't leave a lost-XXXXX directory.
1007 test_streams_depot_delete()
1008 {
1009     tmpfile=$PREFIX/smbclient_interactive_prompt_commands
1010     rm -rf "$LOCAL_PATH/lost-*"
1011
1012     cat > $tmpfile <<EOF
1013 put ${PREFIX}/smbclient_interactive_prompt_commands foo:bar
1014 del foo
1015 ls lost*
1016 quit
1017 EOF
1018     # This only works with SMB3?
1019     cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS -mSMB3 < $tmpfile 2>&1'
1020     eval echo "$cmd"
1021     out=`eval $cmd`
1022     ret=$?
1023     rm -f $tmpfile
1024
1025     if [ $ret != 0 ] ; then
1026         echo "$out"
1027         echo "failed creating then deleting foo:bar with error $ret"
1028         return 1
1029     fi
1030
1031     echo "$out" | grep 'NT_STATUS_NO_SUCH_FILE listing \\lost\*'
1032     ret=$?
1033     if [ $ret != 0 ] ; then
1034         echo "$out"
1035         echo "deleting foo:bar left lost-XXX directory"
1036         rm -rf "$LOCAL_PATH/lost-*"
1037         return 1
1038     fi
1039 }
1040
1041 # Test follow symlinks can't access symlinks
1042 test_nosymlinks()
1043 {
1044 # Setup test dirs.
1045     local_test_dir="$LOCAL_PATH/nosymlinks/test"
1046     local_slink_name="$local_test_dir/source"
1047     local_slink_target="$local_test_dir/nosymlink_target_file"
1048
1049     share_test_dir="test"
1050     share_foo_dir="$share_test_dir/foo"
1051     share_foobar_dir="$share_test_dir/foo/bar"
1052     share_target_file="$share_test_dir/foo/bar/testfile"
1053
1054     rm -rf $local_test_dir
1055
1056     local_nosymlink_target_file="nosymlink_target_file"
1057     echo "$local_slink_target" > $local_nosymlink_target_file
1058
1059     local_foobar_target_file="testfile"
1060     echo "$share_target_file" > $local_foobar_target_file
1061
1062     tmpfile=$PREFIX/smbclient_interactive_prompt_commands
1063     cat > $tmpfile <<EOF
1064 mkdir $share_test_dir
1065 mkdir $share_foo_dir
1066 mkdir $share_foobar_dir
1067 cd /$share_test_dir
1068 put $local_nosymlink_target_file
1069 cd /$share_foobar_dir
1070 put $local_foobar_target_file
1071 quit
1072 EOF
1073
1074     cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/nosymlinks -I $SERVER_IP $LOCAL_ADDARGS < $tmpfile 2>&1'
1075     eval echo "$cmd"
1076     out=`eval $cmd`
1077     ret=$?
1078     rm -f $tmpfile
1079     rm -f $local_nosymlink_target_file
1080     rm -f $local_foobar_target_file
1081
1082     if [ $ret -ne 0 ] ; then
1083        echo "$out"
1084        echo "failed accessing local_symlinks with error $ret"
1085        false
1086        return
1087     fi
1088
1089     echo "$out" | grep 'NT_STATUS_'
1090     ret=$?
1091     if [ $ret -eq 0 ] ; then
1092        echo "$out"
1093        echo "failed - got an NT_STATUS error"
1094        false
1095        return
1096     fi
1097
1098 # Create the symlink locally
1099     ln -s $local_slink_target $local_slink_name
1100
1101 # Getting a file through a symlink name should fail.
1102     tmpfile=$PREFIX/smbclient_interactive_prompt_commands
1103     cat > $tmpfile <<EOF
1104 get test\\source
1105 quit
1106 EOF
1107     cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/nosymlinks -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1108     eval echo "$cmd"
1109     out=`eval $cmd`
1110     ret=$?
1111     rm -f $tmpfile
1112
1113     if [ $ret -ne 0 ] ; then
1114        echo "$out"
1115        echo "failed accessing nosymlinks with error $ret"
1116        return 1
1117     fi
1118
1119     echo "$out" | grep 'NT_STATUS_ACCESS_DENIED'
1120     ret=$?
1121     if [ $ret -ne 0 ] ; then
1122        echo "$out"
1123        echo "failed - should get NT_STATUS_ACCESS_DENIED getting \\nosymlinks\\source"
1124        return 1
1125     fi
1126
1127 # But we should be able to create and delete directories.
1128     cat > $tmpfile <<EOF
1129 mkdir test\\a
1130 mkdir test\\a\\b
1131 quit
1132 EOF
1133     cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/nosymlinks -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1134     eval echo "$cmd"
1135     out=`eval $cmd`
1136     ret=$?
1137     rm -f $tmpfile
1138
1139     if [ $ret -ne 0 ] ; then
1140        echo "$out"
1141        echo "failed accessing nosymlinks with error $ret"
1142        return 1
1143     fi
1144
1145     echo "$out" | grep 'NT_STATUS'
1146     ret=$?
1147     if [ $ret -eq 0 ] ; then
1148         echo "$out"
1149         echo "failed - NT_STATUS_XXXX doing mkdir a; mkdir a\\b on \\nosymlinks"
1150         return 1
1151     fi
1152
1153 # Ensure regular file/directory access also works.
1154     cat > $tmpfile <<EOF
1155 cd test\\foo\\bar
1156 ls
1157 get testfile -
1158 quit
1159 EOF
1160     cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/nosymlinks -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1161     eval echo "$cmd"
1162     out=`eval $cmd`
1163     ret=$?
1164     rm -f $tmpfile
1165
1166     if [ $ret -ne 0 ] ; then
1167        echo "$out"
1168        echo "failed accessing nosymlinks with error $ret"
1169        return 1
1170     fi
1171
1172     echo "$out" | grep 'NT_STATUS'
1173     ret=$?
1174     if [ $ret -eq 0 ] ; then
1175        echo "$out"
1176        echo "failed - NT_STATUS_XXXX doing cd foo\\bar; get testfile on \\nosymlinks"
1177        return 1
1178     fi
1179
1180 # CLEANUP
1181     rm -f $local_slink_name
1182
1183     cat > $tmpfile <<EOF
1184 deltree test
1185 quit
1186 EOF
1187     cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/nosymlinks -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1188     eval echo "$cmd"
1189     out=`eval $cmd`
1190     ret=$?
1191     rm -f $tmpfile
1192
1193     if [ $ret -ne 0 ] ; then
1194        echo "$out"
1195        echo "failed accessing nosymlinks with error $ret"
1196        return 1
1197     fi
1198
1199     echo "$out" | grep 'NT_STATUS'
1200     ret=$?
1201     if [ $ret -eq 0 ] ; then
1202        echo "$out"
1203        echo "failed - NT_STATUS_XXXX doing cd foo\\bar; get testfile on \\nosymlinks"
1204        return 1
1205     fi
1206 }
1207
1208 # Test we can follow normal symlinks.
1209 # Bug: https://bugzilla.samba.org/show_bug.cgi?id=12860
1210 # Note - this needs to be tested over SMB3, not SMB1.
1211
1212 test_local_symlinks()
1213 {
1214 # Setup test dirs.
1215     LOCAL_RAWARGS="${CONFIGURATION} -mSMB3"
1216     LOCAL_ADDARGS="${LOCAL_RAWARGS} $*"
1217
1218     share_test_dir="test"
1219     share_slink_target_dir="$share_test_dir/dir1"
1220
1221     local_test_dir="$LOCAL_PATH/local_symlinks/$share_test_dir"
1222     local_slink_name="$local_test_dir/sym_name"
1223     local_slink_target_dir="$local_test_dir/dir1"
1224
1225     rm -rf $local_test_dir
1226
1227 # Create the initial directories
1228     tmpfile=$PREFIX/smbclient_interactive_prompt_commands
1229     cat > $tmpfile <<EOF
1230 mkdir $share_test_dir
1231 mkdir $share_slink_target_dir
1232 quit
1233 EOF
1234
1235     cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/local_symlinks -I $SERVER_IP $LOCAL_ADDARGS < $tmpfile 2>&1'
1236     eval echo "$cmd"
1237     out=`eval $cmd`
1238     ret=$?
1239     rm -f $tmpfile
1240
1241     if [ $ret -ne 0 ] ; then
1242        echo "$out"
1243        echo "failed accessing local_symlinks with error $ret"
1244        false
1245        return
1246     fi
1247
1248     echo "$out" | grep 'NT_STATUS_'
1249     ret=$?
1250     if [ $ret -eq 0 ] ; then
1251        echo "$out"
1252        echo "failed - got an NT_STATUS error"
1253        false
1254        return
1255     fi
1256
1257 # Create the symlink locally
1258     ln -s $local_slink_target_dir $local_slink_name
1259     ret=$?
1260     if [ $ret -ne 0 ] ; then
1261        echo "$out"
1262        echo "failed - unable to create symlink"
1263        ls -la $local_test_dir
1264        false
1265        return
1266     fi
1267
1268 # Can we cd into the symlink name and ls ?
1269     tmpfile=$PREFIX/smbclient_interactive_prompt_commands
1270     cat > $tmpfile <<EOF
1271 cd $share_test_dir\\sym_name
1272 ls
1273 quit
1274 EOF
1275     cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/local_symlinks -I $SERVER_IP $LOCAL_ADDARGS < $tmpfile 2>&1'
1276     eval echo "$cmd"
1277     out=`eval $cmd`
1278     ret=$?
1279     rm -f $tmpfile
1280
1281     if [ $ret -ne 0 ] ; then
1282        echo "$out"
1283        echo "failed accessing local_symlinks with error $ret"
1284        false
1285        return
1286     fi
1287
1288     echo "$out" | grep 'NT_STATUS_'
1289     ret=$?
1290     if [ $ret -eq 0 ] ; then
1291        echo "$out"
1292        echo "failed - got an NT_STATUS error"
1293        false
1294        return
1295     fi
1296
1297 # CLEANUP
1298     rm -f $local_slink_name
1299
1300     tmpfile=$PREFIX/smbclient_interactive_prompt_commands
1301     cat > $tmpfile <<EOF
1302 deltree $share_test_dir
1303 quit
1304 EOF
1305     cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/local_symlinks -I $SERVER_IP $LOCAL_ADDARGS < $tmpfile 2>&1'
1306     eval echo "$cmd"
1307     out=`eval $cmd`
1308     ret=$?
1309     rm -f $tmpfile
1310
1311     if [ $ret -ne 0 ] ; then
1312        echo "$out"
1313        echo "failed accessing local_symlinks with error $ret"
1314        false
1315        return
1316     fi
1317
1318     echo "$out" | grep 'NT_STATUS_'
1319     ret=$?
1320     if [ $ret -eq 0 ] ; then
1321        echo "$out"
1322        echo "failed - got an NT_STATUS error"
1323        false
1324        return
1325     fi
1326 }
1327
1328 # Test smbclient deltree command
1329 test_deltree()
1330 {
1331     tmpfile=$PREFIX/smbclient_interactive_prompt_commands
1332     deltree_dir=$PREFIX/deltree_dir
1333
1334     rm -rf $deltree_dir
1335     cat > $tmpfile <<EOF
1336 mkdir deltree_dir
1337 mkdir deltree_dir/foo
1338 mkdir deltree_dir/foo/bar
1339 put ${SMBCLIENT} deltree_dir/foo/bar/client
1340 deltree deltree_dir
1341 quit
1342 EOF
1343     cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1344     eval echo "$cmd"
1345     out=`eval $cmd`
1346     ret=$?
1347
1348     if [ $ret != 0 ] ; then
1349         echo "$out"
1350         echo "failed deltree test with output $ret"
1351         false
1352         return
1353     fi
1354
1355     echo "$out" | grep 'NT_STATUS_'
1356     ret=$?
1357     if [ $ret -eq 0 ] ; then
1358        echo "$out"
1359        echo "failed - got an NT_STATUS error"
1360        false
1361        return
1362     fi
1363
1364     if [ -d $deltree_dir ] ; then
1365         echo "deltree did not delete everything"
1366         false
1367         return
1368     fi
1369 }
1370
1371 # Test smbclient setmode command
1372 test_setmode()
1373 {
1374     tmpfile=$PREFIX/smbclient_interactive_prompt_commands
1375
1376     cat > $tmpfile <<EOF
1377 del test_setmode
1378 put ${SMBCLIENT} test_setmode
1379 setmode test_setmode +r +s +h +a
1380 allinfo test_setmode
1381 setmode test_setmode -rsha
1382 allinfo test_setmode
1383 del test_setmode
1384 quit
1385 EOF
1386     cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1387     eval echo "$cmd"
1388     out=`eval $cmd`
1389     ret=$?
1390
1391     if [ $ret != 0 ] ; then
1392         echo "$out"
1393         echo "failed setmode test with output $ret"
1394         false
1395         return
1396     fi
1397
1398     echo "$out" | grep 'attributes: RHSA'
1399     ret=$?
1400     if [ $ret -ne 0 ] ; then
1401        echo "$out"
1402        echo "failed - should get attributes: RHSA"
1403        false
1404        return
1405     fi
1406
1407     echo "$out" | grep 'attributes:  (80)'
1408     ret=$?
1409     if [ $ret -ne 0 ] ; then
1410        echo "$out"
1411        echo "failed - should also get attributes:  (80)"
1412        false
1413        return
1414     fi
1415 }
1416
1417
1418 test_server_os_message()
1419 {
1420     tmpfile=$PREFIX/smbclient_interactive_prompt_commands
1421     cat > $tmpfile <<EOF
1422 ls
1423 quit
1424 EOF
1425     cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1426     eval echo "$cmd"
1427     out=`eval $cmd`
1428     ret=$?
1429     rm -f $tmpfile
1430
1431     if [ $ret -ne 0 ] ; then
1432        echo "$out"
1433        echo "failed to connect error $ret"
1434        return 1
1435     fi
1436
1437     echo "$out" | grep 'Try "help" to get a list of possible commands.'
1438     ret=$?
1439     if [ $ret -ne 0 ] ; then
1440        echo "$out"
1441        echo 'failed - should get: Try "help" to get a list of possible commands.'
1442        return 1
1443     fi
1444
1445     return 0
1446 }
1447
1448 LOGDIR_PREFIX=test_smbclient_s3
1449
1450 # possibly remove old logdirs:
1451
1452 for OLDDIR in $(find ${PREFIX} -type d -name "${LOGDIR_PREFIX}_*") ;  do
1453         echo "removing old directory ${OLDDIR}"
1454         rm -rf ${OLDDIR}
1455 done
1456
1457 LOGDIR=$(mktemp -d ${PREFIX}/${LOGDIR_PREFIX}_XXXXXX)
1458
1459
1460 testit "smbclient -L $SERVER_IP" $SMBCLIENT -L $SERVER_IP -N -p 139 ${RAWARGS} || failed=`expr $failed + 1`
1461 testit "smbclient -L $SERVER -I $SERVER_IP" $SMBCLIENT -L $SERVER -I $SERVER_IP -N -p 139 ${RAWARGS} -c quit || failed=`expr $failed + 1`
1462
1463 testit "noninteractive smbclient does not prompt" \
1464     test_noninteractive_no_prompt || \
1465     failed=`expr $failed + 1`
1466
1467 testit "noninteractive smbclient -l does not prompt" \
1468    test_noninteractive_no_prompt -l $LOGDIR || \
1469     failed=`expr $failed + 1`
1470
1471 testit "interactive smbclient prompts on stdout" \
1472    test_interactive_prompt_stdout || \
1473     failed=`expr $failed + 1`
1474
1475 testit "interactive smbclient -l prompts on stdout" \
1476    test_interactive_prompt_stdout -l $LOGDIR || \
1477     failed=`expr $failed + 1`
1478
1479 testit "creating a bad symlink and deleting it" \
1480    test_bad_symlink || \
1481    failed=`expr $failed + 1`
1482
1483 testit "creating a good symlink and deleting it by path" \
1484    test_good_symlink || \
1485    failed=`expr $failed + 1`
1486
1487 testit "writing into a read-only directory fails" \
1488    test_read_only_dir ro-tmp || \
1489    failed=`expr $failed + 1`
1490
1491 testit "writing into a read-only share fails" \
1492    test_read_only_dir valid-users-tmp || \
1493    failed=`expr $failed + 1`
1494
1495 testit "Reading a owner-only file fails" \
1496    test_owner_only_file || \
1497    failed=`expr $failed + 1`
1498
1499 testit "Accessing an MS-DFS link" \
1500    test_msdfs_link || \
1501    failed=`expr $failed + 1`
1502
1503 testit "Ensure archive bit is set correctly on file/dir rename" \
1504     test_rename_archive_bit || \
1505     failed=`expr $failed + 1`
1506
1507 testit "ccache access works for smbclient" \
1508     test_ccache_access || \
1509     failed=`expr $failed + 1`
1510
1511 testit "sending a message to the remote server" \
1512     test_message || \
1513     failed=`expr $failed + 1`
1514
1515 testit "using an authentication file" \
1516     test_auth_file || \
1517     failed=`expr $failed + 1`
1518
1519 testit "list with backup privilege" \
1520     test_backup_privilege_list || \
1521     failed=`expr $failed + 1`
1522
1523 testit "list a share with bad names (won't convert)" \
1524     test_bad_names || \
1525     failed=`expr $failed + 1`
1526
1527 testit "list a share with a mangled name + acl_xattr object" \
1528     test_mangled_names || \
1529     failed=`expr $failed + 1`
1530
1531 testit "server-side file copy" \
1532     test_scopy || \
1533     failed=`expr $failed + 1`
1534
1535 testit "creating a :stream at root of share" \
1536     test_toplevel_stream || \
1537     failed=`expr $failed + 1`
1538
1539 testit "Ensure widelinks are restricted" \
1540     test_widelinks || \
1541     failed=`expr $failed + 1`
1542
1543 testit "streams_depot can delete correctly" \
1544     test_streams_depot_delete || \
1545     failed=`expr $failed + 1`
1546
1547 testit "follow symlinks = no" \
1548     test_nosymlinks || \
1549     failed=`expr $failed + 1`
1550
1551 testit "follow local symlinks" \
1552     test_local_symlinks || \
1553     failed=`expr $failed + 1`
1554
1555 testit "smbclient deltree command" \
1556     test_deltree || \
1557     failed=`expr $failed + 1`
1558
1559 testit "server os message" \
1560     test_server_os_message || \
1561     failed=`expr $failed + 1`
1562
1563 testit "setmode test" \
1564     test_setmode || \
1565     failed=`expr $failed + 1`
1566
1567 testit "rm -rf $LOGDIR" \
1568     rm -rf $LOGDIR || \
1569     failed=`expr $failed + 1`
1570
1571 testok $0 $failed