blob: a920c274a5ec7638ac87f89ddad4a35835de1441 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
#!/bin/sh
#
# Blackbox test for valid users.
#
if [ $# -lt 7 ]; then
cat <<EOF
Usage: $0 SERVER DOMAIN USERNAME PASSWORD PREFIX TARGET_ENV SMBCLIENT
EOF
exit 1
fi
SERVER=${1}
DOMAIN=${2}
USERNAME=${3}
PASSWORD=${4}
PREFIX=${5}
TARGET_ENV=${6}
SMBCLIENT=${7}
shift 7
SMBCLIENT="$VALGRIND ${SMBCLIENT}"
ADDARGS="$@"
incdir=$(dirname $0)/../../../testprogs/blackbox
. $incdir/subunit.sh
failed=0
# Test listing a share with valid users succeeds
test_dropbox()
{
local filename="wurst.$$"
local filename_path="$PREFIX/$filename"
local dropbox_path="$PREFIX/$TARGET_ENV/share/$1/dirmode733"
local tmpfile=$PREFIX/smbclient.in.$$
echo "wurstbar" >$filename_path
cat >$tmpfile <<EOF
lcd $PREFIX
put $filename dirmode733\\$filename
quit
EOF
# 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
}
testit "dropbox dirmode 0733" \
test_dropbox dropbox ||
failed=$(expr $failed + 1)
exit $failed
|