2020-02-13 13:48:17 +01:00
#!/bin/sh
#
# Blackbox test for valid users.
#
if [ $# -lt 7 ] ; then
2022-04-22 15:34:08 +02:00
cat <<EOF
2020-02-13 13:48:17 +01:00
Usage: $0 SERVER DOMAIN USERNAME PASSWORD PREFIX TARGET_ENV SMBCLIENT
EOF
2022-04-22 15:34:08 +02:00
exit 1
2020-02-13 13:48:17 +01: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 15:34:08 +02:00
incdir = $( dirname $0 ) /../../../testprogs/blackbox
2020-02-13 13:48:17 +01:00
. $incdir /subunit.sh
failed = 0
# Test listing a share with valid users succeeds
test_dropbox( )
{
2022-04-22 15:34:08 +02:00
local filename = " wurst. $$ "
local filename_path = " $PREFIX / $filename "
local dropbox_path = " $PREFIX / $TARGET_ENV /share/ $1 /dirmode733 "
2020-02-13 13:48:17 +01:00
2022-04-22 15:34:08 +02:00
local tmpfile = $PREFIX /smbclient.in.$$
2020-02-13 13:48:17 +01:00
2022-04-22 15:34:08 +02:00
echo "wurstbar" >$filename_path
2020-02-13 13:48:17 +01:00
2022-04-22 15:34:08 +02:00
cat >$tmpfile <<EOF
2020-02-13 13:48:17 +01:00
lcd $PREFIX
put $filename dirmode733\\ $filename
quit
EOF
2022-04-22 15:34:08 +02:00
# Create dropbox directory and set permissions
mkdir -p $dropbox_path
chmod 0333 $dropbox_path
local cmd = 'CLI_FORCE_INTERACTIVE=yes $SMBCLIENT //$SERVER/$1 -U$USERNAME%$PASSWORD $ADDARGS < $tmpfile 2>&1'
eval echo " $cmd "
out = $( eval $cmd )
ret = $?
# Reset dropbox permissions
chmod 0755 $dropbox_path
rm -f $tmpfile
if [ $ret != 0 ] ; then
echo " Failed accessing share $ret "
echo " $out "
return 1
fi
rm -f $filename_path
dropped_file = " $dropbox_path / $filename "
if [ ! -r " $dropped_file " ] ; then
echo " Failed to drop file $filename "
echo " $out "
return 1
fi
content = $( cat $dropped_file )
if [ " $content " != "wurstbar" ] ; then
echo " Invalid file content: $content "
echo " $out "
return 1
fi
return 0
2020-02-13 13:48:17 +01:00
}
testit "dropbox dirmode 0733" \
2022-04-22 15:34:08 +02:00
test_dropbox dropbox ||
failed = $( expr $failed + 1)
2020-02-13 13:48:17 +01:00
exit $failed