2021-09-03 01:32:27 +03:00
#!/bin/sh
#
# Check smbclient can list a directory containing a fifo.
#
if [ $# -lt 7 ] ; then
2022-04-22 16:34:08 +03:00
cat <<EOF
2021-09-03 01:32:27 +03:00
Usage: $0 SERVER DOMAIN USERNAME PASSWORD PREFIX TARGET_ENV SMBCLIENT
EOF
2022-04-22 16:34:08 +03:00
exit 1
2021-09-03 01:32:27 +03:00
fi
SERVER = ${ 1 }
DOMAIN = ${ 2 }
USERNAME = ${ 3 }
PASSWORD = ${ 4 }
PREFIX = ${ 5 }
TARGET_ENV = ${ 6 }
SMBCLIENT = ${ 7 }
shift 7
SMBCLIENT = " $VALGRIND ${ SMBCLIENT } "
ADDARGS = " $@ "
2022-04-22 16:34:08 +03:00
incdir = $( dirname $0 ) /../../../testprogs/blackbox
2021-09-03 01:32:27 +03:00
. $incdir /subunit.sh
failed = 0
# Test that listing a share with a directory containing a fifo succeeds.
#
# BUG: https://bugzilla.samba.org/show_bug.cgi?id=14816
#
test_fifo( )
{
2022-04-22 16:34:08 +03:00
local fifo_dir_path = " $PREFIX / $TARGET_ENV /share/fifodir "
local fifo_path = " $fifo_dir_path /fifo_name "
2021-09-03 01:32:27 +03:00
2022-04-22 16:34:08 +03:00
local tmpfile = $PREFIX /smbclient.in.$$
2021-09-03 01:32:27 +03:00
2022-04-22 16:34:08 +03:00
cat >$tmpfile <<EOF
2021-09-03 01:32:27 +03:00
cd fifodir
ls
quit
EOF
2022-04-22 16:34:08 +03:00
# Create fifo directory.
mkdir -p $fifo_dir_path
# Create fifo underneath.
mkfifo $fifo_path
2021-09-03 01:32:27 +03:00
2022-04-22 16:34:08 +03:00
local cmd = 'CLI_FORCE_INTERACTIVE=yes $SMBCLIENT //$SERVER/$1 -U$USERNAME%$PASSWORD $ADDARGS < $tmpfile 2>&1'
eval echo " $cmd "
out = $( eval $cmd )
ret = $?
2021-09-03 01:32:27 +03:00
2022-04-22 16:34:08 +03:00
# Remove fifo and containing dir.
rm $fifo_path
rmdir $fifo_dir_path
rm -f $tmpfile
2021-09-03 01:32:27 +03:00
2022-04-22 16:34:08 +03:00
# Check for smbclient error.
if [ $ret != 0 ] ; then
echo " Failed accessing share containing dir with fifo $ret "
echo " $out "
return 1
fi
2021-09-03 01:32:27 +03:00
2022-04-22 16:34:08 +03:00
# Check for smbclient timeout (server hung).
echo " $out " | grep 'NT_STATUS_'
ret = $?
if [ $ret -eq 0 ] ; then
# Client was disconnected as server timed out.
echo " $out "
return 1
fi
2021-09-03 01:32:27 +03:00
2022-04-22 16:34:08 +03:00
return 0
2021-09-03 01:32:27 +03:00
}
testit "list directory containing a fifo" \
2022-04-22 16:34:08 +03:00
test_fifo tmp || failed = $( expr $failed + 1)
2021-09-03 01:32:27 +03:00
exit $failed