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 # 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
()
45 cmd
='echo du | $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS 2>&1'
55 echo "$out" |
grep $prompt >/dev
/null
2>&1
58 # got a prompt .. fail
59 echo matched interactive prompt
in non-interactive mode
66 # Test that an interactive smbclient prompts to stdout
67 test_interactive_prompt_stdout
()
70 tmpfile
=$PREFIX/smbclient_interactive_prompt_commands
77 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
83 if [ $ret != 0 ]; then
89 echo "$out" |
grep $prompt >/dev
/null
2>&1
92 echo failed to match interactive prompt on stdout
99 # Test creating a bad symlink and deleting it.
102 prompt
="posix_unlink deleted file /newname"
103 tmpfile
=$PREFIX/smbclient_bad_symlinks_commands
108 symlink badname newname
113 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
119 if [ $ret != 0 ]; then
121 echo "failed create then delete bad symlink with error $ret"
125 echo "$out" |
grep "$prompt" >/dev
/null
2>&1
128 if [ $ret != 0 ]; then
130 echo "failed create then delete bad symlink - grep failed with $ret"
137 # Test creating a good symlink and deleting it by path.
140 tmpfile
=$PREFIX/smbclient.
in.$$
141 slink_name
="$LOCAL_PATH/slink"
142 slink_target
="$LOCAL_PATH/slink_target"
145 ln -s $slink_target $slink_name
151 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
157 if [ $ret != 0 ]; then
159 echo "failed delete good symlink with error $ret"
165 if [ ! -e $slink_target ]; then
166 echo "failed delete good symlink - symlink target deleted !"
172 if [ -e $slink_name ]; then
173 echo "failed delete good symlink - symlink still exists"
183 # Test writing into a read-only directory (logon as guest) fails.
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"
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"
212 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT -U% "//$SERVER/$1" -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
218 if [ $ret != 0 ]; then
220 echo "failed writing into read-only directory with error $ret"
225 echo "$out" |
grep "$prompt" >/dev
/null
2>&1
228 if [ $ret != 0 ]; then
230 echo "failed writing into read-only directory - grep failed with $ret"
237 # Test sending a message
240 tmpfile
=$PREFIX/message_in.$$
243 Test message from pid $$
246 cmd
='$SMBCLIENT "$@" -U$USERNAME%$PASSWORD -M $SERVER -p 139 $ADDARGS -n msgtest < $tmpfile 2>&1'
251 if [ $ret != 0 ]; then
253 echo "failed sending message to $SERVER with error $ret"
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'
264 if [ $ret != 0 ]; then
266 echo "failed getting sent message from $SERVER with error $ret"
270 if cmp $PREFIX/message_out.$$
$tmpfile; then
271 echo "failed comparison of message from $SERVER"
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
288 if [ "$USERID" != 0 ]; then
289 echo "skipping test_owner_only_file as non-root"
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"
307 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U% //$SERVER/ro-tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
313 if [ $ret != 0 ]; then
315 echo "failed reading owner-only file with error $ret"
319 echo "$out" |
grep "$prompt" >/dev
/null
2>&1
322 if [ $ret != 0 ]; then
324 echo "failed reading owner-only file - grep failed with $ret"
331 # Test accessing an msdfs path.
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'
341 if [ $ret != 0 ]; then
343 echo "failed listing msfds-share\ with error $ret"
354 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/msdfs-share -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
360 if [ $ret != 0 ]; then
362 echo "failed accessing \\msdfs-src1 link with error $ret"
366 echo "$out" |
grep "$prompt" >/dev
/null
2>&1
369 if [ $ret != 0 ]; then
371 echo "failed listing \\msdfs-src1 - grep failed with $ret"
377 cd \\deeppath\\msdfs-src2
382 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/msdfs-share -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
388 if [ $ret != 0 ]; then
390 echo "failed accessing \\deeppath\\msdfs-src2 link with error $ret"
394 echo "$out" |
grep "$prompt" >/dev
/null
2>&1
397 if [ $ret != 0 ]; then
399 echo "failed listing \\deeppath\\msdfs-src2 - grep failed with $ret"
406 # Test recursive listing across msdfs links
407 test_msdfs_recursive_dir
()
409 tmpfile
=$PREFIX/smbclient.
in.$$
417 cmd
='$SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/msdfs-share -I $SERVER_IP $ADDARGS -m $PROTOCOL < $tmpfile 2>&1'
421 if [ "$ret" -ne 0 ]; then
423 echo "failed listing msfds-share\ with error $ret"
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
430 if [ "$ret" -ne 0 ]; then
432 echo "Listing \\msdfs-share recursively did not properly end in symlink recursion"
438 # Test doing a normal file rename on an msdfs path.
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.
455 ren $filename_src $filename_dst -f
456 ren $filename_dst $filename_src
461 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/msdfs-share -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
466 rm -f "$filename_src_path"
468 if [ $ret != 0 ]; then
470 echo "failed renaming $filename_src $filename_dst with error $ret"
474 echo "$out" |
grep "NT_STATUS" >/dev
/null
2>&1
477 if [ "$ret" -eq 0 ]; then
479 echo "renaming $filename_src $filename_dst got NT_STATUS_ error"
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"
498 hardlink $filename_src $filename_dst
504 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/msdfs-share -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
509 rm -f "$filename_src_path"
511 if [ $ret != 0 ]; then
513 echo "failed hardlink $filename_src $filename_dst with error $ret"
517 echo "$out" |
grep "NT_STATUS" >/dev
/null
2>&1
520 if [ "$ret" -eq 0 ]; then
522 echo "hardlink $filename_src $filename_dst got NT_STATUS_ error"
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"
545 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/msdfs-share -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
550 rm -f "$filename_src_path"
552 if [ $ret != 0 ] ; then
554 echo "failed deleting $filename_src with error $ret"
558 echo "$out" |
grep "NT_STATUS" >/dev
/null
2>&1
561 if [ "$ret" -eq 0 ] ; then
563 echo "del $filename_src NT_STATUS_ error"
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"
591 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/msdfs-share -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
596 rm -f "$filename_src_path"
597 rm -f "$dirname_src_path"
599 if [ $ret != 0 ] ; then
601 echo "deltree failed deleting dir $dirname_src with error $ret"
605 echo "$out" |
grep "NT_STATUS" >/dev
/null
2>&1
608 if [ "$ret" -eq 0 ] ; then
610 echo "deltree $dirname_src NT_STATUS_ error"
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.$$"
623 filename_ren
="bar.$$"
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"
636 # Create a new file, ensure it has 'A' attributes.
646 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
652 if [ $ret != 0 ]; then
654 echo "failed creating file $filename with error $ret"
658 echo "$out" |
grep "$prompt_file" >/dev
/null
2>&1
666 if [ $ret != 0 ]; then
668 echo "Attributes incorrect on new file $ret"
672 # Now check if we remove 'A' and rename, the A comes back.
679 ren $filename $filename_ren
680 allinfo $filename_ren
684 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
690 if [ $ret != 0 ]; then
692 echo "failed creating file and renaming $filename with error $ret"
696 echo "$out" |
grep "$prompt_file" >/dev
/null
2>&1
704 if [ $ret != 0 ]; then
706 echo "Attributes incorrect on renamed file $ret"
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.
721 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
727 if [ $ret != 0 ]; then
729 echo "failed creating directory $dirname with error $ret"
733 echo "$out" |
grep "$prompt_dir" >/dev
/null
2>&1
737 rm -rf $local_dir_name1
738 rm -rf $local_dir_name2
740 if [ $ret != 0 ]; then
742 echo "Attributes incorrect on new directory $ret"
746 # Now check if we rename, we still only have 'D' attributes
750 ren $dirname $dirname_ren
755 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
761 if [ $ret != 0 ]; then
763 echo "failed creating directory $dirname and renaming with error $ret"
767 echo "$out" |
grep "$prompt_dir" >/dev
/null
2>&1
774 if [ $ret != 0 ]; then
776 echo "Attributes incorrect on renamed directory $ret"
783 # Test authenticating using the winbind ccache
786 $WBINFO --ccache-save="${USERNAME}%${PASSWORD}"
789 if [ $ret != 0 ]; then
790 echo "wbinfo failed to store creds in cache (user='${USERNAME}', pass='${PASSWORD}')"
794 $SMBCLIENT //$SERVER_IP/tmp
--use-winbind-ccache -U "${USERNAME}" $ADDARGS -c quit
2>&1
797 if [ $ret != 0 ]; then
798 echo "smbclient failed to use cached credentials"
802 $WBINFO --ccache-save="${USERNAME}%GarBage"
805 if [ $ret != 0 ]; then
806 echo "wbinfo failed to store creds in cache (user='${USERNAME}', pass='GarBage')"
810 $SMBCLIENT //$SERVER_IP/tmp
--use-winbind-ccache -U "${USERNAME}" $ADDARGS -c quit
2>&1
813 if [ $ret -eq 0 ]; then
814 echo "smbclient succeeded with wrong cached credentials"
821 # Test authenticating using the winbind ccache
824 tmpfile
=$PREFIX/smbclient.
in.$$
830 $SMBCLIENT //$SERVER_IP/tmp
--authentication-file=$tmpfile $ADDARGS -c quit
2>&1
834 if [ $ret != 0 ]; then
835 echo "smbclient failed to use auth file"
844 $SMBCLIENT //$SERVER_IP/tmp
--authentication-file=$tmpfile $ADDARGS -c quit
2>&1
848 if [ $ret -eq 0 ]; then
849 echo "smbclient succeeded with wrong auth file credentials"
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
866 if [ $ret != 0 ]; then
867 priv_username
="$DOMAIN\\$USER_TMP"
869 priv_username
="$USER_TMP"
872 $NET sam rights grant
$priv_username SeBackupPrivilege
2>&1
874 if [ $ret != 0 ]; then
875 echo "Failed to add SeBackupPrivilege to user $priv_username - $ret"
885 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
891 if [ $ret != 0 ]; then
893 echo "failed backup privilege list $ret"
897 # Now remove all privileges from this SID.
898 $NET sam rights revoke
$priv_username SeBackupPrivilege
2>&1
900 if [ $ret != 0 ]; then
901 echo "failed to remove SeBackupPrivilege from user $priv_username - $ret"
906 # Test accessing an share with bad names (won't convert).
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'
917 if [ $ret != 0 ]; then
919 echo "failed accessing badname-tmp (SMB1) with error $ret"
923 echo "$out" |
wc -l 2>&1 |
grep 5
925 if [ $ret != 0 ]; then
927 echo "failed listing \\badname-tmp - grep of number of lines (1) failed with $ret"
931 echo "$out" |
grep '^ \. *D'
933 if [ $ret != 0 ]; then
935 echo "failed listing \\badname-tmp - grep (1) failed with $ret"
939 echo "$out" |
grep '^ \.\. *D'
941 if [ $ret != 0 ]; then
943 echo "failed listing \\badname-tmp - grep (2) failed with $ret"
947 echo "$out" |
grep '^ blank.txt *N'
949 if [ $ret != 0 ]; then
951 echo "failed listing \\badname-tmp - grep (3) failed with $ret"
955 echo "$out" |
grep '^ *$'
957 if [ $ret != 0 ]; then
959 echo "failed listing \\badname-tmp - grep (4) failed with $ret"
963 echo "$out" |
grep 'blocks of size.*blocks available'
965 if [ $ret != 0 ]; then
967 echo "failed listing \\badname-tmp - grep (5) failed with $ret"
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'
980 if [ $ret != 0 ]; then
982 echo "failed accessing badname-tmp (SMB3) with error $ret"
986 echo "$out" |
wc -l 2>&1 |
grep 5
988 if [ $ret != 0 ]; then
990 echo "failed listing \\badname-tmp - SMB3 grep of number of lines (1) failed with $ret"
994 echo "$out" |
grep '^ \. *D'
996 if [ $ret != 0 ]; then
998 echo "failed listing \\badname-tmp - SMB3 grep (1) failed with $ret"
1002 echo "$out" |
grep '^ \.\. *D'
1004 if [ $ret != 0 ]; then
1006 echo "failed listing \\badname-tmp - SMB3 grep (2) failed with $ret"
1010 echo "$out" |
grep '^ blank.txt *N'
1012 if [ $ret != 0 ]; then
1014 echo "failed listing \\badname-tmp - SMB3 grep (3) failed with $ret"
1018 echo "$out" |
grep '^ *$'
1020 if [ $ret != 0 ]; then
1022 echo "failed listing \\badname-tmp - SMB3 grep (4) failed with $ret"
1026 echo "$out" |
grep 'blocks of size.*blocks available'
1028 if [ $ret != 0 ]; then
1030 echo "failed listing \\badname-tmp - SMB3 grep (5) failed with $ret"
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
1047 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/manglenames_share -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1053 if [ $ret != 0 ]; then
1055 echo "failed accessing manglenames_share with error $ret"
1059 echo "$out" |
grep 'NT_STATUS'
1061 if [ $ret = 0 ]; then
1063 echo "failed - NT_STATUS_XXXX listing \\manglenames_share\\FF4GBY~Q"
1068 # Test using scopy to copy a file on the server.
1071 tmpfile
=$PREFIX/smbclient_interactive_prompt_commands
1072 scopy_file
=$PREFIX/scopy_file
1077 scopy smbclient scopy_file
1084 if [ $PROTOCOL = "SMB3" ]; then
1086 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS -m$PROTOOCL < $tmpfile 2>&1'
1090 out1
=$
(md5sum ${SMBCLIENT} |
sed -e 's/ .*//')
1091 out2
=$
(md5sum ${scopy_file} |
sed -e 's/ .*//')
1095 if [ $ret != 0 ]; then
1097 echo "failed scopy test (1) with output $ret"
1101 if [ $out1 != $out2 ]; then
1103 echo "failed md5sum (1)"
1108 # Now do again using SMB1
1109 # to force client-side fallback.
1112 if [ $PROTOCOL = "NT1" ]; then
1115 scopy smbclient scopy_file
1122 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS -m$PROTOCOL < $tmpfile 2>&1'
1126 out1
=$
(md5sum ${SMBCLIENT} |
sed -e 's/ .*//')
1127 out2
=$
(md5sum ${scopy_file} |
sed -e 's/ .*//')
1131 if [ $ret != 0 ]; then
1133 echo "failed scopy test (2) with output $ret"
1137 if [ $out1 != $out2 ]; then
1139 echo "failed md5sum (2)"
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
1150 put ${PREFIX}/smbclient_interactive_prompt_commands :foobar
1156 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS -mSMB3 < $tmpfile 2>&1'
1162 if [ $ret != 0 ]; then
1164 echo "failed creating toplevel stream :foobar with error $ret"
1168 echo "$out" |
grep '^stream:.*:foobar'
1170 if [ $ret != 0 ]; then
1172 echo "failed creating toplevel stream :foobar"
1177 # Test wide links are restricted.
1180 tmpfile
=$PREFIX/smbclient_interactive_prompt_commands
1186 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/widelinks_share -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1192 if [ $ret != 0 ]; then
1194 echo "failed accessing widelinks_share with error $ret"
1198 echo "$out" |
grep 'NT_STATUS'
1200 if [ $ret = 0 ]; then
1202 echo "failed - NT_STATUS_XXXX listing \\widelinks_share\\dot"
1210 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/widelinks_share -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1216 if [ $ret != 0 ]; then
1218 echo "failed accessing widelinks_share with error $ret"
1222 # This should fail with NT_STATUS_OBJECT_NAME_NOT_FOUND
1223 echo "$out" |
grep 'NT_STATUS_OBJECT_NAME_NOT_FOUND'
1225 if [ $ret != 0 ]; then
1227 echo "failed - should get NT_STATUS_OBJECT_NAME_NOT_FOUND listing \\widelinks_share\\source"
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-*"
1239 put ${PREFIX}/smbclient_interactive_prompt_commands foo:bar
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'
1251 if [ $ret != 0 ]; then
1253 echo "failed creating then deleting foo:bar with error $ret"
1257 echo "$out" |
grep 'NT_STATUS_NO_SUCH_FILE listing \\lost\*'
1259 if [ $ret != 0 ]; then
1261 echo "deleting foo:bar left lost-XXX directory"
1262 rm -rf "$LOCAL_PATH/lost-*"
1267 # Test follow symlinks can't access symlinks
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
1290 mkdir $share_test_dir
1291 mkdir $share_foo_dir
1292 mkdir $share_foobar_dir
1295 put $local_nosymlink_target_file
1296 cd /$share_foobar_dir
1297 put $local_foobar_target_file
1301 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/nosymlinks -I $SERVER_IP $LOCAL_ADDARGS < $tmpfile 2>&1'
1306 rm -f $PREFIX/$local_nosymlink_target_file
1307 rm -f $PREFIX/$local_foobar_target_file
1309 if [ $ret -ne 0 ]; then
1311 echo "failed accessing local_symlinks with error $ret"
1316 echo "$out" |
grep 'NT_STATUS_'
1318 if [ $ret -eq 0 ]; then
1320 echo "failed - got an NT_STATUS error"
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
1334 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/nosymlinks -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1340 if [ $ret -ne 0 ]; then
1342 echo "failed accessing nosymlinks with error $ret"
1346 echo "$out" |
grep 'NT_STATUS_OBJECT_NAME_NOT_FOUND'
1348 if [ $ret -ne 0 ]; then
1350 echo "failed - should get NT_STATUS_OBJECT_NAME_NOT_FOUND getting \\nosymlinks\\source"
1354 # But we should be able to create and delete directories.
1360 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/nosymlinks -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1366 if [ $ret -ne 0 ]; then
1368 echo "failed accessing nosymlinks with error $ret"
1372 echo "$out" |
grep 'NT_STATUS'
1374 if [ $ret -eq 0 ]; then
1376 echo "failed - NT_STATUS_XXXX doing mkdir a; mkdir a\\b on \\nosymlinks"
1380 # Ensure regular file/directory access also works.
1387 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/nosymlinks -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1393 if [ $ret -ne 0 ]; then
1395 echo "failed accessing nosymlinks with error $ret"
1399 echo "$out" |
grep 'NT_STATUS'
1401 if [ $ret -eq 0 ]; then
1403 echo "failed - NT_STATUS_XXXX doing cd foo\\bar; get testfile on \\nosymlinks"
1408 rm -f $local_slink_name
1414 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/nosymlinks -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1420 if [ $ret -ne 0 ]; then
1422 echo "failed accessing nosymlinks with error $ret"
1426 echo "$out" |
grep 'NT_STATUS'
1428 if [ $ret -eq 0 ]; then
1430 echo "failed - NT_STATUS_XXXX doing cd foo\\bar; get testfile on \\nosymlinks"
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
()
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
1457 mkdir $share_test_dir
1458 mkdir $share_slink_target_dir
1462 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/local_symlinks -I $SERVER_IP $LOCAL_ADDARGS < $tmpfile 2>&1'
1468 if [ $ret -ne 0 ]; then
1470 echo "failed accessing local_symlinks with error $ret"
1475 echo "$out" |
grep 'NT_STATUS_'
1477 if [ $ret -eq 0 ]; then
1479 echo "failed - got an NT_STATUS error"
1484 # Create the symlink locally
1485 ln -s $local_slink_target_dir $local_slink_name
1487 if [ $ret -ne 0 ]; then
1489 echo "failed - unable to create symlink"
1490 ls -la $local_test_dir
1495 # Create a file to be accessed behind the symlink
1496 touch $local_slink_target_dir/x
1498 if [ $ret -ne 0 ]; then
1500 echo "failed - unable to create file"
1501 ls -la $local_test_dir
1506 # Can we cd into the symlink name and ls ?
1507 tmpfile
=$PREFIX/smbclient_interactive_prompt_commands
1509 cd $share_test_dir\\sym_name
1513 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/local_symlinks -I $SERVER_IP $LOCAL_ADDARGS < $tmpfile 2>&1'
1519 if [ $ret -ne 0 ]; then
1521 echo "failed accessing local_symlinks with error $ret"
1526 echo "$out" |
grep 'NT_STATUS_'
1528 if [ $ret -eq 0 ]; then
1530 echo "failed - got an NT_STATUS error"
1535 # Can we get the test file behind the symlink'ed dir?
1536 tmpfile
=$PREFIX/smbclient_interactive_prompt_commands
1538 get $share_test_dir\\sym_name\\x -
1541 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/local_symlinks -I $SERVER_IP $LOCAL_ADDARGS < $tmpfile 2>&1'
1547 if [ $ret -ne 0 ]; then
1549 echo "failed accessing local_symlinks with error $ret"
1554 echo "$out" |
grep 'NT_STATUS_'
1556 if [ $ret -eq 0 ]; then
1558 echo "failed - got an NT_STATUS error"
1564 rm -f $local_slink_name
1566 tmpfile
=$PREFIX/smbclient_interactive_prompt_commands
1568 deltree $share_test_dir
1571 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/local_symlinks -I $SERVER_IP $LOCAL_ADDARGS < $tmpfile 2>&1'
1577 if [ $ret -ne 0 ]; then
1579 echo "failed accessing local_symlinks with error $ret"
1584 echo "$out" |
grep 'NT_STATUS_'
1586 if [ $ret -eq 0 ]; then
1588 echo "failed - got an NT_STATUS error"
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'
1604 if [ $ret -eq 0 ]; then
1606 echo "failed accessing no perm share should not work"
1610 num
=$
(echo "$out" |
grep 'NT_STATUS_ACCESS_DENIED' |
wc -l)
1611 if [ "$num" -ne "2" ]; then
1613 echo "failed num[$num] - two NT_STATUS_ACCESS_DENIED lines expected"
1620 # Test smbclient deltree command
1623 tmpfile
=$PREFIX/smbclient_interactive_prompt_commands
1624 deltree_dir
=$PREFIX/deltree_dir
1629 mkdir deltree_dir/foo
1630 mkdir deltree_dir/foo/bar
1631 put ${SMBCLIENT} deltree_dir/foo/bar/client
1635 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1640 if [ $ret != 0 ]; then
1642 echo "failed deltree test with output $ret"
1647 echo "$out" |
grep 'NT_STATUS_'
1649 if [ $ret -eq 0 ]; then
1651 echo "failed - got an NT_STATUS error"
1656 if [ -d $deltree_dir ]; then
1657 echo "deltree did not delete everything"
1663 # Test smbclient setmode command
1666 tmpfile
=$PREFIX/smbclient_interactive_prompt_commands
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
1678 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1683 if [ $ret != 0 ]; then
1685 echo "failed setmode test with output $ret"
1690 echo "$out" |
grep 'attributes: RHSA'
1692 if [ $ret -ne 0 ]; then
1694 echo "failed - should get attributes: RHSA"
1699 echo "$out" |
grep 'attributes: (80)'
1701 if [ $ret -ne 0 ]; then
1703 echo "failed - should also get attributes: (80)"
1709 # Test smbclient utimes command
1712 tmpfile
=$PREFIX/smbclient_interactive_prompt_commands
1723 put ${SMBCLIENT} utimes_test
1725 utimes utimes_test 2016:02:04-06:19:20 17:01:01-05:10:20 -1 -1
1730 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1735 if [ -n "$saved_TZ" ]; then
1736 export TZ
="$saved_TZ"
1740 if [ -n "$saved_LANG" ]; then
1741 export LANG
="$saved_LANG"
1746 if [ $ret != 0 ]; then
1748 echo "failed utimes test with output $ret"
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"
1766 if [ "$num_access" != "2" ]; then
1767 echo "failed - should get two access_time $out"
1771 if [ "$num_write" != "1" ]; then
1772 echo "failed - should only get one write_time $out"
1776 if [ "$num_change" != "1" ]; then
1777 echo "failed - should only get one change_time $out"
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.*'
1786 if [ $ret -ne 0 ]; then
1789 echo "failed - should get access_time: Sun Jan 1 05:10:20 [AM] 2017"
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.*'
1798 if [ $ret -ne 0 ]; then
1801 echo "failed - should get access_time: Thu Feb 4 06:19:20 [AM] 2016"
1807 # Test smbclient renames with pathnames containing '..'
1808 test_rename_dotdot
()
1810 tmpfile
=$PREFIX/smbclient_interactive_prompt_commands
1819 put ${SMBCLIENT} README
1820 rename README ..\\dir2\\README
1828 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1833 if [ $ret != 0 ]; then
1835 echo "failed rename_dotdot test with output $ret"
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"
1851 # Test doing a volume command.
1854 tmpfile
=$PREFIX/smbclient_interactive_prompt_commands
1859 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1865 if [ $ret != 0 ]; then
1867 echo "failed doing volume command with error $ret"
1871 echo "$out" |
grep '^Volume: |tmp| serial number'
1873 if [ $ret != 0 ]; then
1875 echo "failed doing volume command"
1880 test_server_os_message
()
1882 tmpfile
=$PREFIX/smbclient_interactive_prompt_commands
1887 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1893 if [ $ret -ne 0 ]; then
1895 echo "failed to connect error $ret"
1899 echo "$out" |
grep 'Try "help" to get a list of possible commands.'
1901 if [ $ret -ne 0 ]; then
1903 echo 'failed - should get: Try "help" to get a list of possible commands.'
1910 test_server_quiet_message
()
1912 tmpfile
=$PREFIX/smbclient_interactive_prompt_commands
1917 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS --quiet < $tmpfile 2>&1'
1923 if [ $ret -ne 0 ]; then
1925 echo "failed to connect error $ret"
1929 echo "$out" |
grep 'Try "help" to get a list of possible commands.'
1931 if [ $ret -eq 0 ]; then
1933 echo 'failed - quiet should skip this message.'
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
1952 put ${PREFIX}/smbclient_interactive_prompt_commands foo:bar
1958 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/streams_xattr -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1964 if [ $ret != 0 ]; then
1966 echo "failed checking attributes on xattr stream foo:bar with error $ret"
1970 echo "$out" |
grep "attributes:.*80"
1972 if [ $ret != 0 ]; then
1974 echo "failed checking attributes on xattr stream foo:bar"
1979 # Test against streams_depot
1984 put ${PREFIX}/smbclient_interactive_prompt_commands foo:bar
1990 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
1996 if [ $ret != 0 ]; then
1998 echo "failed checking attributes on depot stream foo:bar with error $ret"
2002 echo "$out" |
grep "attributes:.*80"
2004 if [ $ret != 0 ]; then
2006 echo "failed checking attributes on depot stream foo:bar"
2011 # Test smbclient non-empty rmdir command
2014 tmpfile
=$PREFIX/smbclient_interactive_prompt_commands
2015 del_nedir
="$LOCAL_PATH/del_nedir"
2019 touch $del_nedir/afile
2024 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
2030 if [ $ret != 0 ]; then
2032 echo "failed test_del_nedir test with output $ret"
2037 # Should get NT_STATUS_DIRECTORY_NOT_EMPTY error from rmdir
2038 echo "$out" |
grep 'NT_STATUS_DIRECTORY_NOT_EMPTY'
2040 if [ $ret -ne 0 ]; then
2042 echo "test_del_nedir failed - should get an NT_STATUS_DIRECTORY_NOT_EMPTY error"
2050 tmpfile
=$PREFIX/smbclient_interactive_prompt_commands
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'
2061 if [ $ret -ne 0 ]; then
2063 echo "test_valid_users:valid_users 'User in 'valid users' can login to service' failed - $ret"
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'
2073 if [ $ret -ne 0 ]; then
2075 echo "test_valid_users:valid_users_group 'User from ad group in 'valid users' can login to service' failed - $ret"
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'
2085 if [ $ret -ne 0 ]; then
2087 echo "test_valid_users:valid_users_unix_group 'User from UNIX group in 'valid users' can login to service' failed - $ret"
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'
2095 echo "$out" |
grep 'NT_STATUS_ACCESS_DENIED'
2098 if [ $ret -ne 0 ]; then
2100 echo "test_valid_users:valid_users_nis_group 'User not in NIS group in 'valid users' can't login to service' failed - $ret"
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'
2110 if [ $ret -ne 0 ]; then
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"
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'
2122 if [ $ret -ne 0 ]; then
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"
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'
2134 if [ $ret -ne 0 ]; then
2136 echo "test_valid_users:invalid_users 'User not in 'invalid users' can login to service' failed - $ret"
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'
2144 echo "$out" |
grep 'NT_STATUS_ACCESS_DENIED'
2147 if [ $ret -ne 0 ]; then
2149 echo "test_valid_users:invalid_users 'User in 'invalid users' can't login to service' failed - $ret"
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'
2157 echo "$out" |
grep 'NT_STATUS_ACCESS_DENIED'
2160 if [ $ret -ne 0 ]; then
2162 echo "test_valid_users:valid_and_invalid_users 'User is in 'valid and invalid users' can't login to service' failed - $ret"
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'
2173 if [ $ret -ne 0 ]; then
2175 echo "test_valid_users:valid_and_invalid_users '2 Users are in 'valid users'' failed - $ret"
2182 test_smbclient_minus_e_stderr
()
2184 cmd
='$SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -c ls'
2187 if [ $?
!= 0 ]; then
2189 echo "command failed"
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"
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'
2205 if [ $?
!= 0 ]; then
2207 echo "command failed"
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"
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}"
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" \
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" \
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" \
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" \
2313 failed
=$
(expr $failed + 1)
2315 testit
"using an authentication 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)" \
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" \
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" \
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" \
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" \
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" \
2377 failed
=$
(expr $failed + 1)
2381 failed
=$
(expr $failed + 1)
2383 testit
"rename_dotdot" \
2384 test_rename_dotdot ||
2385 failed
=$
(expr $failed + 1)
2389 failed
=$
(expr $failed + 1)
2391 testit
"rm -rf $LOGDIR" \
2393 failed
=$
(expr $failed + 1)
2395 testit
"delete a non empty directory" \
2397 failed
=$
(expr $failed + 1)
2399 testit
"valid users" \
2401 failed
=$
(expr $failed + 1)