blob: 4a4a559e0835fa11517939aaf0f1f81d23c440ab (
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
|
#! /bin/sh
# $Id$
#
# Test suite for the wallet command-line client.
#
# Written by Russ Allbery <rra@stanford.edu>
# Copyright 2006, 2007, 2008 Board of Trustees, Leland Stanford Jr. University
#
# See LICENSE for licensing terms.
# Load the test library.
. "@abs_top_srcdir@/tests/libtest.sh"
# Print the number of tests.
total=22
count=1
echo "$total"
# Find the client program.
chdir_data '../client/wallet'
if [ ! -f 'data/test.keytab' ] || [ -z '@REMCTLD@' ] ; then
skip 1 "$total" 'no Kerberos configuration'
exit 0
fi
wallet='../client/wallet'
# Start the remctld daemon and wait for it to start.
principal=`cat data/test.principal`
rm -f data/pid
( @REMCTLD@ -m -p 14373 -s "$principal" -P data/pid -f data/wallet.conf \
-S -F -k data/test.keytab &)
KRB5CCNAME=data/test.cache; export KRB5CCNAME
kinit -k -t data/test.keytab "$principal" > /dev/null 2>&1
if [ $? != 0 ] ; then
kinit -t data/test.keytab "$principal" > /dev/null 2>&1
fi
if [ $? != 0 ] ; then
kinit -k -K data/test.keytab "$principal" > /dev/null 2>&1
fi
if [ $? != 0 ] ; then
echo 'Unable to obtain Kerberos tickets' >&2
exit 1
fi
[ -f data/pid ] || sleep 1
if [ ! -f data/pid ] ; then
echo 'remctld did not start' >&2
exit 1
fi
# We need a modified krb5.conf file for the srvtab test to work, since we need
# to add a v4_realm setting for the test-k5.stanford.edu realm that the keytab
# is for. Despite all the Stanford hard-coding, this test isn't
# Stanford-specific. It just matches the data files shipped with the package.
krb5conf=
for p in /etc/krb5.conf /usr/local/etc/krb5.conf data/krb5.conf ; do
if [ -r "$p" ] ; then
krb5conf="$p"
sed -e '/^ *test-k5.stanford.edu =/,/}/d' \
-e 's/\(default_realm.*=\) .*/\1 test-k5.stanford.edu/' \
"$p" > ./krb5.conf
cat >> krb5.conf <<EOF
[realms]
test-k5.stanford.edu = {
v4_realm = TEST.STANFORD.EDU
}
EOF
KRB5_CONFIG="./krb5.conf"
export KRB5_CONFIG
break
fi
done
if [ -z "$krb5conf" ] ; then
echo 'No krb5.conf found -- put one in tests/data/krb5.conf' >&2
exit 1
fi
# Make sure everything's clean.
rm -f keytab keytab.bak srvtab srvtab.bak sync-kaserver
# Now, we can finally run our tests. First, basic operations.
runsuccess "" "$wallet" -k "$principal" -p 14373 -s localhost -c fake-wallet \
get keytab -f keytab service/fake-test
if cmp keytab data/fake-data >/dev/null 2>&1 ; then
printcount "ok"
else
printcount "not ok"
fi
if [ -f keytab.bak ] || [ -f keytab.new ] ; then
printcount "not ok"
else
printcount "ok"
fi
runsuccess "" "$wallet" -k "$principal" -p 14373 -s localhost -c fake-wallet \
get keytab -f keytab service/fake-test
if cmp keytab data/fake-data >/dev/null 2>&1 ; then
printcount "ok"
else
printcount "not ok"
fi
if [ -f keytab.new ] || [ ! -f keytab.bak ] ; then
printcount "not ok"
else
printcount "ok"
fi
# Now, append configuration to krb5.conf and test getting configuration from
# there.
cat >> krb5.conf <<EOF
[appdefaults]
wallet_server = localhost
wallet = {
wallet_port = 14373
wallet_type = fake-wallet
wallet_principal = $principal
}
EOF
runsuccess "" "$wallet" get keytab -f keytab service/fake-test
if cmp keytab data/fake-data >/dev/null 2>&1 ; then
printcount "ok"
else
printcount "not ok"
fi
# Test srvtab support.
runsuccess "" "$wallet" get keytab -f keytab -S srvtab service/fake-srvtab
if cmp keytab data/fake-keytab >/dev/null 2>&1 ; then
printcount "ok"
rm keytab
else
printcount "not ok"
fi
if cmp keytab.bak data/fake-data >/dev/null 2>&1 ; then
printcount "ok"
rm keytab.bak
else
printcount "not ok"
fi
if [ -f sync-kaserver ] ; then
printcount "ok"
else
printcount "not ok"
fi
runsuccess "" "$wallet" get keytab -f keytab -S srvtab service/fake-srvtab
if cmp keytab data/fake-keytab >/dev/null 2>&1 ; then
printcount "ok"
rm keytab
else
printcount "not ok"
fi
if [ -f sync-kaserver ] ; then
printcount "ok"
rm sync-kaserver
else
printcount "not ok"
fi
if cmp srvtab data/fake-srvtab >/dev/null 2>&1 ; then
printcount "ok"
rm srvtab
else
printcount "not ok"
fi
if cmp srvtab.bak data/fake-srvtab >/dev/null 2>&1 ; then
printcount "ok"
rm srvtab.bak
else
printcount "not ok"
fi
runsuccess "Some stuff about service/fake-test" \
"$wallet" show keytab service/fake-test
runfailure 1 "wallet: Unknown object type srvtab" \
"$wallet" get srvtab service/fake-test
runfailure 1 "wallet: Unknown keytab service/unknown" \
"$wallet" show keytab service/unknown
runfailure 1 "wallet: Unknown keytab service/unknown" \
"$wallet" get keytab service/unknown
runsuccess "Expiration date of service/fake-test" \
"$wallet" expires keytab service/fake-test
# Clean up.
KRB5_CONFIG=
rm data/krb5.conf
rm -f data/test.cache
if [ -f data/pid ] ; then
kill `cat data/pid`
rm -f data/pid
fi
|