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"
19 WBINFO
="$VALGRIND ${WBINFO:-$BINDIR/wbinfo}"
23 test x
"$TEST_FUNCTIONS_SH" != x
"INCLUDED" && {
25 .
$incdir/test_functions.sh
30 # Test that a noninteractive smbclient does not prompt
31 test_noninteractive_no_prompt
()
35 cmd
='echo du | $SMBCLIENT $CONFIGURATION "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS 2>&1'
46 echo "$out" |
grep $prompt >/dev
/null
2>&1
49 # got a prompt .. fail
50 echo matched interactive prompt
in non-interactive mode
57 # Test that an interactive smbclient prompts to stdout
58 test_interactive_prompt_stdout
()
61 tmpfile
=/tmp
/smbclient.
in.$$
68 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT $CONFIGURATION "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
74 if [ $ret != 0 ] ; then
81 echo "$out" |
grep $prompt >/dev
/null
2>&1
84 # got a prompt .. succeed
87 echo failed to match interactive prompt on stdout
92 # Test creating a bad symlink and deleting it.
95 prompt
="posix_unlink deleted file /newname"
96 tmpfile
=/tmp
/smbclient.
in.$$
101 symlink badname newname
106 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT $CONFIGURATION "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
112 if [ $ret != 0 ] ; then
114 echo "failed create then delete bad symlink with error $ret"
119 echo "$out" |
grep "$prompt" >/dev
/null
2>&1
122 if [ $ret = 0 ] ; then
123 # got the correct prompt .. succeed
127 echo "failed create then delete bad symlink - grep failed with $ret"
132 # Test creating a good symlink and deleting it by path.
135 tmpfile
=/tmp
/smbclient.
in.$$
136 slink_name
="$LOCAL_PATH/slink"
137 slink_target
="$LOCAL_PATH/slink_target"
140 ln -s $slink_target $slink_name
146 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT $CONFIGURATION "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
152 if [ $ret != 0 ] ; then
154 echo "failed delete good symlink with error $ret"
161 if [ ! -e $slink_target ] ; then
162 echo "failed delete good symlink - symlink target deleted !"
169 if [ -e $slink_name ] ; then
170 echo "failed delete good symlink - symlink still exists"
175 # got the correct prompt .. succeed
181 # Test writing into a read-only directory (logon as guest) fails.
184 prompt
="NT_STATUS_ACCESS_DENIED making remote directory"
185 tmpfile
=/tmp
/smbclient.
in.$$
188 ## We can't do this as non-root. We always have rights to
189 ## create the directory.
191 if [ "$USERID" != 0 ] ; then
192 echo "skipping test_read_only_dir as non-root"
198 ## We can't do this with an encrypted connection. No credentials
199 ## to set up the channel.
201 if [ "$ADDARGS" = "-e" ] ; then
202 echo "skipping test_read_only_dir with encrypted connection"
212 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT $CONFIGURATION "$@" -U% //$SERVER/ro-tmp -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
229 # got the correct prompt .. succeed
233 echo "failed writing into read-only directory - grep failed with $ret"
238 # Test reading an owner-only file (logon as guest) fails.
239 test_owner_only_file
()
241 prompt
="NT_STATUS_ACCESS_DENIED opening remote file"
242 tmpfile
=/tmp
/smbclient.
in.$$
245 ## We can't do this as non-root. We always have rights to
248 if [ "$USERID" != 0 ] ; then
249 echo "skipping test_owner_only_file as non-root"
255 ## We can't do this with an encrypted connection. No credentials
256 ## to set up the channel.
258 if [ "$ADDARGS" = "-e" ] ; then
259 echo "skipping test_owner_only_file with encrypted connection"
269 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT $CONFIGURATION "$@" -U% //$SERVER/ro-tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
275 if [ $ret != 0 ] ; then
277 echo "failed reading owner-only file with error $ret"
282 echo "$out" |
grep "$prompt" >/dev
/null
2>&1
285 if [ $ret = 0 ] ; then
286 # got the correct prompt .. succeed
290 echo "failed reading owner-only file - grep failed with $ret"
295 # Test accessing an msdfs path.
298 tmpfile
=/tmp
/smbclient.
in.$$
299 prompt
=" msdfs-target "
308 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT $CONFIGURATION "$@" -U$USERNAME%$PASSWORD //$SERVER/msdfs-share -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
314 if [ $ret != 0 ] ; then
316 echo "failed accessing \\msdfs-src1 link with error $ret"
321 echo "$out" |
grep "$prompt" >/dev
/null
2>&1
324 if [ $ret != 0 ] ; then
326 echo "failed listing \\msdfs-src1 - grep failed with $ret"
332 cd \\deeppath\\msdfs-src2
337 cmd
='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT $CONFIGURATION "$@" -U$USERNAME%$PASSWORD //$SERVER/msdfs-share -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
343 if [ $ret != 0 ] ; then
345 echo "failed accessing \\deeppath\\msdfs-src2 link with error $ret"
350 echo "$out" |
grep "$prompt" >/dev
/null
2>&1
353 if [ $ret != 0 ] ; then
355 echo "failed listing \\deeppath\\msdfs-src2 - grep failed with $ret"
364 # Test authenticating using the winbind ccache
367 $WBINFO --ccache-save="${USERNAME}%${PASSWORD}"
368 $SMBCLIENT $CONFIGURATION //$SERVER_IP/tmp
-C -U "${USERNAME}%" \
372 if [ $ret != 0 ] ; then
373 echo "smbclient failed to use cached credentials"
378 $WBINFO --ccache-save="${USERNAME}%GarBage"
379 $SMBCLIENT $CONFIGURATION //$SERVER_IP/tmp
-C -U "${USERNAME}%" \
383 if [ $ret == 0 ] ; then
384 echo "smbclient succeeded with wrong cached credentials"
393 testit
"smbclient -L $SERVER_IP" $SMBCLIENT $CONFIGURATION -L $SERVER_IP -N -p 139 || failed
=`expr $failed + 1`
394 testit
"smbclient -L $SERVER -I $SERVER_IP" $SMBCLIENT $CONFIGURATION -L $SERVER -I $SERVER_IP -N -p 139 || failed
=`expr $failed + 1`
396 testit
"noninteractive smbclient does not prompt" \
397 test_noninteractive_no_prompt || \
398 failed
=`expr $failed + 1`
400 testit
"noninteractive smbclient -l does not prompt" \
401 test_noninteractive_no_prompt
-l /tmp || \
402 failed
=`expr $failed + 1`
404 testit
"interactive smbclient prompts on stdout" \
405 test_interactive_prompt_stdout || \
406 failed
=`expr $failed + 1`
408 testit
"interactive smbclient -l prompts on stdout" \
409 test_interactive_prompt_stdout
-l /tmp || \
410 failed
=`expr $failed + 1`
412 testit
"creating a bad symlink and deleting it" \
413 test_bad_symlink || \
414 failed
=`expr $failed + 1`
416 testit
"creating a good symlink and deleting it by path" \
417 test_good_symlink || \
418 failed
=`expr $failed + 1`
420 testit
"writing into a read-only directory fails" \
421 test_read_only_dir || \
422 failed
=`expr $failed + 1`
424 testit
"Reading a owner-only file fails" \
425 test_owner_only_file || \
426 failed
=`expr $failed + 1`
428 testit
"Accessing an MS-DFS link" \
430 failed
=`expr $failed + 1`
432 testit
"ccache access works for smbclient" \
433 test_ccache_access || \
434 failed
=`expr $failed + 1`