tests: Get a file through an absolute symlink within a subdirectory
[Samba.git] / source3 / script / tests / test_smbclient_s3.sh
blobe4b05b12dfaf46883226694003c2f2ef20707235
1 #!/bin/sh
3 # this runs the file serving tests that are expected to pass with samba3
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
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} $*"
31 incdir=$(dirname $0)/../../../testprogs/blackbox
32 . $incdir/subunit.sh
34 failed=0
36 # Do not let deprecated option warnings muck this up
37 SAMBA_DEPRECATED_SUPPRESS=1
38 export SAMBA_DEPRECATED_SUPPRESS
40 # Test that a noninteractive smbclient does not prompt
41 test_noninteractive_no_prompt()
43 prompt="smb"
45 cmd='echo du | $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS 2>&1'
46 eval echo "$cmd"
47 out=$(eval $cmd)
49 if [ $? != 0 ]; then
50 echo "$out"
51 echo "command failed"
52 return 1
55 echo "$out" | grep $prompt >/dev/null 2>&1
57 if [ $? = 0 ]; then
58 # got a prompt .. fail
59 echo matched interactive prompt in non-interactive mode
60 return 1
63 return 0
66 # Test that an interactive smbclient prompts to stdout
67 test_interactive_prompt_stdout()
69 prompt="smb"
70 tmpfile=$PREFIX/smbclient_interactive_prompt_commands
72 cat >$tmpfile <<EOF
74 quit
75 EOF
77 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
78 eval echo "$cmd"
79 out=$(eval $cmd)
80 ret=$?
81 rm -f $tmpfile
83 if [ $ret != 0 ]; then
84 echo "$out"
85 echo "command failed"
86 return 1
89 echo "$out" | grep $prompt >/dev/null 2>&1
91 if [ $? != 0 ]; then
92 echo failed to match interactive prompt on stdout
93 return 1
96 return 0
99 # Test creating a bad symlink and deleting it.
100 test_bad_symlink()
102 prompt="posix_unlink deleted file /newname"
103 tmpfile=$PREFIX/smbclient_bad_symlinks_commands
105 cat >$tmpfile <<EOF
106 posix
107 posix_unlink newname
108 symlink badname newname
109 posix_unlink newname
110 quit
113 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
114 eval echo "$cmd"
115 out=$(eval $cmd)
116 ret=$?
117 rm -f $tmpfile
119 if [ $ret != 0 ]; then
120 echo "$out"
121 echo "failed create then delete bad symlink with error $ret"
122 return 1
125 echo "$out" | grep "$prompt" >/dev/null 2>&1
127 ret=$?
128 if [ $ret != 0 ]; then
129 echo "$out"
130 echo "failed create then delete bad symlink - grep failed with $ret"
131 return 1
134 return 0
137 # Test creating a good symlink and deleting it by path.
138 test_good_symlink()
140 tmpfile=$PREFIX/smbclient.in.$$
141 slink_name="$LOCAL_PATH/slink"
142 slink_target="$LOCAL_PATH/slink_target"
144 touch $slink_target
145 ln -s $slink_target $slink_name
146 cat >$tmpfile <<EOF
147 del slink
148 quit
151 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
152 eval echo "$cmd"
153 out=$(eval $cmd)
154 ret=$?
155 rm -f $tmpfile
157 if [ $ret != 0 ]; then
158 echo "$out"
159 echo "failed delete good symlink with error $ret"
160 rm $slink_target
161 rm $slink_name
162 return 1
165 if [ ! -e $slink_target ]; then
166 echo "failed delete good symlink - symlink target deleted !"
167 rm $slink_target
168 rm $slink_name
169 return 1
172 if [ -e $slink_name ]; then
173 echo "failed delete good symlink - symlink still exists"
174 rm $slink_target
175 rm $slink_name
176 return 1
179 rm $slink_target
180 return 0
183 # Test writing into a read-only directory (logon as guest) fails.
184 test_read_only_dir()
186 prompt="NT_STATUS_ACCESS_DENIED making remote directory"
187 tmpfile=$PREFIX/smbclient.in.$$
190 ## We can't do this as non-root. We always have rights to
191 ## create the directory.
193 if [ "$USERID" != 0 ]; then
194 echo "skipping test_read_only_dir as non-root"
195 return 0
199 ## We can't do this with an encrypted connection. No credentials
200 ## to set up the channel.
202 if [ "$ADDARGS" = "-e" ]; then
203 echo "skipping test_read_only_dir with encrypted connection"
204 return 0
207 cat >$tmpfile <<EOF
208 mkdir a_test_dir
209 quit
212 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT -U% "//$SERVER/$1" -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
213 eval echo "$cmd"
214 out=$(eval $cmd)
215 ret=$?
216 rm -f $tmpfile
218 if [ $ret != 0 ]; then
219 echo "$out"
220 echo "failed writing into read-only directory with error $ret"
222 return 1
225 echo "$out" | grep "$prompt" >/dev/null 2>&1
227 ret=$?
228 if [ $ret != 0 ]; then
229 echo "$out"
230 echo "failed writing into read-only directory - grep failed with $ret"
231 return 1
234 return 0
237 # Test sending a message
238 test_message()
240 tmpfile=$PREFIX/message_in.$$
242 cat >$tmpfile <<EOF
243 Test message from pid $$
246 cmd='$SMBCLIENT "$@" -U$USERNAME%$PASSWORD -M $SERVER -p 139 $ADDARGS -n msgtest < $tmpfile 2>&1'
247 eval echo "$cmd"
248 out=$(eval $cmd)
249 ret=$?
251 if [ $ret != 0 ]; then
252 echo "$out"
253 echo "failed sending message to $SERVER with error $ret"
254 rm -f $tmpfile
255 return 1
258 # The server writes this into a file message.msgtest, via message.%m to test the % sub code
259 cmd='$SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmpguest -p 139 $ADDARGS -c "get message.msgtest $PREFIX/message_out.$$" 2>&1'
260 eval echo "$cmd"
261 out=$(eval $cmd)
262 ret=$?
264 if [ $ret != 0 ]; then
265 echo "$out"
266 echo "failed getting sent message from $SERVER with error $ret"
267 return 1
270 if cmp $PREFIX/message_out.$$ $tmpfile; then
271 echo "failed comparison of message from $SERVER"
272 return 1
275 return 0
278 # Test reading an owner-only file (logon as guest) fails.
279 test_owner_only_file()
281 prompt="NT_STATUS_ACCESS_DENIED opening remote file"
282 tmpfile=$PREFIX/smbclient.in.$$
285 ## We can't do this as non-root. We always have rights to
286 ## read the file.
288 if [ "$USERID" != 0 ]; then
289 echo "skipping test_owner_only_file as non-root"
290 return 0
294 ## We can't do this with an encrypted connection. No credentials
295 ## to set up the channel.
297 if [ "$ADDARGS" = "-e" ]; then
298 echo "skipping test_owner_only_file with encrypted connection"
299 return 0
302 cat >$tmpfile <<EOF
303 get unreadable_file
304 quit
307 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U% //$SERVER/ro-tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
308 eval echo "$cmd"
309 out=$(eval $cmd)
310 ret=$?
311 rm -f $tmpfile
313 if [ $ret != 0 ]; then
314 echo "$out"
315 echo "failed reading owner-only file with error $ret"
316 return 1
319 echo "$out" | grep "$prompt" >/dev/null 2>&1
321 ret=$?
322 if [ $ret != 0 ]; then
323 echo "$out"
324 echo "failed reading owner-only file - grep failed with $ret"
325 return 1
328 return 0
331 # Test accessing an msdfs path.
332 test_msdfs_link()
334 tmpfile=$PREFIX/smbclient.in.$$
335 prompt=" msdfs-target "
337 cmd='$SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/msdfs-share -I $SERVER_IP $ADDARGS -m $PROTOCOL -c dir 2>&1'
338 out=$(eval $cmd)
339 ret=$?
341 if [ $ret != 0 ]; then
342 echo "$out"
343 echo "failed listing msfds-share\ with error $ret"
344 return 1
347 cat >$tmpfile <<EOF
349 cd \\msdfs-src1
350 ls msdfs-target
351 quit
354 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/msdfs-share -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
355 eval echo "$cmd"
356 out=$(eval $cmd)
357 ret=$?
358 rm -f $tmpfile
360 if [ $ret != 0 ]; then
361 echo "$out"
362 echo "failed accessing \\msdfs-src1 link with error $ret"
363 return 1
366 echo "$out" | grep "$prompt" >/dev/null 2>&1
368 ret=$?
369 if [ $ret != 0 ]; then
370 echo "$out"
371 echo "failed listing \\msdfs-src1 - grep failed with $ret"
372 return 1
375 cat >$tmpfile <<EOF
377 cd \\deeppath\\msdfs-src2
378 ls msdfs-target
379 quit
382 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/msdfs-share -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
383 eval echo "$cmd"
384 out=$(eval $cmd)
385 ret=$?
386 rm -f $tmpfile
388 if [ $ret != 0 ]; then
389 echo "$out"
390 echo "failed accessing \\deeppath\\msdfs-src2 link with error $ret"
391 return 1
394 echo "$out" | grep "$prompt" >/dev/null 2>&1
396 ret=$?
397 if [ $ret != 0 ]; then
398 echo "$out"
399 echo "failed listing \\deeppath\\msdfs-src2 - grep failed with $ret"
400 return 1
403 return 0
406 # Test recursive listing across msdfs links
407 test_msdfs_recursive_dir()
409 tmpfile=$PREFIX/smbclient.in.$$
411 cat >$tmpfile <<EOF
412 recurse
414 quit
417 cmd='$SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/msdfs-share -I $SERVER_IP $ADDARGS -m $PROTOCOL < $tmpfile 2>&1'
418 out=$(eval $cmd)
419 ret="$?"
421 if [ "$ret" -ne 0 ]; then
422 echo "$out"
423 echo "failed listing msfds-share\ with error $ret"
424 return 1
427 echo "$out" | grep 'NT_STATUS_OBJECT_PATH_NOT_FOUND listing \widelinks\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\*' > /dev/null 2>&1
429 ret="$?"
430 if [ "$ret" -ne 0 ]; then
431 echo "$out"
432 echo "Listing \\msdfs-share recursively did not properly end in symlink recursion"
435 return 0
438 # Test doing a normal file rename on an msdfs path.
439 test_msdfs_rename()
441 tmpfile="$PREFIX/smbclient.in.$$"
442 filename_src="src.$$"
443 filename_dst="dest.$$"
444 filename_src_path="$PREFIX/$filename_src"
445 rm -f "$filename_src_path"
446 touch "$filename_src_path"
449 # Use both non-force and force rename to
450 # ensure we test both codepaths inside libsmb.
452 cat >$tmpfile <<EOF
453 lcd $PREFIX
454 put $filename_src
455 ren $filename_src $filename_dst -f
456 ren $filename_dst $filename_src
457 del $filename_src
458 quit
461 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/msdfs-share -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
462 eval echo "$cmd"
463 out=$(eval $cmd)
464 ret=$?
465 rm -f "$tmpfile"
466 rm -f "$filename_src_path"
468 if [ $ret != 0 ]; then
469 echo "$out"
470 echo "failed renaming $filename_src $filename_dst with error $ret"
471 return 1
474 echo "$out" | grep "NT_STATUS" >/dev/null 2>&1
476 ret="$?"
477 if [ "$ret" -eq 0 ]; then
478 echo "$out"
479 echo "renaming $filename_src $filename_dst got NT_STATUS_ error"
480 return 1
482 return 0
485 # Test doing a normal file hardlink on an msdfs path.
486 test_msdfs_hardlink()
488 tmpfile="$PREFIX/smbclient.in.$$"
489 filename_src="src.$$"
490 filename_dst="dest.$$"
491 filename_src_path="$PREFIX/$filename_src"
492 rm -f "$filename_src_path"
493 touch "$filename_src_path"
495 cat >$tmpfile <<EOF
496 lcd $PREFIX
497 put $filename_src
498 hardlink $filename_src $filename_dst
499 del $filename_src
500 del $filename_dst
501 quit
504 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/msdfs-share -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
505 eval echo "$cmd"
506 out=$(eval $cmd)
507 ret=$?
508 rm -f "$tmpfile"
509 rm -f "$filename_src_path"
511 if [ $ret != 0 ]; then
512 echo "$out"
513 echo "failed hardlink $filename_src $filename_dst with error $ret"
514 return 1
517 echo "$out" | grep "NT_STATUS" >/dev/null 2>&1
519 ret="$?"
520 if [ "$ret" -eq 0 ]; then
521 echo "$out"
522 echo "hardlink $filename_src $filename_dst got NT_STATUS_ error"
523 return 1
525 return 0
528 test_msdfs_del()
530 tmpfile="$PREFIX/smbclient.in.$$"
531 filename_src="src.$$"
532 filename_src_path="$PREFIX/$filename_src"
533 rm -f "$filename_src_path"
534 touch "$filename_src_path"
536 cat > $tmpfile <<EOF
537 lcd $PREFIX
538 cd dfshop1
539 cd dfshop2
540 put $filename_src
541 del $filename_src
542 quit
545 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/msdfs-share -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
546 eval echo "$cmd"
547 out=`eval $cmd`
548 ret=$?
549 rm -f "$tmpfile"
550 rm -f "$filename_src_path"
552 if [ $ret != 0 ] ; then
553 echo "$out"
554 echo "failed deleting $filename_src with error $ret"
555 return 1
558 echo "$out" | grep "NT_STATUS" >/dev/null 2>&1
560 ret="$?"
561 if [ "$ret" -eq 0 ] ; then
562 echo "$out"
563 echo "del $filename_src NT_STATUS_ error"
564 return 1
566 return 0
569 test_msdfs_deltree()
571 tmpfile="$PREFIX/smbclient.in.$$"
572 dirname_src="foodir.$$"
573 filename_src="src.$$"
574 filename_src_path="$PREFIX/$filename_src"
575 dirname_src_path="$PREFIX/$dirname"
576 rm -f "$filename_src_path"
577 touch "$filename_src_path"
579 cat > $tmpfile <<EOF
580 lcd $PREFIX
581 cd dfshop1
582 cd dfshop2
583 mkdir $dirname_src
584 cd $dirname_src
585 put $filename_src
586 cd ..
587 deltree $dirname_src
588 quit
591 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/msdfs-share -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
592 eval echo "$cmd"
593 out=`eval $cmd`
594 ret=$?
595 rm -f "$tmpfile"
596 rm -f "$filename_src_path"
597 rm -f "$dirname_src_path"
599 if [ $ret != 0 ] ; then
600 echo "$out"
601 echo "deltree failed deleting dir $dirname_src with error $ret"
602 return 1
605 echo "$out" | grep "NT_STATUS" >/dev/null 2>&1
607 ret="$?"
608 if [ "$ret" -eq 0 ] ; then
609 echo "$out"
610 echo "deltree $dirname_src NT_STATUS_ error"
611 return 1
613 return 0
616 # Archive bits are correctly set on file/dir creation and rename.
617 test_rename_archive_bit()
619 prompt_file="attributes: A (20)"
620 prompt_dir="attributes: D (10)"
621 tmpfile="$PREFIX/smbclient.in.$$"
622 filename="foo.$$"
623 filename_ren="bar.$$"
624 dirname="foodir.$$"
625 dirname_ren="bardir.$$"
626 filename_path="$PREFIX/$filename"
627 local_name1="$LOCAL_PATH/$filename"
628 local_name2="$LOCAL_PATH/$filename_ren"
629 local_dir_name1="$LOCAL_PATH/$dirname"
630 local_dir_name2="$LOCAL_PATH/$dirname_ren"
632 rm -f $filename_path
633 rm -f $local_name1
634 rm -f $local_name2
636 # Create a new file, ensure it has 'A' attributes.
637 touch $filename_path
639 cat >$tmpfile <<EOF
640 lcd $PREFIX
641 put $filename
642 allinfo $filename
643 quit
646 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
647 eval echo "$cmd"
648 out=$(eval $cmd)
649 ret=$?
650 rm -f $tmpfile
652 if [ $ret != 0 ]; then
653 echo "$out"
654 echo "failed creating file $filename with error $ret"
655 return 1
658 echo "$out" | grep "$prompt_file" >/dev/null 2>&1
660 ret=$?
662 rm -f $filename_path
663 rm -f $local_name1
664 rm -f $local_name2
666 if [ $ret != 0 ]; then
667 echo "$out"
668 echo "Attributes incorrect on new file $ret"
669 return 1
672 # Now check if we remove 'A' and rename, the A comes back.
673 touch $filename_path
675 cat >$tmpfile <<EOF
676 lcd $PREFIX
677 put $filename
678 setmode $filename -a
679 ren $filename $filename_ren
680 allinfo $filename_ren
681 quit
684 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
685 eval echo "$cmd"
686 out=$(eval $cmd)
687 ret=$?
688 rm -f $tmpfile
690 if [ $ret != 0 ]; then
691 echo "$out"
692 echo "failed creating file and renaming $filename with error $ret"
693 return 1
696 echo "$out" | grep "$prompt_file" >/dev/null 2>&1
698 ret=$?
700 rm -f $filename_path
701 rm -f $local_name1
702 rm -f $local_name2
704 if [ $ret != 0 ]; then
705 echo "$out"
706 echo "Attributes incorrect on renamed file $ret"
707 return 1
710 rm -rf $local_dir_name1
711 rm -rf $local_dir_name2
713 # Create a new directory, ensure it has 'D' but not 'A' attributes.
715 cat >$tmpfile <<EOF
716 mkdir $dirname
717 allinfo $dirname
718 quit
721 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
722 eval echo "$cmd"
723 out=$(eval $cmd)
724 ret=$?
725 rm -f $tmpfile
727 if [ $ret != 0 ]; then
728 echo "$out"
729 echo "failed creating directory $dirname with error $ret"
730 return 1
733 echo "$out" | grep "$prompt_dir" >/dev/null 2>&1
735 ret=$?
737 rm -rf $local_dir_name1
738 rm -rf $local_dir_name2
740 if [ $ret != 0 ]; then
741 echo "$out"
742 echo "Attributes incorrect on new directory $ret"
743 return 1
746 # Now check if we rename, we still only have 'D' attributes
748 cat >$tmpfile <<EOF
749 mkdir $dirname
750 ren $dirname $dirname_ren
751 allinfo $dirname_ren
752 quit
755 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
756 eval echo "$cmd"
757 out=$(eval $cmd)
758 ret=$?
759 rm -f $tmpfile
761 if [ $ret != 0 ]; then
762 echo "$out"
763 echo "failed creating directory $dirname and renaming with error $ret"
764 return 1
767 echo "$out" | grep "$prompt_dir" >/dev/null 2>&1
769 ret=$?
771 rm -f $local_name1
772 rm -f $local_name2
774 if [ $ret != 0 ]; then
775 echo "$out"
776 echo "Attributes incorrect on renamed directory $ret"
777 return 1
780 return 0
783 # Test authenticating using the winbind ccache
784 test_ccache_access()
786 $WBINFO --ccache-save="${USERNAME}%${PASSWORD}"
787 ret=$?
789 if [ $ret != 0 ]; then
790 echo "wbinfo failed to store creds in cache (user='${USERNAME}', pass='${PASSWORD}')"
791 return 1
794 $SMBCLIENT //$SERVER_IP/tmp --use-winbind-ccache -U "${USERNAME}" $ADDARGS -c quit 2>&1
795 ret=$?
797 if [ $ret != 0 ]; then
798 echo "smbclient failed to use cached credentials"
799 return 1
802 $WBINFO --ccache-save="${USERNAME}%GarBage"
803 ret=$?
805 if [ $ret != 0 ]; then
806 echo "wbinfo failed to store creds in cache (user='${USERNAME}', pass='GarBage')"
807 return 1
810 $SMBCLIENT //$SERVER_IP/tmp --use-winbind-ccache -U "${USERNAME}" $ADDARGS -c quit 2>&1
811 ret=$?
813 if [ $ret -eq 0 ]; then
814 echo "smbclient succeeded with wrong cached credentials"
815 return 1
818 $WBINFO --logoff
821 # Test authenticating using the winbind ccache
822 test_auth_file()
824 tmpfile=$PREFIX/smbclient.in.$$
825 cat >$tmpfile <<EOF
826 username=${USERNAME}
827 password=${PASSWORD}
828 domain=${DOMAIN}
830 $SMBCLIENT //$SERVER_IP/tmp --authentication-file=$tmpfile $ADDARGS -c quit 2>&1
831 ret=$?
832 rm $tmpfile
834 if [ $ret != 0 ]; then
835 echo "smbclient failed to use auth file"
836 return 1
839 cat >$tmpfile <<EOF
840 username=${USERNAME}
841 password=xxxx
842 domain=${DOMAIN}
844 $SMBCLIENT //$SERVER_IP/tmp --authentication-file=$tmpfile $ADDARGS -c quit 2>&1
845 ret=$?
846 rm $tmpfile
848 if [ $ret -eq 0 ]; then
849 echo "smbclient succeeded with wrong auth file credentials"
850 return 1
854 # Test doing a directory listing with backup privilege.
855 test_backup_privilege_list()
857 tmpfile=$PREFIX/smbclient_backup_privilege_list
859 # selftest uses the forward slash as a separator, but "net sam rights
860 # grant" requires the backslash separator
861 USER_TMP=$(printf '%s' "$USERNAME" | tr '/' '\\')
863 # If we don't have a DOMAIN component to the username, add it.
864 printf '%s' "$USER_TMP" | grep '\\' 2>&1
865 ret=$?
866 if [ $ret != 0 ]; then
867 priv_username="$DOMAIN\\$USER_TMP"
868 else
869 priv_username="$USER_TMP"
872 $NET sam rights grant $priv_username SeBackupPrivilege 2>&1
873 ret=$?
874 if [ $ret != 0 ]; then
875 echo "Failed to add SeBackupPrivilege to user $priv_username - $ret"
876 return 1
879 cat >$tmpfile <<EOF
880 backup
882 quit
885 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
886 eval echo "$cmd"
887 out=$(eval $cmd)
888 ret=$?
889 rm -f $tmpfile
891 if [ $ret != 0 ]; then
892 echo "$out"
893 echo "failed backup privilege list $ret"
894 return 1
897 # Now remove all privileges from this SID.
898 $NET sam rights revoke $priv_username SeBackupPrivilege 2>&1
899 ret=$?
900 if [ $ret != 0 ]; then
901 echo "failed to remove SeBackupPrivilege from user $priv_username - $ret"
902 return 1
906 # Test accessing an share with bad names (won't convert).
907 test_bad_names()
909 # First with SMB1
911 if [ $PROTOCOL = "NT1" ]; then
912 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/badname-tmp -I $SERVER_IP $ADDARGS -m$PROTOCOL -c ls 2>&1'
913 eval echo "$cmd"
914 out=$(eval $cmd)
915 ret=$?
917 if [ $ret != 0 ]; then
918 echo "$out"
919 echo "failed accessing badname-tmp (SMB1) with error $ret"
920 return 1
923 echo "$out" | wc -l 2>&1 | grep 5
924 ret=$?
925 if [ $ret != 0 ]; then
926 echo "$out"
927 echo "failed listing \\badname-tmp - grep of number of lines (1) failed with $ret"
928 return 1
931 echo "$out" | grep '^ \. *D'
932 ret=$?
933 if [ $ret != 0 ]; then
934 echo "$out"
935 echo "failed listing \\badname-tmp - grep (1) failed with $ret"
936 return 1
939 echo "$out" | grep '^ \.\. *D'
940 ret=$?
941 if [ $ret != 0 ]; then
942 echo "$out"
943 echo "failed listing \\badname-tmp - grep (2) failed with $ret"
944 return 1
947 echo "$out" | grep '^ blank.txt *N'
948 ret=$?
949 if [ $ret != 0 ]; then
950 echo "$out"
951 echo "failed listing \\badname-tmp - grep (3) failed with $ret"
952 return 1
955 echo "$out" | grep '^ *$'
956 ret=$?
957 if [ $ret != 0 ]; then
958 echo "$out"
959 echo "failed listing \\badname-tmp - grep (4) failed with $ret"
960 return 1
963 echo "$out" | grep 'blocks of size.*blocks available'
964 ret=$?
965 if [ $ret != 0 ]; then
966 echo "$out"
967 echo "failed listing \\badname-tmp - grep (5) failed with $ret"
968 return 1
972 if [ $PROTOCOL = "SMB3" ]; then
974 # Now check again with -mSMB3
975 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/badname-tmp -I $SERVER_IP $ADDARGS -m$PROTOCOL -c ls 2>&1'
976 eval echo "$cmd"
977 out=$(eval $cmd)
978 ret=$?
980 if [ $ret != 0 ]; then
981 echo "$out"
982 echo "failed accessing badname-tmp (SMB3) with error $ret"
983 return 1
986 echo "$out" | wc -l 2>&1 | grep 5
987 ret=$?
988 if [ $ret != 0 ]; then
989 echo "$out"
990 echo "failed listing \\badname-tmp - SMB3 grep of number of lines (1) failed with $ret"
991 return 1
994 echo "$out" | grep '^ \. *D'
995 ret=$?
996 if [ $ret != 0 ]; then
997 echo "$out"
998 echo "failed listing \\badname-tmp - SMB3 grep (1) failed with $ret"
999 return 1
1002 echo "$out" | grep '^ \.\. *D'
1003 ret=$?
1004 if [ $ret != 0 ]; then
1005 echo "$out"
1006 echo "failed listing \\badname-tmp - SMB3 grep (2) failed with $ret"
1007 return 1
1010 echo "$out" | grep '^ blank.txt *N'
1011 ret=$?
1012 if [ $ret != 0 ]; then
1013 echo "$out"
1014 echo "failed listing \\badname-tmp - SMB3 grep (3) failed with $ret"
1015 return 1
1018 echo "$out" | grep '^ *$'
1019 ret=$?
1020 if [ $ret != 0 ]; then
1021 echo "$out"
1022 echo "failed listing \\badname-tmp - SMB3 grep (4) failed with $ret"
1023 return 1
1026 echo "$out" | grep 'blocks of size.*blocks available'
1027 ret=$?
1028 if [ $ret != 0 ]; then
1029 echo "$out"
1030 echo "failed listing \\badname-tmp - SMB3 grep (5) failed with $ret"
1031 return 1
1036 # Test accessing an share with a name that must be mangled - with acl_xattrs.
1037 # We know foo:bar gets mangled to FF4GBY~Q with the default name-mangling algorithm (hash2).
1038 test_mangled_names()
1040 tmpfile=$PREFIX/smbclient_interactive_prompt_commands
1041 cat >$tmpfile <<EOF
1043 cd FF4GBY~Q
1045 quit
1047 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/manglenames_share -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1048 eval echo "$cmd"
1049 out=$(eval $cmd)
1050 ret=$?
1051 rm -f $tmpfile
1053 if [ $ret != 0 ]; then
1054 echo "$out"
1055 echo "failed accessing manglenames_share with error $ret"
1056 return 1
1059 echo "$out" | grep 'NT_STATUS'
1060 ret=$?
1061 if [ $ret = 0 ]; then
1062 echo "$out"
1063 echo "failed - NT_STATUS_XXXX listing \\manglenames_share\\FF4GBY~Q"
1064 return 1
1068 # Test using scopy to copy a file on the server.
1069 test_scopy()
1071 tmpfile=$PREFIX/smbclient_interactive_prompt_commands
1072 scopy_file=$PREFIX/scopy_file
1074 rm -f $scopy_file
1075 cat >$tmpfile <<EOF
1076 put ${SMBCLIENT}
1077 scopy smbclient scopy_file
1078 lcd ${PREFIX}
1079 get scopy_file
1080 del smbclient
1081 del scopy_file
1082 quit
1084 if [ $PROTOCOL = "SMB3" ]; then
1085 # First SMB3
1086 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS -m$PROTOOCL < $tmpfile 2>&1'
1087 eval echo "$cmd"
1088 out=$(eval $cmd)
1089 ret=$?
1090 out1=$(md5sum ${SMBCLIENT} | sed -e 's/ .*//')
1091 out2=$(md5sum ${scopy_file} | sed -e 's/ .*//')
1092 rm -f $tmpfile
1093 rm -f $scopy_file
1095 if [ $ret != 0 ]; then
1096 echo "$out"
1097 echo "failed scopy test (1) with output $ret"
1098 return 1
1101 if [ $out1 != $out2 ]; then
1102 echo "$out1 $out2"
1103 echo "failed md5sum (1)"
1104 return 1
1108 # Now do again using SMB1
1109 # to force client-side fallback.
1112 if [ $PROTOCOL = "NT1" ]; then
1113 cat >$tmpfile <<EOF
1114 put ${SMBCLIENT}
1115 scopy smbclient scopy_file
1116 lcd ${PREFIX}
1117 get scopy_file
1118 del smbclient
1119 del scopy_file
1120 quit
1122 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS -m$PROTOCOL < $tmpfile 2>&1'
1123 eval echo "$cmd"
1124 out=$(eval $cmd)
1125 ret=$?
1126 out1=$(md5sum ${SMBCLIENT} | sed -e 's/ .*//')
1127 out2=$(md5sum ${scopy_file} | sed -e 's/ .*//')
1128 rm -f $tmpfile
1129 rm -f $scopy_file
1131 if [ $ret != 0 ]; then
1132 echo "$out"
1133 echo "failed scopy test (2) with output $ret"
1134 return 1
1137 if [ $out1 != $out2 ]; then
1138 echo "$out1 $out2"
1139 echo "failed md5sum (2)"
1140 return 1
1145 # Test creating a stream on the root of the share directory filename - :foobar
1146 test_toplevel_stream()
1148 tmpfile=$PREFIX/smbclient_interactive_prompt_commands
1149 cat >$tmpfile <<EOF
1150 put ${PREFIX}/smbclient_interactive_prompt_commands :foobar
1151 allinfo \\
1152 setmode \\ -a
1153 quit
1155 # Only with SMB3???
1156 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS -mSMB3 < $tmpfile 2>&1'
1157 eval echo "$cmd"
1158 out=$(eval $cmd)
1159 ret=$?
1160 rm -f $tmpfile
1162 if [ $ret != 0 ]; then
1163 echo "$out"
1164 echo "failed creating toplevel stream :foobar with error $ret"
1165 return 1
1168 echo "$out" | grep '^stream:.*:foobar'
1169 ret=$?
1170 if [ $ret != 0 ]; then
1171 echo "$out"
1172 echo "failed creating toplevel stream :foobar"
1173 return 1
1177 # Test wide links are restricted.
1178 test_widelinks()
1180 tmpfile=$PREFIX/smbclient_interactive_prompt_commands
1181 cat >$tmpfile <<EOF
1182 cd dot
1184 quit
1186 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/widelinks_share -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1187 eval echo "$cmd"
1188 out=$(eval $cmd)
1189 ret=$?
1190 rm -f $tmpfile
1192 if [ $ret != 0 ]; then
1193 echo "$out"
1194 echo "failed accessing widelinks_share with error $ret"
1195 return 1
1198 echo "$out" | grep 'NT_STATUS'
1199 ret=$?
1200 if [ $ret = 0 ]; then
1201 echo "$out"
1202 echo "failed - NT_STATUS_XXXX listing \\widelinks_share\\dot"
1203 return 1
1206 cat >$tmpfile <<EOF
1207 allinfo source
1208 quit
1210 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/widelinks_share -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1211 eval echo "$cmd"
1212 out=$(eval $cmd)
1213 ret=$?
1214 rm -f $tmpfile
1216 if [ $ret != 0 ]; then
1217 echo "$out"
1218 echo "failed accessing widelinks_share with error $ret"
1219 return 1
1222 # This should fail with NT_STATUS_OBJECT_NAME_NOT_FOUND
1223 echo "$out" | grep 'NT_STATUS_OBJECT_NAME_NOT_FOUND'
1224 ret=$?
1225 if [ $ret != 0 ]; then
1226 echo "$out"
1227 echo "failed - should get NT_STATUS_OBJECT_NAME_NOT_FOUND listing \\widelinks_share\\source"
1228 return 1
1232 # Test creating then deleting a stream file doesn't leave a lost-XXXXX directory.
1233 test_streams_depot_delete()
1235 tmpfile=$PREFIX/smbclient_interactive_prompt_commands
1236 rm -rf "$LOCAL_PATH/lost-*"
1238 cat >$tmpfile <<EOF
1239 put ${PREFIX}/smbclient_interactive_prompt_commands foo:bar
1240 del foo
1241 ls lost*
1242 quit
1244 # This only works with SMB3?
1245 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS -mSMB3 < $tmpfile 2>&1'
1246 eval echo "$cmd"
1247 out=$(eval $cmd)
1248 ret=$?
1249 rm -f $tmpfile
1251 if [ $ret != 0 ]; then
1252 echo "$out"
1253 echo "failed creating then deleting foo:bar with error $ret"
1254 return 1
1257 echo "$out" | grep 'NT_STATUS_NO_SUCH_FILE listing \\lost\*'
1258 ret=$?
1259 if [ $ret != 0 ]; then
1260 echo "$out"
1261 echo "deleting foo:bar left lost-XXX directory"
1262 rm -rf "$LOCAL_PATH/lost-*"
1263 return 1
1267 # Test follow symlinks can't access symlinks
1268 test_nosymlinks()
1270 # Setup test dirs.
1271 local_test_dir="$LOCAL_PATH/nosymlinks/test"
1272 local_slink_name="$local_test_dir/source"
1273 local_slink_target="$local_test_dir/nosymlink_target_file"
1275 share_test_dir="test"
1276 share_foo_dir="$share_test_dir/foo"
1277 share_foobar_dir="$share_test_dir/foo/bar"
1278 share_target_file="$share_test_dir/foo/bar/testfile"
1280 rm -rf $local_test_dir
1282 local_nosymlink_target_file="nosymlink_target_file"
1283 echo "$local_slink_target" >$PREFIX/$local_nosymlink_target_file
1285 local_foobar_target_file="testfile"
1286 echo "$share_target_file" >$PREFIX/$local_foobar_target_file
1288 tmpfile=$PREFIX/smbclient_interactive_prompt_commands
1289 cat >$tmpfile <<EOF
1290 mkdir $share_test_dir
1291 mkdir $share_foo_dir
1292 mkdir $share_foobar_dir
1293 lcd $PREFIX
1294 cd /$share_test_dir
1295 put $local_nosymlink_target_file
1296 cd /$share_foobar_dir
1297 put $local_foobar_target_file
1298 quit
1301 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/nosymlinks -I $SERVER_IP $LOCAL_ADDARGS < $tmpfile 2>&1'
1302 eval echo "$cmd"
1303 out=$(eval $cmd)
1304 ret=$?
1305 rm -f $tmpfile
1306 rm -f $PREFIX/$local_nosymlink_target_file
1307 rm -f $PREFIX/$local_foobar_target_file
1309 if [ $ret -ne 0 ]; then
1310 echo "$out"
1311 echo "failed accessing local_symlinks with error $ret"
1312 false
1313 return
1316 echo "$out" | grep 'NT_STATUS_'
1317 ret=$?
1318 if [ $ret -eq 0 ]; then
1319 echo "$out"
1320 echo "failed - got an NT_STATUS error"
1321 false
1322 return
1325 # Create the symlink locally
1326 ln -s $local_slink_target $local_slink_name
1328 # Getting a file through a symlink name should fail.
1329 tmpfile=$PREFIX/smbclient_interactive_prompt_commands
1330 cat >$tmpfile <<EOF
1331 get test\\source
1332 quit
1334 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/nosymlinks -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1335 eval echo "$cmd"
1336 out=$(eval $cmd)
1337 ret=$?
1338 rm -f $tmpfile
1340 if [ $ret -ne 0 ]; then
1341 echo "$out"
1342 echo "failed accessing nosymlinks with error $ret"
1343 return 1
1346 echo "$out" | grep 'NT_STATUS_OBJECT_NAME_NOT_FOUND'
1347 ret=$?
1348 if [ $ret -ne 0 ]; then
1349 echo "$out"
1350 echo "failed - should get NT_STATUS_OBJECT_NAME_NOT_FOUND getting \\nosymlinks\\source"
1351 return 1
1354 # But we should be able to create and delete directories.
1355 cat >$tmpfile <<EOF
1356 mkdir test\\a
1357 mkdir test\\a\\b
1358 quit
1360 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/nosymlinks -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1361 eval echo "$cmd"
1362 out=$(eval $cmd)
1363 ret=$?
1364 rm -f $tmpfile
1366 if [ $ret -ne 0 ]; then
1367 echo "$out"
1368 echo "failed accessing nosymlinks with error $ret"
1369 return 1
1372 echo "$out" | grep 'NT_STATUS'
1373 ret=$?
1374 if [ $ret -eq 0 ]; then
1375 echo "$out"
1376 echo "failed - NT_STATUS_XXXX doing mkdir a; mkdir a\\b on \\nosymlinks"
1377 return 1
1380 # Ensure regular file/directory access also works.
1381 cat >$tmpfile <<EOF
1382 cd test\\foo\\bar
1384 get testfile -
1385 quit
1387 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/nosymlinks -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1388 eval echo "$cmd"
1389 out=$(eval $cmd)
1390 ret=$?
1391 rm -f $tmpfile
1393 if [ $ret -ne 0 ]; then
1394 echo "$out"
1395 echo "failed accessing nosymlinks with error $ret"
1396 return 1
1399 echo "$out" | grep 'NT_STATUS'
1400 ret=$?
1401 if [ $ret -eq 0 ]; then
1402 echo "$out"
1403 echo "failed - NT_STATUS_XXXX doing cd foo\\bar; get testfile on \\nosymlinks"
1404 return 1
1407 # CLEANUP
1408 rm -f $local_slink_name
1410 cat >$tmpfile <<EOF
1411 deltree test
1412 quit
1414 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/nosymlinks -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1415 eval echo "$cmd"
1416 out=$(eval $cmd)
1417 ret=$?
1418 rm -f $tmpfile
1420 if [ $ret -ne 0 ]; then
1421 echo "$out"
1422 echo "failed accessing nosymlinks with error $ret"
1423 return 1
1426 echo "$out" | grep 'NT_STATUS'
1427 ret=$?
1428 if [ $ret -eq 0 ]; then
1429 echo "$out"
1430 echo "failed - NT_STATUS_XXXX doing cd foo\\bar; get testfile on \\nosymlinks"
1431 return 1
1435 # Test we can follow normal symlinks.
1436 # Bug: https://bugzilla.samba.org/show_bug.cgi?id=12860
1437 # Note - this needs to be tested over SMB3, not SMB1.
1439 test_local_symlinks()
1441 # Setup test dirs.
1442 LOCAL_RAWARGS="${CONFIGURATION} -mSMB3"
1443 LOCAL_ADDARGS="${LOCAL_RAWARGS} $*"
1445 share_test_dir="test"
1446 share_slink_target_dir="$share_test_dir/dir1"
1448 local_test_dir="$LOCAL_PATH/local_symlinks/$share_test_dir"
1449 local_slink_name="$local_test_dir/sym_name"
1450 local_slink_target_dir="$local_test_dir/dir1"
1452 rm -rf $local_test_dir
1454 # Create the initial directories
1455 tmpfile=$PREFIX/smbclient_interactive_prompt_commands
1456 cat >$tmpfile <<EOF
1457 mkdir $share_test_dir
1458 mkdir $share_slink_target_dir
1459 quit
1462 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/local_symlinks -I $SERVER_IP $LOCAL_ADDARGS < $tmpfile 2>&1'
1463 eval echo "$cmd"
1464 out=$(eval $cmd)
1465 ret=$?
1466 rm -f $tmpfile
1468 if [ $ret -ne 0 ]; then
1469 echo "$out"
1470 echo "failed accessing local_symlinks with error $ret"
1471 false
1472 return
1475 echo "$out" | grep 'NT_STATUS_'
1476 ret=$?
1477 if [ $ret -eq 0 ]; then
1478 echo "$out"
1479 echo "failed - got an NT_STATUS error"
1480 false
1481 return
1484 # Create the symlink locally
1485 ln -s $local_slink_target_dir $local_slink_name
1486 ret=$?
1487 if [ $ret -ne 0 ]; then
1488 echo "$out"
1489 echo "failed - unable to create symlink"
1490 ls -la $local_test_dir
1491 false
1492 return
1495 # Create a file to be accessed behind the symlink
1496 touch $local_slink_target_dir/x
1497 ret=$?
1498 if [ $ret -ne 0 ]; then
1499 echo "$out"
1500 echo "failed - unable to create file"
1501 ls -la $local_test_dir
1502 false
1503 return
1506 # Can we cd into the symlink name and ls ?
1507 tmpfile=$PREFIX/smbclient_interactive_prompt_commands
1508 cat >$tmpfile <<EOF
1509 cd $share_test_dir\\sym_name
1511 quit
1513 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/local_symlinks -I $SERVER_IP $LOCAL_ADDARGS < $tmpfile 2>&1'
1514 eval echo "$cmd"
1515 out=$(eval $cmd)
1516 ret=$?
1517 rm -f $tmpfile
1519 if [ $ret -ne 0 ]; then
1520 echo "$out"
1521 echo "failed accessing local_symlinks with error $ret"
1522 false
1523 return
1526 echo "$out" | grep 'NT_STATUS_'
1527 ret=$?
1528 if [ $ret -eq 0 ]; then
1529 echo "$out"
1530 echo "failed - got an NT_STATUS error"
1531 false
1532 return
1535 # Can we get the test file behind the symlink'ed dir?
1536 tmpfile=$PREFIX/smbclient_interactive_prompt_commands
1537 cat >$tmpfile <<EOF
1538 get $share_test_dir\\sym_name\\x -
1539 quit
1541 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/local_symlinks -I $SERVER_IP $LOCAL_ADDARGS < $tmpfile 2>&1'
1542 eval echo "$cmd"
1543 out=$(eval $cmd)
1544 ret=$?
1545 rm -f $tmpfile
1547 if [ $ret -ne 0 ]; then
1548 echo "$out"
1549 echo "failed accessing local_symlinks with error $ret"
1550 false
1551 return
1554 echo "$out" | grep 'NT_STATUS_'
1555 ret=$?
1556 if [ $ret -eq 0 ]; then
1557 echo "$out"
1558 echo "failed - got an NT_STATUS error"
1559 false
1560 return
1563 # CLEANUP
1564 rm -f $local_slink_name
1566 tmpfile=$PREFIX/smbclient_interactive_prompt_commands
1567 cat >$tmpfile <<EOF
1568 deltree $share_test_dir
1569 quit
1571 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/local_symlinks -I $SERVER_IP $LOCAL_ADDARGS < $tmpfile 2>&1'
1572 eval echo "$cmd"
1573 out=$(eval $cmd)
1574 ret=$?
1575 rm -f $tmpfile
1577 if [ $ret -ne 0 ]; then
1578 echo "$out"
1579 echo "failed accessing local_symlinks with error $ret"
1580 false
1581 return
1584 echo "$out" | grep 'NT_STATUS_'
1585 ret=$?
1586 if [ $ret -eq 0 ]; then
1587 echo "$out"
1588 echo "failed - got an NT_STATUS error"
1589 false
1590 return
1595 # Regression test for CVE-2019-10197
1596 # we should always get ACCESS_DENIED
1598 test_noperm_share_regression()
1600 cmd='$SMBCLIENT -U$USERNAME%$PASSWORD //$SERVER/noperm -I $SERVER_IP $LOCAL_ADDARGS -c "ls;ls" 2>&1'
1601 eval echo "$cmd"
1602 out=$(eval $cmd)
1603 ret=$?
1604 if [ $ret -eq 0 ]; then
1605 echo "$out"
1606 echo "failed accessing no perm share should not work"
1607 return 1
1610 num=$(echo "$out" | grep 'NT_STATUS_ACCESS_DENIED' | wc -l)
1611 if [ "$num" -ne "2" ]; then
1612 echo "$out"
1613 echo "failed num[$num] - two NT_STATUS_ACCESS_DENIED lines expected"
1614 return 1
1617 return 0
1620 # Test smbclient deltree command
1621 test_deltree()
1623 tmpfile=$PREFIX/smbclient_interactive_prompt_commands
1624 deltree_dir=$PREFIX/deltree_dir
1626 rm -rf $deltree_dir
1627 cat >$tmpfile <<EOF
1628 mkdir deltree_dir
1629 mkdir deltree_dir/foo
1630 mkdir deltree_dir/foo/bar
1631 put ${SMBCLIENT} deltree_dir/foo/bar/client
1632 deltree deltree_dir
1633 quit
1635 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1636 eval echo "$cmd"
1637 out=$(eval $cmd)
1638 ret=$?
1640 if [ $ret != 0 ]; then
1641 echo "$out"
1642 echo "failed deltree test with output $ret"
1643 false
1644 return
1647 echo "$out" | grep 'NT_STATUS_'
1648 ret=$?
1649 if [ $ret -eq 0 ]; then
1650 echo "$out"
1651 echo "failed - got an NT_STATUS error"
1652 false
1653 return
1656 if [ -d $deltree_dir ]; then
1657 echo "deltree did not delete everything"
1658 false
1659 return
1663 # Test smbclient setmode command
1664 test_setmode()
1666 tmpfile=$PREFIX/smbclient_interactive_prompt_commands
1668 cat >$tmpfile <<EOF
1669 del test_setmode
1670 put ${SMBCLIENT} test_setmode
1671 setmode test_setmode +r +s +h +a
1672 allinfo test_setmode
1673 setmode test_setmode -rsha
1674 allinfo test_setmode
1675 del test_setmode
1676 quit
1678 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1679 eval echo "$cmd"
1680 out=$(eval $cmd)
1681 ret=$?
1683 if [ $ret != 0 ]; then
1684 echo "$out"
1685 echo "failed setmode test with output $ret"
1686 false
1687 return
1690 echo "$out" | grep 'attributes: RHSA'
1691 ret=$?
1692 if [ $ret -ne 0 ]; then
1693 echo "$out"
1694 echo "failed - should get attributes: RHSA"
1695 false
1696 return
1699 echo "$out" | grep 'attributes: (80)'
1700 ret=$?
1701 if [ $ret -ne 0 ]; then
1702 echo "$out"
1703 echo "failed - should also get attributes: (80)"
1704 false
1705 return
1709 # Test smbclient utimes command
1710 test_utimes()
1712 tmpfile=$PREFIX/smbclient_interactive_prompt_commands
1714 saved_TZ="$TZ"
1715 TZ=UTC
1716 export TZ
1717 saved_LANG="$LANG"
1718 LANG=C
1719 export LANG
1721 cat >$tmpfile <<EOF
1722 del utimes_test
1723 put ${SMBCLIENT} utimes_test
1724 allinfo utimes_test
1725 utimes utimes_test 2016:02:04-06:19:20 17:01:01-05:10:20 -1 -1
1726 allinfo utimes_test
1727 del utimes_test
1728 quit
1730 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1731 eval echo "$cmd"
1732 out=$(eval $cmd)
1733 ret=$?
1735 if [ -n "$saved_TZ" ]; then
1736 export TZ="$saved_TZ"
1737 else
1738 unset TZ
1740 if [ -n "$saved_LANG" ]; then
1741 export LANG="$saved_LANG"
1742 else
1743 unset LANG
1746 if [ $ret != 0 ]; then
1747 echo "$out"
1748 echo "failed utimes test with output $ret"
1749 false
1750 return
1753 # Now, we should have 2 identical write_time and change_time
1754 # values, but one access_time of Jan 1 05:10:20 AM,
1755 # and one create_time of Feb 04 06:19:20 AM 2016
1756 out_sorted=$(echo "$out" | sort | uniq)
1757 num_create=$(echo "$out_sorted" | grep -c 'create_time:')
1758 num_access=$(echo "$out_sorted" | grep -c 'access_time:')
1759 num_write=$(echo "$out_sorted" | grep -c 'write_time:')
1760 num_change=$(echo "$out_sorted" | grep -c 'change_time:')
1761 if [ "$num_create" != "2" ]; then
1762 echo "failed - should get two create_time $out"
1763 false
1764 return
1766 if [ "$num_access" != "2" ]; then
1767 echo "failed - should get two access_time $out"
1768 false
1769 return
1771 if [ "$num_write" != "1" ]; then
1772 echo "failed - should only get one write_time $out"
1773 false
1774 return
1776 if [ "$num_change" != "1" ]; then
1777 echo "failed - should only get one change_time $out"
1778 false
1779 return
1782 # This could be: Sun Jan 1 05:10:20 AM 2017
1783 # or : Sun Jan 1 05:10:20 2017 CET
1784 echo "$out" | grep 'access_time:.*Sun Jan.*1 05:10:20 .*2017.*'
1785 ret=$?
1786 if [ $ret -ne 0 ]; then
1787 echo "$out"
1788 echo
1789 echo "failed - should get access_time: Sun Jan 1 05:10:20 [AM] 2017"
1790 false
1791 return
1794 # This could be: Thu Feb 4 06:19:20 AM 2016
1795 # or : Thu Feb 4 06:19:20 2016 CET
1796 echo "$out" | grep 'create_time:.*Thu Feb.*4 06:19:20 .*2016.*'
1797 ret=$?
1798 if [ $ret -ne 0 ]; then
1799 echo "$out"
1800 echo
1801 echo "failed - should get access_time: Thu Feb 4 06:19:20 [AM] 2016"
1802 false
1803 return
1807 # Test smbclient renames with pathnames containing '..'
1808 test_rename_dotdot()
1810 tmpfile=$PREFIX/smbclient_interactive_prompt_commands
1812 cat >$tmpfile <<EOF
1813 deltree dotdot_test
1814 mkdir dotdot_test
1815 cd dotdot_test
1816 mkdir dir1
1817 mkdir dir2
1818 cd dir1
1819 put ${SMBCLIENT} README
1820 rename README ..\\dir2\\README
1821 cd ..
1822 cd dir2
1823 allinfo README
1824 cd \\
1825 deltree dotdot_test
1826 quit
1828 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1829 eval echo "$cmd"
1830 out=$(eval $cmd)
1831 ret=$?
1833 if [ $ret != 0 ]; then
1834 echo "$out"
1835 echo "failed rename_dotdot test with output $ret"
1836 false
1837 return
1840 # We are allowed to get NT_STATUS_NO_SUCH_FILE listing \dotdot_test
1841 # as the top level directory should not exist, but no other errors.
1843 error_str=$(echo $out | grep NT_STATUS | grep -v "NT_STATUS_NO_SUCH_FILE listing .dotdot_test")
1844 if [ "$error_str" != "" ]; then
1845 echo "failed - unexpected NT_STATUS error in $out"
1846 false
1847 return
1851 # Test doing a volume command.
1852 test_volume()
1854 tmpfile=$PREFIX/smbclient_interactive_prompt_commands
1855 cat >$tmpfile <<EOF
1856 volume
1857 quit
1859 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1860 eval echo "$cmd"
1861 out=$(eval $cmd)
1862 ret=$?
1863 rm -f $tmpfile
1865 if [ $ret != 0 ]; then
1866 echo "$out"
1867 echo "failed doing volume command with error $ret"
1868 return 1
1871 echo "$out" | grep '^Volume: |tmp| serial number'
1872 ret=$?
1873 if [ $ret != 0 ]; then
1874 echo "$out"
1875 echo "failed doing volume command"
1876 return 1
1880 test_server_os_message()
1882 tmpfile=$PREFIX/smbclient_interactive_prompt_commands
1883 cat >$tmpfile <<EOF
1885 quit
1887 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1888 eval echo "$cmd"
1889 out=$(eval $cmd)
1890 ret=$?
1891 rm -f $tmpfile
1893 if [ $ret -ne 0 ]; then
1894 echo "$out"
1895 echo "failed to connect error $ret"
1896 return 1
1899 echo "$out" | grep 'Try "help" to get a list of possible commands.'
1900 ret=$?
1901 if [ $ret -ne 0 ]; then
1902 echo "$out"
1903 echo 'failed - should get: Try "help" to get a list of possible commands.'
1904 return 1
1907 return 0
1910 test_server_quiet_message()
1912 tmpfile=$PREFIX/smbclient_interactive_prompt_commands
1913 cat >$tmpfile <<EOF
1915 quit
1917 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS --quiet < $tmpfile 2>&1'
1918 eval echo "$cmd"
1919 out=$(eval $cmd)
1920 ret=$?
1921 rm -f $tmpfile
1923 if [ $ret -ne 0 ]; then
1924 echo "$out"
1925 echo "failed to connect error $ret"
1926 return 1
1929 echo "$out" | grep 'Try "help" to get a list of possible commands.'
1930 ret=$?
1931 if [ $ret -eq 0 ]; then
1932 echo "$out"
1933 echo 'failed - quiet should skip this message.'
1934 return 1
1937 return 0
1940 # Test xattr_stream correctly reports mode.
1941 # BUG: https://bugzilla.samba.org/show_bug.cgi?id=13380
1943 test_stream_directory_xattr()
1945 tmpfile=$PREFIX/smbclient_interactive_prompt_commands
1947 # Test against streams_xattr
1949 cat >$tmpfile <<EOF
1950 deltree foo
1951 mkdir foo
1952 put ${PREFIX}/smbclient_interactive_prompt_commands foo:bar
1953 setmode foo -a
1954 allinfo foo:bar
1955 deltree foo
1956 quit
1958 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/streams_xattr -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1959 eval echo "$cmd"
1960 out=$(eval $cmd)
1961 ret=$?
1962 rm -f $tmpfile
1964 if [ $ret != 0 ]; then
1965 echo "$out"
1966 echo "failed checking attributes on xattr stream foo:bar with error $ret"
1967 return 1
1970 echo "$out" | grep "attributes:.*80"
1971 ret=$?
1972 if [ $ret != 0 ]; then
1973 echo "$out"
1974 echo "failed checking attributes on xattr stream foo:bar"
1975 return 1
1979 # Test against streams_depot
1981 cat >$tmpfile <<EOF
1982 deltree foo
1983 mkdir foo
1984 put ${PREFIX}/smbclient_interactive_prompt_commands foo:bar
1985 setmode foo -a
1986 allinfo foo:bar
1987 deltree foo
1988 quit
1990 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1991 eval echo "$cmd"
1992 out=$(eval $cmd)
1993 ret=$?
1994 rm -f $tmpfile
1996 if [ $ret != 0 ]; then
1997 echo "$out"
1998 echo "failed checking attributes on depot stream foo:bar with error $ret"
1999 return 1
2002 echo "$out" | grep "attributes:.*80"
2003 ret=$?
2004 if [ $ret != 0 ]; then
2005 echo "$out"
2006 echo "failed checking attributes on depot stream foo:bar"
2007 return 1
2011 # Test smbclient non-empty rmdir command
2012 test_del_nedir()
2014 tmpfile=$PREFIX/smbclient_interactive_prompt_commands
2015 del_nedir="$LOCAL_PATH/del_nedir"
2017 rm -rf $del_nedir
2018 mkdir $del_nedir
2019 touch $del_nedir/afile
2020 cat >$tmpfile <<EOF
2021 rmdir del_nedir
2022 quit
2024 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
2025 eval echo "$cmd"
2026 out=$(eval $cmd)
2027 ret=$?
2028 rm -rf $del_nedir
2030 if [ $ret != 0 ]; then
2031 echo "$out"
2032 echo "failed test_del_nedir test with output $ret"
2033 false
2034 return
2037 # Should get NT_STATUS_DIRECTORY_NOT_EMPTY error from rmdir
2038 echo "$out" | grep 'NT_STATUS_DIRECTORY_NOT_EMPTY'
2039 ret=$?
2040 if [ $ret -ne 0 ]; then
2041 echo "$out"
2042 echo "test_del_nedir failed - should get an NT_STATUS_DIRECTORY_NOT_EMPTY error"
2043 false
2044 return
2048 test_valid_users()
2050 tmpfile=$PREFIX/smbclient_interactive_prompt_commands
2051 cat >$tmpfile <<EOF
2053 quit
2055 # User in "valid users" can login to service
2056 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$DC_USERNAME%$DC_PASSWORD //$SERVER/valid_users $ADDARGS < $tmpfile 2>&1'
2057 eval echo "$cmd"
2058 out=$(eval $cmd)
2059 ret=$?
2061 if [ $ret -ne 0 ]; then
2062 echo "$out"
2063 echo "test_valid_users:valid_users 'User in 'valid users' can login to service' failed - $ret"
2064 return 1
2067 # User from ad group in "valid users" can login to service
2068 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$DC_USERNAME%$DC_PASSWORD //$SERVER/valid_users_group $ADDARGS < $tmpfile 2>&1'
2069 eval echo "$cmd"
2070 out=$(eval $cmd)
2071 ret=$?
2073 if [ $ret -ne 0 ]; then
2074 echo "$out"
2075 echo "test_valid_users:valid_users_group 'User from ad group in 'valid users' can login to service' failed - $ret"
2076 return 1
2079 # User from UNIX group in "valid users" can login to service
2080 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$DC_USERNAME%$DC_PASSWORD //$SERVER/valid_users_unix_group $ADDARGS < $tmpfile 2>&1'
2081 eval echo "$cmd"
2082 out=$(eval $cmd)
2083 ret=$?
2085 if [ $ret -ne 0 ]; then
2086 echo "$out"
2087 echo "test_valid_users:valid_users_unix_group 'User from UNIX group in 'valid users' can login to service' failed - $ret"
2088 return 1
2091 # User not in NIS group in "valid users" can't login to service
2092 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$DC_USERNAME%$DC_PASSWORD //$SERVER/valid_users_nis_group $ADDARGS < $tmpfile 2>&1'
2093 eval echo "$cmd"
2094 out=$(eval $cmd)
2095 echo "$out" | grep 'NT_STATUS_ACCESS_DENIED'
2096 ret=$?
2098 if [ $ret -ne 0 ]; then
2099 echo "$out"
2100 echo "test_valid_users:valid_users_nis_group 'User not in NIS group in 'valid users' can't login to service' failed - $ret"
2101 return 1
2104 # Check user in UNIX, then in NIS group in "valid users" can login to service
2105 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$DC_USERNAME%$DC_PASSWORD //$SERVER/valid_users_unix_nis_group $ADDARGS < $tmpfile 2>&1'
2106 eval echo "$cmd"
2107 out=$(eval $cmd)
2108 ret=$?
2110 if [ $ret -ne 0 ]; then
2111 echo "$out"
2112 echo "test_valid_users:valid_users_unix_nis_group 'Check user in UNIX, then in NIS group in 'valid users' can login to service' failed - $ret"
2113 return 1
2116 # Check user in NIS, then in UNIX group in "valid users" can login to service
2117 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$DC_USERNAME%$DC_PASSWORD //$SERVER/valid_users_nis_unix_group $ADDARGS < $tmpfile 2>&1'
2118 eval echo "$cmd"
2119 out=$(eval $cmd)
2120 ret=$?
2122 if [ $ret -ne 0 ]; then
2123 echo "$out"
2124 echo "test_valid_users:valid_users_nis_unix_group 'Check user in NIS, then in UNIX group in 'valid users' can login to service' failed - $ret"
2125 return 1
2128 # User not in "invalid users" can login to service
2129 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -Ualice%Secret007 //$SERVER/invalid_users $ADDARGS < $tmpfile 2>&1'
2130 eval echo "$cmd"
2131 out=$(eval $cmd)
2132 ret=$?
2134 if [ $ret -ne 0 ]; then
2135 echo "$out"
2136 echo "test_valid_users:invalid_users 'User not in 'invalid users' can login to service' failed - $ret"
2137 return 1
2140 # User in "invalid users" can't login to service
2141 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$DC_USERNAME%$DC_PASSWORD //$SERVER/invalid_users $ADDARGS < $tmpfile 2>&1'
2142 eval echo "$cmd"
2143 out=$(eval $cmd)
2144 echo "$out" | grep 'NT_STATUS_ACCESS_DENIED'
2145 ret=$?
2147 if [ $ret -ne 0 ]; then
2148 echo "$out"
2149 echo "test_valid_users:invalid_users 'User in 'invalid users' can't login to service' failed - $ret"
2150 return 1
2153 # User is in "valid and invalid users" can't login to service
2154 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$DC_USERNAME%$DC_PASSWORD //$SERVER/valid_and_invalid_users $ADDARGS < $tmpfile 2>&1'
2155 eval echo "$cmd"
2156 out=$(eval $cmd)
2157 echo "$out" | grep 'NT_STATUS_ACCESS_DENIED'
2158 ret=$?
2160 if [ $ret -ne 0 ]; then
2161 echo "$out"
2162 echo "test_valid_users:valid_and_invalid_users 'User is in 'valid and invalid users' can't login to service' failed - $ret"
2163 return 1
2166 # 2 Users are in "valid users"
2167 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -Ualice%Secret007 //$SERVER/valid_and_invalid_users $ADDARGS < $tmpfile 2>&1'
2168 eval echo "$cmd"
2169 out=$(eval $cmd)
2170 ret=$?
2171 rm -f $tmpfile
2173 if [ $ret -ne 0 ]; then
2174 echo "$out"
2175 echo "test_valid_users:valid_and_invalid_users '2 Users are in 'valid users'' failed - $ret"
2176 return 1
2179 return 0
2182 test_smbclient_minus_e_stderr()
2184 cmd='$SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -c ls'
2185 eval echo "$cmd"
2186 out=$(eval $cmd)
2187 if [ $? != 0 ]; then
2188 echo "$out"
2189 echo "command failed"
2190 return 1
2193 # test smbclient 'ls' command output went to stdout
2194 echo "$out" | grep "blocks available" >/dev/null 2>&1
2195 if [ $? != 0 ]; then
2196 # didn't get output to stdout
2197 echo "expected output was NOT output to stdout"
2198 return 1
2201 # this time execute ls but redirect stdout alone to /dev/null
2202 cmd='$SMBCLIENT -E "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -c "ls" 2>&1 > /dev/null'
2203 eval echo "$cmd"
2204 out=$(eval $cmd)
2205 if [ $? != 0 ]; then
2206 echo "$out"
2207 echo "command failed"
2208 return 1
2211 # test smbclient 'ls' command output went to stderr
2212 echo "$out" | grep "blocks available" >/dev/null 2>&1
2213 if [ $? != 0 ]; then
2214 # didn't get output to stderr
2215 echo "expected output was NOT output to stderr"
2216 return 1
2219 return 0
2225 LOGDIR_PREFIX=test_smbclient_s3
2227 # possibly remove old logdirs:
2229 for OLDDIR in $(find ${PREFIX} -type d -name "${LOGDIR_PREFIX}_*"); do
2230 echo "removing old directory ${OLDDIR}"
2231 rm -rf ${OLDDIR}
2232 done
2234 LOGDIR=$(mktemp -d ${PREFIX}/${LOGDIR_PREFIX}_XXXXXX)
2236 testit "smbclient -L $SERVER_IP" $SMBCLIENT -L $SERVER_IP -N -p 139 ${RAWARGS} || failed=$(expr $failed + 1)
2237 testit "smbclient -L $SERVER -I $SERVER_IP" $SMBCLIENT -L $SERVER -I $SERVER_IP -N -p 139 ${RAWARGS} -c quit || failed=$(expr $failed + 1)
2239 testit "noninteractive smbclient does not prompt" \
2240 test_noninteractive_no_prompt ||
2241 failed=$(expr $failed + 1)
2243 testit "noninteractive smbclient -l does not prompt" \
2244 test_noninteractive_no_prompt -l $LOGDIR ||
2245 failed=$(expr $failed + 1)
2247 testit "smbclient output goes to stderr when -E is passed" \
2248 test_smbclient_minus_e_stderr ||
2249 failed=$(expr $failed + 1)
2251 testit "interactive smbclient prompts on stdout" \
2252 test_interactive_prompt_stdout ||
2253 failed=$(expr $failed + 1)
2255 testit "interactive smbclient -l prompts on stdout" \
2256 test_interactive_prompt_stdout -l $LOGDIR ||
2257 failed=$(expr $failed + 1)
2259 testit "creating a bad symlink and deleting it" \
2260 test_bad_symlink ||
2261 failed=$(expr $failed + 1)
2263 testit "creating a good symlink and deleting it by path" \
2264 test_good_symlink ||
2265 failed=$(expr $failed + 1)
2267 testit "writing into a read-only directory fails" \
2268 test_read_only_dir ro-tmp ||
2269 failed=$(expr $failed + 1)
2271 testit "writing into a read-only share fails" \
2272 test_read_only_dir valid-users-tmp ||
2273 failed=$(expr $failed + 1)
2275 testit "Reading a owner-only file fails" \
2276 test_owner_only_file ||
2277 failed=$(expr $failed + 1)
2279 testit "Accessing an MS-DFS link" \
2280 test_msdfs_link ||
2281 failed=$(expr $failed + 1)
2283 testit "Recursive ls across MS-DFS links" \
2284 test_msdfs_recursive_dir ||
2285 failed=$(expr $failed + 1)
2287 testit "Rename on MS-DFS share" \
2288 test_msdfs_rename ||
2289 failed=$(expr $failed + 1)
2291 testit "Hardlink on MS-DFS share" \
2292 test_msdfs_hardlink ||
2293 failed=$(expr $failed + 1)
2295 testit "del on MS-DFS share" \
2296 test_msdfs_del || \
2297 failed=`expr $failed + 1`
2299 testit "deltree on MS-DFS share" \
2300 test_msdfs_deltree || \
2301 failed=`expr $failed + 1`
2303 testit "Ensure archive bit is set correctly on file/dir rename" \
2304 test_rename_archive_bit ||
2305 failed=$(expr $failed + 1)
2307 testit "ccache access works for smbclient" \
2308 test_ccache_access ||
2309 failed=$(expr $failed + 1)
2311 testit "sending a message to the remote server" \
2312 test_message ||
2313 failed=$(expr $failed + 1)
2315 testit "using an authentication file" \
2316 test_auth_file ||
2317 failed=$(expr $failed + 1)
2319 testit "list with backup privilege" \
2320 test_backup_privilege_list ||
2321 failed=$(expr $failed + 1)
2323 testit "list a share with bad names (won't convert)" \
2324 test_bad_names ||
2325 failed=$(expr $failed + 1)
2327 testit "list a share with a mangled name + acl_xattr object" \
2328 test_mangled_names ||
2329 failed=$(expr $failed + 1)
2331 testit "server-side file copy" \
2332 test_scopy ||
2333 failed=$(expr $failed + 1)
2335 testit "creating a :stream at root of share" \
2336 test_toplevel_stream ||
2337 failed=$(expr $failed + 1)
2339 testit "Ensure widelinks are restricted" \
2340 test_widelinks ||
2341 failed=$(expr $failed + 1)
2343 testit "streams_depot can delete correctly" \
2344 test_streams_depot_delete ||
2345 failed=$(expr $failed + 1)
2347 testit "stream_xattr attributes" \
2348 test_stream_directory_xattr ||
2349 failed=$(expr $failed + 1)
2351 testit "follow symlinks = no" \
2352 test_nosymlinks ||
2353 failed=$(expr $failed + 1)
2355 testit "follow local symlinks" \
2356 test_local_symlinks ||
2357 failed=$(expr $failed + 1)
2359 testit "noperm share regression" \
2360 test_noperm_share_regression ||
2361 failed=$(expr $failed + 1)
2363 testit "smbclient deltree command" \
2364 test_deltree ||
2365 failed=$(expr $failed + 1)
2367 testit "server os message" \
2368 test_server_os_message ||
2369 failed=$(expr $failed + 1)
2371 testit "test server quiet message" \
2372 test_server_quiet_message ||
2373 failed=$(expr $failed + 1)
2375 testit "setmode test" \
2376 test_setmode ||
2377 failed=$(expr $failed + 1)
2379 testit "utimes" \
2380 test_utimes ||
2381 failed=$(expr $failed + 1)
2383 testit "rename_dotdot" \
2384 test_rename_dotdot ||
2385 failed=$(expr $failed + 1)
2387 testit "volume" \
2388 test_volume ||
2389 failed=$(expr $failed + 1)
2391 testit "rm -rf $LOGDIR" \
2392 rm -rf $LOGDIR ||
2393 failed=$(expr $failed + 1)
2395 testit "delete a non empty directory" \
2396 test_del_nedir ||
2397 failed=$(expr $failed + 1)
2399 testit "valid users" \
2400 test_valid_users ||
2401 failed=$(expr $failed + 1)
2403 testok $0 $failed