3 # this runs the file serving tests that are expected to pass with samba3
7 Usage: test_smbclient_s3.sh SERVER SERVER_IP DOMAIN USERNAME PASSWORD USERID LOCAL_PATH PREFIX SMBCLIENT WBINFO NET CONFIGURATION PROTOCOL
25 SMBCLIENT="$VALGRIND ${SMBCLIENT}"
26 WBINFO="$VALGRIND ${WBINFO}"
28 RAWARGS="${CONFIGURATION} -m${PROTOCOL}"
29 ADDARGS="${RAWARGS} $*"
31 incdir=`dirname $0`/../../../testprogs/blackbox
36 # Test that a noninteractive smbclient does not prompt
37 test_noninteractive_no_prompt()
41 cmd='echo du | $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS 2>&1'
51 echo "$out" | grep $prompt >/dev/null 2>&1
54 # got a prompt .. fail
55 echo matched interactive prompt in non-interactive mode
62 # Test that an interactive smbclient prompts to stdout
63 test_interactive_prompt_stdout()
66 tmpfile=$PREFIX/smbclient_interactive_prompt_commands
73 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
79 if [ $ret != 0 ] ; then
85 echo "$out" | grep $prompt >/dev/null 2>&1
88 echo failed to match interactive prompt on stdout
95 # Test creating a bad symlink and deleting it.
98 prompt="posix_unlink deleted file /newname"
99 tmpfile=$PREFIX/smbclient_bad_symlinks_commands
104 symlink badname newname
109 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
115 if [ $ret != 0 ] ; then
117 echo "failed create then delete bad symlink with error $ret"
121 echo "$out" | grep "$prompt" >/dev/null 2>&1
124 if [ $ret != 0 ] ; then
126 echo "failed create then delete bad symlink - grep failed with $ret"
133 # Test creating a good symlink and deleting it by path.
136 tmpfile=$PREFIX/smbclient.in.$$
137 slink_name="$LOCAL_PATH/slink"
138 slink_target="$LOCAL_PATH/slink_target"
141 ln -s $slink_target $slink_name
147 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
153 if [ $ret != 0 ] ; then
155 echo "failed delete good symlink with error $ret"
161 if [ ! -e $slink_target ] ; then
162 echo "failed delete good symlink - symlink target deleted !"
168 if [ -e $slink_name ] ; then
169 echo "failed delete good symlink - symlink still exists"
179 # Test writing into a read-only directory (logon as guest) fails.
182 prompt="NT_STATUS_ACCESS_DENIED making remote directory"
183 tmpfile=$PREFIX/smbclient.in.$$
186 ## We can't do this as non-root. We always have rights to
187 ## create the directory.
189 if [ "$USERID" != 0 ] ; then
190 echo "skipping test_read_only_dir as non-root"
195 ## We can't do this with an encrypted connection. No credentials
196 ## to set up the channel.
198 if [ "$ADDARGS" = "-e" ] ; then
199 echo "skipping test_read_only_dir with encrypted connection"
208 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT -U% "//$SERVER/$1" -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
214 if [ $ret != 0 ] ; then
216 echo "failed writing into read-only directory with error $ret"
221 echo "$out" | grep "$prompt" >/dev/null 2>&1
224 if [ $ret != 0 ] ; then
226 echo "failed writing into read-only directory - grep failed with $ret"
234 # Test sending a message
237 tmpfile=$PREFIX/message_in.$$
240 Test message from pid $$
243 cmd='$SMBCLIENT "$@" -U$USERNAME%$PASSWORD -M $SERVER -p 139 $ADDARGS -n msgtest < $tmpfile 2>&1'
248 if [ $ret != 0 ] ; then
250 echo "failed sending message to $SERVER with error $ret"
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'
261 if [ $ret != 0 ] ; then
263 echo "failed getting sent message from $SERVER with error $ret"
267 if [ cmp $PREFIX/message_out.$$ $tmpfile != 0 ] ; then
268 echo "failed comparison of message from $SERVER"
275 # Test reading an owner-only file (logon as guest) fails.
276 test_owner_only_file()
278 prompt="NT_STATUS_ACCESS_DENIED opening remote file"
279 tmpfile=$PREFIX/smbclient.in.$$
282 ## We can't do this as non-root. We always have rights to
285 if [ "$USERID" != 0 ] ; then
286 echo "skipping test_owner_only_file as non-root"
291 ## We can't do this with an encrypted connection. No credentials
292 ## to set up the channel.
294 if [ "$ADDARGS" = "-e" ] ; then
295 echo "skipping test_owner_only_file with encrypted connection"
304 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U% //$SERVER/ro-tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
310 if [ $ret != 0 ] ; then
312 echo "failed reading owner-only file with error $ret"
316 echo "$out" | grep "$prompt" >/dev/null 2>&1
319 if [ $ret != 0 ] ; then
321 echo "failed reading owner-only file - grep failed with $ret"
328 # Test accessing an msdfs path.
331 tmpfile=$PREFIX/smbclient.in.$$
332 prompt=" msdfs-target "
334 cmd='$SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/msdfs-share -I $SERVER_IP $ADDARGS -m nt1 -c dir 2>&1'
338 if [ $ret != 0 ] ; then
340 echo "failed listing msfds-share\ with error $ret"
351 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/msdfs-share -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
357 if [ $ret != 0 ] ; then
359 echo "failed accessing \\msdfs-src1 link with error $ret"
363 echo "$out" | grep "$prompt" >/dev/null 2>&1
366 if [ $ret != 0 ] ; then
368 echo "failed listing \\msdfs-src1 - grep failed with $ret"
374 cd \\deeppath\\msdfs-src2
379 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/msdfs-share -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
385 if [ $ret != 0 ] ; then
387 echo "failed accessing \\deeppath\\msdfs-src2 link with error $ret"
391 echo "$out" | grep "$prompt" >/dev/null 2>&1
394 if [ $ret != 0 ] ; then
396 echo "failed listing \\deeppath\\msdfs-src2 - grep failed with $ret"
403 # Archive bits are correctly set on file/dir creation and rename.
404 test_rename_archive_bit()
406 prompt_file="attributes: A (20)"
407 prompt_dir="attributes: D (10)"
408 tmpfile="$PREFIX/smbclient.in.$$"
410 filename_ren="bar.$$"
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"
423 # Create a new file, ensure it has 'A' attributes.
433 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
439 if [ $ret != 0 ] ; then
441 echo "failed creating file $filename with error $ret"
445 echo "$out" | grep "$prompt_file" >/dev/null 2>&1
453 if [ $ret != 0 ] ; then
455 echo "Attributes incorrect on new file $ret"
459 # Now check if we remove 'A' and rename, the A comes back.
466 ren $filename $filename_ren
467 allinfo $filename_ren
471 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
477 if [ $ret != 0 ] ; then
479 echo "failed creating file and renaming $filename with error $ret"
483 echo "$out" | grep "$prompt_file" >/dev/null 2>&1
491 if [ $ret != 0 ] ; then
493 echo "Attributes incorrect on renamed file $ret"
497 rm -rf $local_dir_name1
498 rm -rf $local_dir_name2
500 # Create a new directory, ensure it has 'D' but not 'A' attributes.
508 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
514 if [ $ret != 0 ] ; then
516 echo "failed creating directory $dirname with error $ret"
520 echo "$out" | grep "$prompt_dir" >/dev/null 2>&1
524 rm -rf $local_dir_name1
525 rm -rf $local_dir_name2
527 if [ $ret != 0 ] ; then
529 echo "Attributes incorrect on new directory $ret"
533 # Now check if we rename, we still only have 'D' attributes
537 ren $dirname $dirname_ren
542 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
548 if [ $ret != 0 ] ; then
550 echo "failed creating directory $dirname and renaming with error $ret"
554 echo "$out" | grep "$prompt_dir" >/dev/null 2>&1
561 if [ $ret != 0 ] ; then
563 echo "Attributes incorrect on renamed directory $ret"
570 # Test authenticating using the winbind ccache
573 $WBINFO --ccache-save="${USERNAME}%${PASSWORD}"
576 if [ $ret != 0 ] ; then
577 echo "wbinfo failed to store creds in cache (user='${USERNAME}', pass='${PASSWORD}')"
581 $SMBCLIENT //$SERVER_IP/tmp -C -U "${USERNAME}" $ADDARGS -c quit 2>&1
584 if [ $ret != 0 ] ; then
585 echo "smbclient failed to use cached credentials"
589 $WBINFO --ccache-save="${USERNAME}%GarBage"
592 if [ $ret != 0 ] ; then
593 echo "wbinfo failed to store creds in cache (user='${USERNAME}', pass='GarBage')"
597 $SMBCLIENT //$SERVER_IP/tmp -C -U "${USERNAME}" $ADDARGS -c quit 2>&1
600 if [ $ret -eq 0 ] ; then
601 echo "smbclient succeeded with wrong cached credentials"
608 # Test authenticating using the winbind ccache
611 tmpfile=$PREFIX/smbclient.in.$$
617 $SMBCLIENT //$SERVER_IP/tmp --authentication-file=$tmpfile $ADDARGS -c quit 2>&1
621 if [ $ret != 0 ] ; then
622 echo "smbclient failed to use auth file"
631 $SMBCLIENT //$SERVER_IP/tmp --authentication-file=$tmpfile $ADDARGS -c quit 2>&1
635 if [ $ret -eq 0 ] ; then
636 echo "smbclient succeeded with wrong auth file credentials"
641 # Test doing a directory listing with backup privilege.
642 test_backup_privilege_list()
644 tmpfile=$PREFIX/smbclient_backup_privilege_list
646 # If we don't have a DOMAIN component to the username, add it.
647 echo "$USERNAME" | grep '\\' 2>&1
649 if [ $ret != 0 ] ; then
650 priv_username="$DOMAIN\\$USERNAME"
652 priv_username=$USERNAME
655 $NET sam rights grant $priv_username SeBackupPrivilege 2>&1
657 if [ $ret != 0 ] ; then
658 echo "Failed to add SeBackupPrivilege to user $priv_username - $ret"
668 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
674 if [ $ret != 0 ] ; then
676 echo "failed backup privilege list $ret"
680 # Now remove all privileges from this SID.
681 $NET sam rights revoke $priv_username SeBackupPrivilege 2>&1
683 if [ $ret != 0 ] ; then
684 echo "failed to remove SeBackupPrivilege from user $priv_username - $ret"
689 # Test accessing an share with bad names (won't convert).
693 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/badname-tmp -I $SERVER_IP $ADDARGS -mNT1 -c ls 2>&1'
698 if [ $ret != 0 ] ; then
700 echo "failed accessing badname-tmp (SMB1) with error $ret"
704 echo "$out" | wc -l 2>&1 | grep 5
706 if [ $ret != 0 ] ; then
708 echo "failed listing \\badname-tmp - grep of number of lines (1) failed with $ret"
712 echo "$out" | grep '^ \. *D'
714 if [ $ret != 0 ] ; then
716 echo "failed listing \\badname-tmp - grep (1) failed with $ret"
720 echo "$out" | grep '^ \.\. *D'
722 if [ $ret != 0 ] ; then
724 echo "failed listing \\badname-tmp - grep (2) failed with $ret"
728 echo "$out" | grep '^ blank.txt *N'
730 if [ $ret != 0 ] ; then
732 echo "failed listing \\badname-tmp - grep (3) failed with $ret"
736 echo "$out" | grep '^ *$'
738 if [ $ret != 0 ] ; then
740 echo "failed listing \\badname-tmp - grep (4) failed with $ret"
744 echo "$out" | grep 'blocks of size.*blocks available'
746 if [ $ret != 0 ] ; then
748 echo "failed listing \\badname-tmp - grep (5) failed with $ret"
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'
758 if [ $ret != 0 ] ; then
760 echo "failed accessing badname-tmp (SMB3) with error $ret"
764 echo "$out" | wc -l 2>&1 | grep 5
766 if [ $ret != 0 ] ; then
768 echo "failed listing \\badname-tmp - SMB3 grep of number of lines (1) failed with $ret"
772 echo "$out" | grep '^ \. *D'
774 if [ $ret != 0 ] ; then
776 echo "failed listing \\badname-tmp - SMB3 grep (1) failed with $ret"
780 echo "$out" | grep '^ \.\. *D'
782 if [ $ret != 0 ] ; then
784 echo "failed listing \\badname-tmp - SMB3 grep (2) failed with $ret"
788 echo "$out" | grep '^ blank.txt *N'
790 if [ $ret != 0 ] ; then
792 echo "failed listing \\badname-tmp - SMB3 grep (3) failed with $ret"
796 echo "$out" | grep '^ *$'
798 if [ $ret != 0 ] ; then
800 echo "failed listing \\badname-tmp - SMB3 grep (4) failed with $ret"
804 echo "$out" | grep 'blocks of size.*blocks available'
806 if [ $ret != 0 ] ; then
808 echo "failed listing \\badname-tmp - SMB3 grep (5) failed with $ret"
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).
817 tmpfile=$PREFIX/smbclient_interactive_prompt_commands
824 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/manglenames_share -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
830 if [ $ret != 0 ] ; then
832 echo "failed accessing manglenames_share with error $ret"
836 echo "$out" | grep 'NT_STATUS'
838 if [ $ret == 0 ] ; then
840 echo "failed - NT_STATUS_XXXX listing \\manglenames_share\\FF4GBY~Q"
845 # Test using scopy to copy a file on the server.
848 tmpfile=$PREFIX/smbclient_interactive_prompt_commands
849 scopy_file=$PREFIX/scopy_file
854 scopy smbclient scopy_file
862 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS -mSMB3 < $tmpfile 2>&1'
866 out1=`md5sum ${SMBCLIENT} | sed -e 's/ .*//'`
867 out2=`md5sum ${scopy_file} | sed -e 's/ .*//'`
871 if [ $ret != 0 ] ; then
873 echo "failed scopy test (1) with output $ret"
877 if [ $out1 != $out2 ] ; then
879 echo "failed md5sum (1)"
884 # Now do again using SMB1
885 # to force client-side fallback.
890 scopy smbclient scopy_file
897 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS -mNT1 < $tmpfile 2>&1'
901 out1=`md5sum ${SMBCLIENT} | sed -e 's/ .*//'`
902 out2=`md5sum ${scopy_file} | sed -e 's/ .*//'`
906 if [ $ret != 0 ] ; then
908 echo "failed scopy test (2) with output $ret"
912 if [ $out1 != $out2 ] ; then
914 echo "failed md5sum (2)"
919 # Test creating a stream on the root of the share directory filname - :foobar
920 test_toplevel_stream()
922 tmpfile=$PREFIX/smbclient_interactive_prompt_commands
924 put ${PREFIX}/smbclient_interactive_prompt_commands :foobar
930 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS -mSMB3 < $tmpfile 2>&1'
936 if [ $ret != 0 ] ; then
938 echo "failed creating toplevel stream :foobar with error $ret"
942 echo "$out" | grep '^stream:.*:foobar'
944 if [ $ret != 0 ] ; then
946 echo "failed creating toplevel stream :foobar"
951 # Test wide links are restricted.
954 tmpfile=$PREFIX/smbclient_interactive_prompt_commands
960 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/widelinks_share -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
966 if [ $ret != 0 ] ; then
968 echo "failed accessing widelinks_share with error $ret"
972 echo "$out" | grep 'NT_STATUS'
974 if [ $ret == 0 ] ; then
976 echo "failed - NT_STATUS_XXXX listing \\widelinks_share\\dot"
984 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/widelinks_share -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
990 if [ $ret != 0 ] ; then
992 echo "failed accessing widelinks_share with error $ret"
996 # This should fail with NT_STATUS_ACCESS_DENIED
997 echo "$out" | grep 'NT_STATUS_ACCESS_DENIED'
999 if [ $ret != 0 ] ; then
1001 echo "failed - should get NT_STATUS_ACCESS_DENIED listing \\widelinks_share\\source"
1006 # Test creating then deleting a stream file doesn't leave a lost-XXXXX directory.
1007 test_streams_depot_delete()
1009 tmpfile=$PREFIX/smbclient_interactive_prompt_commands
1010 rm -rf "$LOCAL_PATH/lost-*"
1012 cat > $tmpfile <<EOF
1013 put ${PREFIX}/smbclient_interactive_prompt_commands foo:bar
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'
1025 if [ $ret != 0 ] ; then
1027 echo "failed creating then deleting foo:bar with error $ret"
1031 echo "$out" | grep 'NT_STATUS_NO_SUCH_FILE listing \\lost\*'
1033 if [ $ret != 0 ] ; then
1035 echo "deleting foo:bar left lost-XXX directory"
1036 rm -rf "$LOCAL_PATH/lost-*"
1041 # Test follow symlinks can't access symlinks
1045 test_dir="$LOCAL_PATH/nosymlinks/test"
1047 slink_name="$test_dir/source"
1048 slink_target="$test_dir/target"
1049 foobar_dir="$test_dir/foo/bar"
1050 get_target="$test_dir/foo/bar/testfile"
1055 echo "$slink_target" > $slink_target
1056 ln -s $slink_target $slink_name
1058 mkdir -p $foobar_dir
1059 echo "$get_target" > $get_target
1061 # Getting a file through a symlink name should fail.
1062 tmpfile=$PREFIX/smbclient_interactive_prompt_commands
1063 cat > $tmpfile <<EOF
1067 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/nosymlinks -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1073 if [ $ret -ne 0 ] ; then
1075 echo "failed accessing nosymlinks with error $ret"
1079 echo "$out" | grep 'NT_STATUS_ACCESS_DENIED'
1081 if [ $ret -ne 0 ] ; then
1083 echo "failed - should get NT_STATUS_ACCESS_DENIED getting \\nosymlinks\\source"
1087 # But we should be able to create and delete directories.
1088 cat > $tmpfile <<EOF
1093 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/nosymlinks -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1099 if [ $ret -ne 0 ] ; then
1101 echo "failed accessing nosymlinks with error $ret"
1105 echo "$out" | grep 'NT_STATUS'
1107 if [ $ret -eq 0 ] ; then
1109 echo "failed - NT_STATUS_XXXX doing mkdir a; mkdir a\\b on \\nosymlinks"
1113 # Ensure regular file/directory access also works.
1114 cat > $tmpfile <<EOF
1120 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/nosymlinks -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1126 if [ $ret -ne 0 ] ; then
1128 echo "failed accessing nosymlinks with error $ret"
1132 echo "$out" | grep 'NT_STATUS'
1134 if [ $ret -eq 0 ] ; then
1136 echo "failed - NT_STATUS_XXXX doing cd foo\\bar; get testfile on \\nosymlinks"
1141 # Test we can follow normal symlinks.
1142 # Bug: https://bugzilla.samba.org/show_bug.cgi?id=12860
1143 # Note - this needs to be tested over SMB3, not SMB1.
1145 test_local_symlinks()
1148 LOCAL_RAWARGS="${CONFIGURATION} -mSMB3"
1149 LOCAL_ADDARGS="${LOCAL_RAWARGS} $*"
1151 share_test_dir="test"
1152 share_slink_target_dir="$share_test_dir/dir1"
1154 local_test_dir="$LOCAL_PATH/local_symlinks/$share_test_dir"
1155 local_slink_name="$local_test_dir/sym_name"
1156 local_slink_target_dir="$local_test_dir/dir1"
1158 rm -rf $local_test_dir
1160 # Create the initial directories
1161 tmpfile=$PREFIX/smbclient_interactive_prompt_commands
1162 cat > $tmpfile <<EOF
1163 mkdir $share_test_dir
1164 mkdir $share_slink_target_dir
1168 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/local_symlinks -I $SERVER_IP $LOCAL_ADDARGS < $tmpfile 2>&1'
1174 if [ $ret -ne 0 ] ; then
1176 echo "failed accessing local_symlinks with error $ret"
1181 echo "$out" | grep 'NT_STATUS_'
1183 if [ $ret -eq 0 ] ; then
1185 echo "failed - got an NT_STATUS error"
1190 # Create the symlink locally
1191 ln -s $local_slink_target_dir $local_slink_name
1193 if [ $ret -ne 0 ] ; then
1195 echo "failed - unable to create symlink"
1196 ls -la $local_test_dir
1201 # Can we cd into the symlink name and ls ?
1202 tmpfile=$PREFIX/smbclient_interactive_prompt_commands
1203 cat > $tmpfile <<EOF
1204 cd $share_test_dir\\sym_name
1208 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/local_symlinks -I $SERVER_IP $LOCAL_ADDARGS < $tmpfile 2>&1'
1214 if [ $ret -ne 0 ] ; then
1216 echo "failed accessing local_symlinks with error $ret"
1221 echo "$out" | grep 'NT_STATUS_'
1223 if [ $ret -eq 0 ] ; then
1225 echo "failed - got an NT_STATUS error"
1231 rm -f $local_slink_name
1233 tmpfile=$PREFIX/smbclient_interactive_prompt_commands
1234 cat > $tmpfile <<EOF
1235 deltree $share_test_dir
1238 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/local_symlinks -I $SERVER_IP $LOCAL_ADDARGS < $tmpfile 2>&1'
1244 if [ $ret -ne 0 ] ; then
1246 echo "failed accessing local_symlinks with error $ret"
1251 echo "$out" | grep 'NT_STATUS_'
1253 if [ $ret -eq 0 ] ; then
1255 echo "failed - got an NT_STATUS error"
1261 # Test smbclient deltree command
1264 tmpfile=$PREFIX/smbclient_interactive_prompt_commands
1265 deltree_dir=$PREFIX/deltree_dir
1268 cat > $tmpfile <<EOF
1270 mkdir deltree_dir/foo
1271 mkdir deltree_dir/foo/bar
1272 put ${SMBCLIENT} deltree_dir/foo/bar/client
1276 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1281 if [ $ret != 0 ] ; then
1283 echo "failed deltree test with output $ret"
1288 echo "$out" | grep 'NT_STATUS_'
1290 if [ $ret -eq 0 ] ; then
1292 echo "failed - got an NT_STATUS error"
1297 if [ -d $deltree_dir ] ; then
1298 echo "deltree did not delete everything"
1304 # Test smbclient setmode command
1307 tmpfile=$PREFIX/smbclient_interactive_prompt_commands
1309 cat > $tmpfile <<EOF
1311 put ${SMBCLIENT} test_setmode
1312 setmode test_setmode +r +s +h +a
1313 allinfo test_setmode
1314 setmode test_setmode -rsha
1315 allinfo test_setmode
1319 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1324 if [ $ret != 0 ] ; then
1326 echo "failed setmode test with output $ret"
1331 echo "$out" | grep 'attributes: RHSA'
1333 if [ $ret -ne 0 ] ; then
1335 echo "failed - should get attributes: RHSA"
1340 echo "$out" | grep 'attributes: (80)'
1342 if [ $ret -ne 0 ] ; then
1344 echo "failed - should also get attributes: (80)"
1351 test_server_os_message()
1353 tmpfile=$PREFIX/smbclient_interactive_prompt_commands
1354 cat > $tmpfile <<EOF
1358 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1364 if [ $ret -ne 0 ] ; then
1366 echo "failed to connect error $ret"
1370 echo "$out" | grep 'Try "help" do get a list of possible commands.'
1372 if [ $ret -ne 0 ] ; then
1374 echo 'failed - should get: Try "help" do get a list of possible commands.'
1381 LOGDIR_PREFIX=test_smbclient_s3
1383 # possibly remove old logdirs:
1385 for OLDDIR in $(find ${PREFIX} -type d -name "${LOGDIR_PREFIX}_*") ; do
1386 echo "removing old directory ${OLDDIR}"
1390 LOGDIR=$(mktemp -d ${PREFIX}/${LOGDIR_PREFIX}_XXXXXX)
1393 testit "smbclient -L $SERVER_IP" $SMBCLIENT -L $SERVER_IP -N -p 139 ${RAWARGS} || failed=`expr $failed + 1`
1394 testit "smbclient -L $SERVER -I $SERVER_IP" $SMBCLIENT -L $SERVER -I $SERVER_IP -N -p 139 ${RAWARGS} -c quit || failed=`expr $failed + 1`
1396 testit "noninteractive smbclient does not prompt" \
1397 test_noninteractive_no_prompt || \
1398 failed=`expr $failed + 1`
1400 testit "noninteractive smbclient -l does not prompt" \
1401 test_noninteractive_no_prompt -l $LOGDIR || \
1402 failed=`expr $failed + 1`
1404 testit "interactive smbclient prompts on stdout" \
1405 test_interactive_prompt_stdout || \
1406 failed=`expr $failed + 1`
1408 testit "interactive smbclient -l prompts on stdout" \
1409 test_interactive_prompt_stdout -l $LOGDIR || \
1410 failed=`expr $failed + 1`
1412 testit "creating a bad symlink and deleting it" \
1413 test_bad_symlink || \
1414 failed=`expr $failed + 1`
1416 testit "creating a good symlink and deleting it by path" \
1417 test_good_symlink || \
1418 failed=`expr $failed + 1`
1420 testit "writing into a read-only directory fails" \
1421 test_read_only_dir ro-tmp || \
1422 failed=`expr $failed + 1`
1424 testit "writing into a read-only share fails" \
1425 test_read_only_dir valid-users-tmp || \
1426 failed=`expr $failed + 1`
1428 testit "Reading a owner-only file fails" \
1429 test_owner_only_file || \
1430 failed=`expr $failed + 1`
1432 testit "Accessing an MS-DFS link" \
1433 test_msdfs_link || \
1434 failed=`expr $failed + 1`
1436 testit "Ensure archive bit is set correctly on file/dir rename" \
1437 test_rename_archive_bit || \
1438 failed=`expr $failed + 1`
1440 testit "ccache access works for smbclient" \
1441 test_ccache_access || \
1442 failed=`expr $failed + 1`
1444 testit "sending a message to the remote server" \
1446 failed=`expr $failed + 1`
1448 testit "using an authentication file" \
1450 failed=`expr $failed + 1`
1452 testit "list with backup privilege" \
1453 test_backup_privilege_list || \
1454 failed=`expr $failed + 1`
1456 testit "list a share with bad names (won't convert)" \
1458 failed=`expr $failed + 1`
1460 testit "list a share with a mangled name + acl_xattr object" \
1461 test_mangled_names || \
1462 failed=`expr $failed + 1`
1464 testit "server-side file copy" \
1466 failed=`expr $failed + 1`
1468 testit "creating a :stream at root of share" \
1469 test_toplevel_stream || \
1470 failed=`expr $failed + 1`
1472 testit "Ensure widelinks are restricted" \
1474 failed=`expr $failed + 1`
1476 testit "streams_depot can delete correctly" \
1477 test_streams_depot_delete || \
1478 failed=`expr $failed + 1`
1480 testit "follow symlinks = no" \
1481 test_nosymlinks || \
1482 failed=`expr $failed + 1`
1484 testit "follow local symlinks" \
1485 test_local_symlinks || \
1486 failed=`expr $failed + 1`
1488 testit "smbclient deltree command" \
1490 failed=`expr $failed + 1`
1492 testit "server os message" \
1493 test_server_os_message || \
1494 failed=`expr $failed + 1`
1496 testit "setmode test" \
1498 failed=`expr $failed + 1`
1500 testit "rm -rf $LOGDIR" \
1502 failed=`expr $failed + 1`