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
|
#! /bin/sh
# $OpenLDAP$
## This work is part of OpenLDAP Software <http://www.openldap.org/>.
##
## Copyright 1998-2022 The OpenLDAP Foundation.
## All rights reserved.
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted only as authorized by the OpenLDAP
## Public License.
##
## A copy of this license is available in the file LICENSE in the
## top-level directory of the distribution or, alternatively, at
## <http://www.OpenLDAP.org/license.html>.
KRB5_TRACE=$TESTDIR/k5_trace
KRB5_CONFIG=$TESTDIR/krb5.conf
KRB5_KDC_PROFILE=$KRB5_CONFIG
KRB5_KTNAME=$TESTDIR/server.kt
KRB5_CLIENT_KTNAME=$TESTDIR/client.kt
KRB5CCNAME=$TESTDIR/client.ccache
export KRB5_TRACE KRB5_CONFIG KRB5_KDC_PROFILE KRB5_KTNAME KRB5_CLIENT_KTNAME KRB5CCNAME
KDCLOG=$TESTDIR/setup_kdc.log
KSERVICE=ldap/$LOCALHOST
KUSER=kuser
. $CONFFILTER < $DATADIR/krb5.conf > $KRB5_CONFIG
PATH=${PATH}:/usr/lib/heimdal-servers:/usr/sbin:/usr/local/sbin
echo "Trying Heimdal KDC..."
command -v kdc >/dev/null 2>&1
if test $? = 0 ; then
kstash --random-key > $KDCLOG 2>&1
RC=$?
if test $RC != 0 ; then
echo "Heimdal: kstash failed, skipping GSSAPI tests"
exit 0
fi
flags="--realm-max-ticket-life=1h --realm-max-renewable-life=1h"
kadmin -l init $flags $KRB5REALM > $KDCLOG 2>&1
RC=$?
if test $RC != 0 ; then
echo "Heimdal: kadmin init failed, skipping GSSAPI tests"
exit 0
fi
kadmin -l add --random-key --use-defaults $KSERVICE > $KDCLOG 2>&1
RC=$?
if test $RC != 0 ; then
echo "Heimdal: kadmin add failed, skipping GSSAPI tests"
exit 0
fi
kadmin -l ext -k $KRB5_KTNAME $KSERVICE > $KDCLOG 2>&1
RC=$?
if test $RC != 0 ; then
echo "Heimdal: kadmin ext failed, skipping GSSAPI tests"
exit 0
fi
kadmin -l add --random-key --use-defaults $KUSER > $KDCLOG 2>&1
RC=$?
if test $RC != 0 ; then
echo "Heimdal: kadmin add failed, skipping GSSAPI tests"
exit 0
fi
kadmin -l ext -k $KRB5_CLIENT_KTNAME $KUSER > $KDCLOG 2>&1
RC=$?
if test $RC != 0 ; then
echo "Heimdal: kadmin ext failed, skipping GSSAPI tests"
exit 0
fi
kdc --addresses=$LOCALIP --ports="$KDCPORT/udp" > $KDCLOG 2>&1 &
else
echo "Trying MIT KDC..."
command -v krb5kdc >/dev/null 2>&1
if test $? != 0; then
echo "No KDC available, skipping GSSAPI tests"
exit 0
fi
kdb5_util create -r $KRB5REALM -s -P password > $KDCLOG 2>&1
RC=$?
if test $RC != 0 ; then
echo "MIT: kdb5_util create failed, skipping GSSAPI tests"
exit 0
fi
kadmin.local -q "addprinc -randkey $KSERVICE" > $KDCLOG 2>&1
RC=$?
if test $RC != 0 ; then
echo "MIT: admin addprinc failed, skipping GSSAPI tests"
exit 0
fi
kadmin.local -q "ktadd -k $KRB5_KTNAME $KSERVICE" > $KDCLOG 2>&1
RC=$?
if test $RC != 0 ; then
echo "MIT: kadmin ktadd failed, skipping GSSAPI tests"
exit 0
fi
kadmin.local -q "addprinc -randkey $KUSER" > $KDCLOG 2>&1
RC=$?
if test $RC != 0 ; then
echo "MIT: kadmin addprinc failed, skipping GSSAPI tests"
exit 0
fi
kadmin.local -q "ktadd -k $KRB5_CLIENT_KTNAME $KUSER" > $KDCLOG 2>&1
RC=$?
if test $RC != 0 ; then
echo "MIT: kadmin ktadd failed, skipping GSSAPI tests"
exit 0
fi
krb5kdc -n > $KDCLOG 2>&1 &
fi
KDCPROC=$!
sleep 1
kinit -kt $KRB5_CLIENT_KTNAME $KUSER > $KDCLOG 2>&1
RC=$?
if test $RC != 0 ; then
kill $KDCPROC
echo "SASL/GSSAPI: kinit failed, skipping GSSAPI tests"
exit 0
fi
pluginviewer -m GSSAPI > $TESTDIR/plugin_out 2>/dev/null
RC=$?
if test $RC != 0 ; then
saslpluginviewer -m GSSAPI > $TESTDIR/plugin_out 2>/dev/null
RC=$?
if test $RC != 0 ; then
kill $KDCPROC
echo "cyrus-sasl has no GSSAPI support, test skipped"
exit 0
fi
fi
HAVE_SASL_GSS_CBIND=no
grep CHANNEL_BINDING $TESTDIR/plugin_out > /dev/null 2>&1
RC=$?
if test $RC = 0 ; then
HAVE_SASL_GSS_CBIND=yes
fi
|