3 # this runs the file serving tests that are expected to pass with samba3
7 Usage: test_smbclient_s3.sh SERVER SERVER_IP USERNAME PASSWORD USERID LOCAL_PATH
18 SMBCLIENT
="$VALGRIND ${SMBCLIENT:-$BINDIR/smbclient} $CONFIGURATION"
22 test x
"$TEST_FUNCTIONS_SH" != x
"INCLUDED" && {
24 .
$incdir/test_functions.sh
29 # Test that a noninteractive smbclient does not prompt
30 test_noninteractive_no_prompt
()
34 cmd
='echo du | $SMBCLIENT $CONFIGURATION "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS 2>&1'
45 echo "$out" |
grep $prompt >/dev
/null
2>&1
48 # got a prompt .. fail
49 echo matched interactive prompt
in non-interactive mode
56 # Test that an interactive smbclient prompts to stdout
57 test_interactive_prompt_stdout
()
60 tmpfile
=/tmp
/smbclient.
in.$$
67 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT $CONFIGURATION "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
73 if [ $ret != 0 ] ; then
80 echo "$out" |
grep $prompt >/dev
/null
2>&1
83 # got a prompt .. succeed
86 echo failed to match interactive prompt on stdout
91 # Test creating a bad symlink and deleting it.
94 prompt
="posix_unlink deleted file /newname"
95 tmpfile
=/tmp
/smbclient.
in.$$
100 symlink badname newname
105 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT $CONFIGURATION "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
111 if [ $ret != 0 ] ; then
113 echo "failed create then delete bad symlink with error $ret"
118 echo "$out" |
grep "$prompt" >/dev
/null
2>&1
121 if [ $ret = 0 ] ; then
122 # got the correct prompt .. succeed
126 echo "failed create then delete bad symlink - grep failed with $ret"
131 # Test creating a good symlink and deleting it by path.
134 tmpfile
=/tmp
/smbclient.
in.$$
135 slink_name
="$LOCAL_PATH/slink"
136 slink_target
="$LOCAL_PATH/slink_target"
139 ln -s $slink_target $slink_name
145 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT $CONFIGURATION "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
151 if [ $ret != 0 ] ; then
153 echo "failed delete good symlink with error $ret"
160 if [ ! -e $slink_target ] ; then
161 echo "failed delete good symlink - symlink target deleted !"
168 if [ -e $slink_name ] ; then
169 echo "failed delete good symlink - symlink still exists"
174 # got the correct prompt .. succeed
180 # Test writing into a read-only directory (logon as guest) fails.
183 prompt
="NT_STATUS_ACCESS_DENIED making remote directory"
184 tmpfile
=/tmp
/smbclient.
in.$$
187 ## We can't do this as non-root. We always have rights to
188 ## create the directory.
190 if [ "$USERID" != 0 ] ; then
191 echo "skipping test_read_only_dir as non-root"
197 ## We can't do this with an encrypted connection. No credentials
198 ## to set up the channel.
200 if [ "$ADDARGS" = "-e" ] ; then
201 echo "skipping test_read_only_dir with encrypted connection"
211 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT $CONFIGURATION "$@" -U% //$SERVER/ro-tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
217 if [ $ret != 0 ] ; then
219 echo "failed writing into read-only directory with error $ret"
224 echo "$out" |
grep "$prompt" >/dev
/null
2>&1
227 if [ $ret = 0 ] ; then
228 # got the correct prompt .. succeed
232 echo "failed writing into read-only directory - grep failed with $ret"
237 # Test reading an owner-only file (logon as guest) fails.
238 test_owner_only_file
()
240 prompt
="NT_STATUS_ACCESS_DENIED opening remote file"
241 tmpfile
=/tmp
/smbclient.
in.$$
244 ## We can't do this as non-root. We always have rights to
247 if [ "$USERID" != 0 ] ; then
248 echo "skipping test_owner_only_file as non-root"
254 ## We can't do this with an encrypted connection. No credentials
255 ## to set up the channel.
257 if [ "$ADDARGS" = "-e" ] ; then
258 echo "skipping test_owner_only_file with encrypted connection"
268 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT $CONFIGURATION "$@" -U% //$SERVER/ro-tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
274 if [ $ret != 0 ] ; then
276 echo "failed reading owner-only file with error $ret"
281 echo "$out" |
grep "$prompt" >/dev
/null
2>&1
284 if [ $ret = 0 ] ; then
285 # got the correct prompt .. succeed
289 echo "failed reading owner-only file - grep failed with $ret"
294 # Test accessing an msdfs path.
297 tmpfile
=/tmp
/smbclient.
in.$$
298 prompt
=" msdfs-target "
307 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT $CONFIGURATION "$@" -U$USERNAME%$PASSWORD //$SERVER/msdfs-share -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
313 if [ $ret != 0 ] ; then
315 echo "failed accessing \\msdfs-src1 link with error $ret"
320 echo "$out" |
grep "$prompt" >/dev
/null
2>&1
323 if [ $ret != 0 ] ; then
325 echo "failed listing \\msdfs-src1 - grep failed with $ret"
331 cd \\deeppath\\msdfs-src2
336 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT $CONFIGURATION "$@" -U$USERNAME%$PASSWORD //$SERVER/msdfs-share -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
342 if [ $ret != 0 ] ; then
344 echo "failed accessing \\deeppath\\msdfs-src2 link with error $ret"
349 echo "$out" |
grep "$prompt" >/dev
/null
2>&1
352 if [ $ret != 0 ] ; then
354 echo "failed listing \\deeppath\\msdfs-src2 - grep failed with $ret"
364 testit
"smbclient -L $SERVER_IP" $SMBCLIENT $CONFIGURATION -L $SERVER_IP -N -p 139 || failed
=`expr $failed + 1`
365 testit
"smbclient -L $SERVER -I $SERVER_IP" $SMBCLIENT $CONFIGURATION -L $SERVER -I $SERVER_IP -N -p 139 || failed
=`expr $failed + 1`
367 testit
"noninteractive smbclient does not prompt" \
368 test_noninteractive_no_prompt || \
369 failed
=`expr $failed + 1`
371 testit
"noninteractive smbclient -l does not prompt" \
372 test_noninteractive_no_prompt
-l /tmp || \
373 failed
=`expr $failed + 1`
375 testit
"interactive smbclient prompts on stdout" \
376 test_interactive_prompt_stdout || \
377 failed
=`expr $failed + 1`
379 testit
"interactive smbclient -l prompts on stdout" \
380 test_interactive_prompt_stdout
-l /tmp || \
381 failed
=`expr $failed + 1`
383 testit
"creating a bad symlink and deleting it" \
384 test_bad_symlink || \
385 failed
=`expr $failed + 1`
387 testit
"creating a good symlink and deleting it by path" \
388 test_good_symlink || \
389 failed
=`expr $failed + 1`
391 testit
"writing into a read-only directory fails" \
392 test_read_only_dir || \
393 failed
=`expr $failed + 1`
395 testit
"Reading a owner-only file fails" \
396 test_owner_only_file || \
397 failed
=`expr $failed + 1`
399 testit
"Accessing an MS-DFS link" \
401 failed
=`expr $failed + 1`