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
17 SMBCLIENT="$VALGRIND ${SMBCLIENT:-$BINDIR/smbclient} $CONFIGURATION"
21 test x"$TEST_FUNCTIONS_SH" != x"INCLUDED" && {
23 . $incdir/test_functions.sh
28 # Test that a noninteractive smbclient does not prompt
29 test_noninteractive_no_prompt()
33 cmd='echo du | $SMBCLIENT $CONFIGURATION "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS 2>&1'
44 echo "$out" | grep $prompt >/dev/null 2>&1
47 # got a prompt .. fail
48 echo matched interactive prompt in non-interactive mode
55 # Test that an interactive smbclient prompts to stdout
56 test_interactive_prompt_stdout()
59 tmpfile=/tmp/smbclient.in.$$
66 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT $CONFIGURATION "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
72 if [ $ret != 0 ] ; then
79 echo "$out" | grep $prompt >/dev/null 2>&1
82 # got a prompt .. succeed
85 echo failed to match interactive prompt on stdout
90 # Test creating a bad symlink and deleting it.
93 prompt="posix_unlink deleted file /newname"
94 tmpfile=/tmp/smbclient.in.$$
99 symlink badname newname
104 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT $CONFIGURATION "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
110 if [ $ret != 0 ] ; then
112 echo "failed create then delete bad symlink with error $ret"
117 echo "$out" | grep "$prompt" >/dev/null 2>&1
120 if [ $ret = 0 ] ; then
121 # got the correct prompt .. succeed
125 echo "failed create then delete bad symlink - grep failed with $ret"
130 # Test writing into a read-only directory (logon as guest) fails.
133 prompt="NT_STATUS_ACCESS_DENIED making remote directory"
134 tmpfile=/tmp/smbclient.in.$$
137 ## We can't do this as non-root. We always have rights to
138 ## create the directory.
140 if [ "$USERID" != 0 ] ; then
141 echo "skipping test_read_only_dir as non-root"
147 ## We can't do this with an encrypted connection. No credentials
148 ## to set up the channel.
150 if [ "$ADDARGS" = "-e" ] ; then
151 echo "skipping test_read_only_dir with encrypted connection"
161 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT $CONFIGURATION "$@" -U% //$SERVER/ro-tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
167 if [ $ret != 0 ] ; then
169 echo "failed writing into read-only directory with error $ret"
174 echo "$out" | grep "$prompt" >/dev/null 2>&1
177 if [ $ret = 0 ] ; then
178 # got the correct prompt .. succeed
182 echo "failed writing into read-only directory - grep failed with $ret"
187 # Test reading an owner-only file (logon as guest) fails.
188 test_owner_only_file()
190 prompt="NT_STATUS_ACCESS_DENIED opening remote file"
191 tmpfile=/tmp/smbclient.in.$$
194 ## We can't do this as non-root. We always have rights to
197 if [ "$USERID" != 0 ] ; then
198 echo "skipping test_owner_only_file as non-root"
204 ## We can't do this with an encrypted connection. No credentials
205 ## to set up the channel.
207 if [ "$ADDARGS" = "-e" ] ; then
208 echo "skipping test_owner_only_file with encrypted connection"
218 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT $CONFIGURATION "$@" -U% //$SERVER/ro-tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
224 if [ $ret != 0 ] ; then
226 echo "failed reading owner-only file with error $ret"
231 echo "$out" | grep "$prompt" >/dev/null 2>&1
234 if [ $ret = 0 ] ; then
235 # got the correct prompt .. succeed
239 echo "failed reading owner-only file - grep failed with $ret"
244 testit "smbclient -L $SERVER_IP" $SMBCLIENT $CONFIGURATION -L $SERVER_IP -N -p 139 || failed=`expr $failed + 1`
245 testit "smbclient -L $SERVER -I $SERVER_IP" $SMBCLIENT $CONFIGURATION -L $SERVER -I $SERVER_IP -N -p 139 || failed=`expr $failed + 1`
247 testit "noninteractive smbclient does not prompt" \
248 test_noninteractive_no_prompt || \
249 failed=`expr $failed + 1`
251 testit "noninteractive smbclient -l does not prompt" \
252 test_noninteractive_no_prompt -l /tmp || \
253 failed=`expr $failed + 1`
255 testit "interactive smbclient prompts on stdout" \
256 test_interactive_prompt_stdout || \
257 failed=`expr $failed + 1`
259 testit "interactive smbclient -l prompts on stdout" \
260 test_interactive_prompt_stdout -l /tmp || \
261 failed=`expr $failed + 1`
263 testit "creating a bad symlink and deleting it" \
264 test_bad_symlink || \
265 failed=`expr $failed + 1`
267 testit "writing into a read-only directory fails" \
268 test_read_only_dir || \
269 failed=`expr $failed + 1`
271 testit "Reading a owner-only file fails" \
272 test_owner_only_file || \
273 failed=`expr $failed + 1`