blob: 2036d57566ca817d06e9e7530dda82d9f7f7a4a0 (
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
|
#!/bin/sh
if [ $# -lt 4 ]; then
cat <<EOF
Usage: test_smbspool.sh SERVER SERVER_IP USERNAME PASSWORD TARGET_ENV
EOF
exit 1
fi
SERVER="$1"
SERVER_IP="$2"
USERNAME="$3"
PASSWORD="$4"
TARGET_ENV="$5"
shift 5
ADDARGS="$@"
incdir=$(dirname $0)/../../../testprogs/blackbox
. $incdir/subunit.sh
. $incdir/common_test_fns.inc
samba_bindir="$BINDIR"
samba_vlp="$samba_bindir/vlp"
samba_smbspool="$samba_bindir/smbspool"
samba_argv_wrapper="$samba_bindir/smbspool_argv_wrapper"
samba_smbtorture3="$samba_bindir/smbtorture3"
samba_smbspool_krb5="$samba_bindir/smbspool_krb5_wrapper"
test_smbspool_noargs()
{
cmd='$1 2>&1'
eval echo "$cmd"
out=$(eval $cmd)
ret=$?
if [ $ret != 0 ]; then
echo "$out"
echo "failed to execute $1"
fi
echo "$out" | grep 'network smb "Unknown" "Windows Printer via SAMBA"'
ret=$?
if [ $ret != 0 ]; then
echo "$out"
return 1
fi
}
test_smbspool_authinforequired_none()
{
cmd='$samba_smbspool_krb5 smb://$SERVER_IP/print4 200 $USERNAME "Testprint" 1 "options" $SRCDIR/testdata/printing/example.ps 2>&1'
AUTH_INFO_REQUIRED="none"
export AUTH_INFO_REQUIRED
eval echo "$cmd"
out=$(eval $cmd)
ret=$?
unset AUTH_INFO_REQUIRED
if [ $ret != 0 ]; then
echo "$out"
echo "failed to execute $samba_smbspool_krb5"
return 1
fi
return 0
}
test_smbspool_authinforequired_unknown()
{
cmd='$samba_smbspool_krb5 smb://$SERVER_IP/print4 200 $USERNAME "Testprint" 1 "options" $SRCDIR/testdata/printing/example.ps 2>&1'
# smbspool_krb5_wrapper must ignore AUTH_INFO_REQUIRED unknown to him and pass the task to smbspool
# smbspool must fail with NT_STATUS_ACCESS_DENIED (22)
# "jjf4wgmsbc0" is just a random string
AUTH_INFO_REQUIRED="jjf4wgmsbc0"
export AUTH_INFO_REQUIRED
eval echo "$cmd"
out=$(eval $cmd)
ret=$?
unset AUTH_INFO_REQUIRED
case "$ret" in
2) return 0 ;;
*)
echo "ret=$ret"
echo "$out"
echo "failed to test $samba_smbspool_krb5 against unknown value of AUTH_INFO_REQUIRED"
return 1
;;
esac
}
#
# The test environment uses 'vlp' (virtual lp) as the printing backend.
#
# When using the vlp backend the print job is only written to the database.
# The job needs to removed manually using 'vlp lprm' command!
#
# This calls the 'vlp' command to check if the print job has been successfully
# added to the database and also makes sure the temporary print file has been
# created.
#
# The function removes the print job from the vlp database if successful.
#
test_vlp_verify()
{
tdbfile="$PREFIX_ABS/$TARGET_ENV/lockdir/vlp.tdb"
if [ ! -w $tdbfile ]; then
echo "vlp tdbfile $tdbfile doesn't exist or is not writeable!"
return 1
fi
cmd='$samba_vlp tdbfile=$tdbfile lpq print1 2>&1'
eval echo "$cmd"
out=$(eval $cmd)
ret=$?
if [ $ret != 0 ]; then
echo "failed to get print queue with $samba_vlp"
echo "$out"
fi
jobid=$(echo "$out" | awk '/[0-9]+/ { print $1 };')
if [ -z "$jobid" ] || [ $jobid -lt 100 ] || [ $jobid -gt 2000 ]; then
echo "Invalid jobid: $jobid"
echo "$out"
return 1
fi
file=$(echo "$out" | awk '/[0-9]+/ { print $6 };')
if [ ! -r $PREFIX_ABS/$TARGET_ENV/share/$file ]; then
echo "$file doesn't exist"
echo "$out"
return 1
fi
$samba_vlp "tdbfile=$tdbfile" lprm print1 $jobid
ret=$?
if [ $ret != 0 ]; then
echo "Failed to remove jobid $jobid from $tdbfile"
return 1
fi
}
test_delete_on_close()
{
tdbfile="$PREFIX_ABS/$TARGET_ENV/lockdir/vlp.tdb"
if [ ! -w $tdbfile ]; then
echo "vlp tdbfile $tdbfile doesn't exist or is not writeable!"
return 1
fi
cmd='$samba_vlp tdbfile=$tdbfile lpq print1 2>&1'
eval echo "$cmd"
out=$(eval $cmd)
ret=$?
if [ $ret != 0 ]; then
echo "failed to lpq jobs on print1 with $samba_vlp"
echo "$out"
return 1
fi
num_jobs=$(echo "$out" | wc -l)
#
# Now run the test DELETE-PRINT from smbtorture3
#
cmd='$samba_smbtorture3 //$SERVER_IP/print1 -U$USERNAME%$PASSWORD DELETE-PRINT 2>&1'
eval echo "$cmd"
out_t=$(eval $cmd)
ret=$?
if [ $ret != 0 ]; then
echo "failed to run DELETE-PRINT on print1"
echo "$out_t"
return 1
fi
cmd='$samba_vlp tdbfile=$tdbfile lpq print1 2>&1'
eval echo "$cmd"
out1=$(eval $cmd)
ret=$?
if [ $ret != 0 ]; then
echo "(2) failed to lpq jobs on print1 with $samba_vlp"
echo "$out1"
return 1
fi
num_jobs1=$(echo "$out1" | wc -l)
#
# Number of jobs should not change. Job
# should not have made it to backend.
#
if [ "$num_jobs1" -ne "$num_jobs" ]; then
echo "delete-on-close fail $num_jobs1 -ne $num_jobs"
echo "$out"
echo "$out_t"
echo "$out1"
return 1
fi
return 0
}
testit "smbspool no args" \
test_smbspool_noargs $samba_smbspool ||
failed=$(expr $failed + 1)
testit "smbspool_krb5_wrapper no args" \
test_smbspool_noargs $samba_smbspool_krb5 ||
failed=$(expr $failed + 1)
testit "smbspool_krb5_wrapper AuthInfoRequired=none" \
test_smbspool_authinforequired_none ||
failed=$(expr $failed + 1)
testit "smbspool_krb5_wrapper AuthInfoRequired=(sth unknown)" \
test_smbspool_authinforequired_unknown ||
failed=$(expr $failed + 1)
testit "smbspool print example.ps" \
$samba_smbspool smb://$USERNAME:$PASSWORD@$SERVER_IP/print1 200 $USERNAME "Testprint" 1 "options" $SRCDIR/testdata/printing/example.ps ||
failed=$(expr $failed + 1)
testit "vlp verify example.ps" \
test_vlp_verify ||
failed=$(expr $failed + 1)
testit "smbspool print example.ps via stdin" \
$samba_smbspool smb://$USERNAME:$PASSWORD@$SERVER_IP/print1 200 $USERNAME "Testprint" 1 "options" <$SRCDIR/testdata/printing/example.ps ||
failed=$(expr $failed + 1)
testit "vlp verify example.ps" \
test_vlp_verify ||
failed=$(expr $failed + 1)
DEVICE_URI="smb://$USERNAME:$PASSWORD@$SERVER_IP/print1"
export DEVICE_URI
testit "smbspool print DEVICE_URI example.ps" \
$samba_smbspool 200 $USERNAME "Testprint" 1 "options" $SRCDIR/testdata/printing/example.ps ||
failed=$(expr $failed + 1)
unset DEVICE_URI
testit "vlp verify example.ps" \
test_vlp_verify ||
failed=$(expr $failed + 1)
DEVICE_URI="smb://$USERNAME:$PASSWORD@$SERVER_IP/print1"
export DEVICE_URI
testit "smbspool print DEVICE_URI example.ps via stdin" \
$samba_smbspool 200 $USERNAME "Testprint" 1 "options" <$SRCDIR/testdata/printing/example.ps ||
failed=$(expr $failed + 1)
unset DEVICE_URI
testit "vlp verify example.ps" \
test_vlp_verify ||
failed=$(expr $failed + 1)
DEVICE_URI="smb://$USERNAME:$PASSWORD@$SERVER_IP/print1"
export DEVICE_URI
testit "smbspool print sanitized Device URI in argv0 example.ps" \
$samba_argv_wrapper $samba_smbspool smb://$SERVER_IP/print1 200 $USERNAME "Testprint" 1 "options" $SRCDIR/testdata/printing/example.ps ||
failed=$(expr $failed + 1)
unset DEVICE_URI
testit "vlp verify example.ps" \
test_vlp_verify ||
failed=$(expr $failed + 1)
DEVICE_URI="smb://$USERNAME:$PASSWORD@$SERVER_IP/print1"
export DEVICE_URI
testit "smbspool print sanitized Device URI in argv0 example.ps via stdin" \
$samba_argv_wrapper $samba_smbspool smb://$SERVER_IP/print1 200 $USERNAME "Testprint" 1 "options" <$SRCDIR/testdata/printing/example.ps ||
failed=$(expr $failed + 1)
unset DEVICE_URI
testit "vlp verify example.ps" \
test_vlp_verify ||
failed=$(expr $failed + 1)
AUTH_INFO_REQUIRED="username,password"
export AUTH_INFO_REQUIRED
testit "smbspool_krb5(username,password) print example.ps" \
$samba_smbspool_krb5 smb://$USERNAME:$PASSWORD@$SERVER_IP/print1 200 $USERNAME "Testprint" 1 "options" $SRCDIR/testdata/printing/example.ps ||
failed=$(expr $failed + 1)
testit "vlp verify example.ps" \
test_vlp_verify ||
failed=$(expr $failed + 1)
unset AUTH_INFO_REQUIRED
testit "delete on close" \
test_delete_on_close ||
failed=$(expr $failed + 1)
exit $failed
|