#!/bin/sh # this runs the file serving tests that are expected to pass with samba3 if [ $# -lt 6 ]; then cat </dev/null 2>&1 if [ $? = 0 ] ; then # got a prompt .. fail echo matched interactive prompt in non-interactive mode false else true fi } # Test that an interactive smbclient prompts to stdout test_interactive_prompt_stdout() { prompt="smb" tmpfile=/tmp/smbclient.in.$$ cat > $tmpfile </dev/null 2>&1 if [ $? = 0 ] ; then # got a prompt .. succeed true else echo failed to match interactive prompt on stdout false fi } # Test creating a bad symlink and deleting it. test_bad_symlink() { prompt="posix_unlink deleted file /newname" tmpfile=/tmp/smbclient.in.$$ cat > $tmpfile </dev/null 2>&1 ret=$? if [ $ret = 0 ] ; then # got the correct prompt .. succeed true else echo "$out" echo "failed create then delete bad symlink - grep failed with $ret" false fi } # Test creating a good symlink and deleting it by path. test_good_symlink() { tmpfile=/tmp/smbclient.in.$$ slink_name="$LOCAL_PATH/slink" slink_target="$LOCAL_PATH/slink_target" touch $slink_target ln -s $slink_target $slink_name cat > $tmpfile < $tmpfile </dev/null 2>&1 ret=$? if [ $ret = 0 ] ; then # got the correct prompt .. succeed true else echo "$out" echo "failed writing into read-only directory - grep failed with $ret" false fi } # Test reading an owner-only file (logon as guest) fails. test_owner_only_file() { prompt="NT_STATUS_ACCESS_DENIED opening remote file" tmpfile=/tmp/smbclient.in.$$ ## ## We can't do this as non-root. We always have rights to ## read the file. ## if [ "$USERID" != 0 ] ; then echo "skipping test_owner_only_file as non-root" true return fi ## ## We can't do this with an encrypted connection. No credentials ## to set up the channel. ## if [ "$ADDARGS" = "-e" ] ; then echo "skipping test_owner_only_file with encrypted connection" true return fi cat > $tmpfile </dev/null 2>&1 ret=$? if [ $ret = 0 ] ; then # got the correct prompt .. succeed true else echo "$out" echo "failed reading owner-only file - grep failed with $ret" false fi } # Test accessing an msdfs path. test_msdfs_link() { tmpfile=/tmp/smbclient.in.$$ prompt=" msdfs-target " cat > $tmpfile </dev/null 2>&1 ret=$? if [ $ret != 0 ] ; then echo "$out" echo "failed listing \\msdfs-src1 - grep failed with $ret" false fi cat > $tmpfile </dev/null 2>&1 ret=$? if [ $ret != 0 ] ; then echo "$out" echo "failed listing \\deeppath\\msdfs-src2 - grep failed with $ret" false return else true return fi } # Test authenticating using the winbind ccache test_ccache_access() { $WBINFO --ccache-save="${USERNAME}%${PASSWORD}" $SMBCLIENT $CONFIGURATION //$SERVER_IP/tmp -C -U "${USERNAME}%" \ -c quit 2>&1 ret=$? if [ $ret != 0 ] ; then echo "smbclient failed to use cached credentials" false return fi $WBINFO --ccache-save="${USERNAME}%GarBage" $SMBCLIENT $CONFIGURATION //$SERVER_IP/tmp -C -U "${USERNAME}%" \ -c quit 2>&1 ret=$? if [ $ret == 0 ] ; then echo "smbclient succeeded with wrong cached credentials" false return fi $WBINFO --logoff } testit "smbclient -L $SERVER_IP" $SMBCLIENT $CONFIGURATION -L $SERVER_IP -N -p 139 || failed=`expr $failed + 1` testit "smbclient -L $SERVER -I $SERVER_IP" $SMBCLIENT $CONFIGURATION -L $SERVER -I $SERVER_IP -N -p 139 || failed=`expr $failed + 1` testit "noninteractive smbclient does not prompt" \ test_noninteractive_no_prompt || \ failed=`expr $failed + 1` testit "noninteractive smbclient -l does not prompt" \ test_noninteractive_no_prompt -l /tmp || \ failed=`expr $failed + 1` testit "interactive smbclient prompts on stdout" \ test_interactive_prompt_stdout || \ failed=`expr $failed + 1` testit "interactive smbclient -l prompts on stdout" \ test_interactive_prompt_stdout -l /tmp || \ failed=`expr $failed + 1` testit "creating a bad symlink and deleting it" \ test_bad_symlink || \ failed=`expr $failed + 1` testit "creating a good symlink and deleting it by path" \ test_good_symlink || \ failed=`expr $failed + 1` testit "writing into a read-only directory fails" \ test_read_only_dir || \ failed=`expr $failed + 1` testit "Reading a owner-only file fails" \ test_owner_only_file || \ failed=`expr $failed + 1` testit "Accessing an MS-DFS link" \ test_msdfs_link || \ failed=`expr $failed + 1` testit "ccache access works for smbclient" \ test_ccache_access || \ failed=`expr $failed + 1` testok $0 $failed