Debian Codegraph @

debian/tests/slapd-gssapi

raw symbols SCIP
1 #!/bin/sh
2
3 set -ex
4
5 . debian/tests/util
6
7 TEST_REALM="EXAMPLE.INTERNAL"
8 MYHOSTNAME="krb5-dep8.internal"
9 adjust_hostname "${MYHOSTNAME}"
10
11 create_realm "${TEST_REALM}" "${MYHOSTNAME}"
12
13 # restart slapd
14 systemctl restart slapd.service
15
16 # create a random-enough principal
17 principal="testuser$$"
18 kadmin.local -q "addprinc -pw secret ${principal}"
19
20 # create an ldap service principal
21 kadmin.local -q "addprinc -randkey ldap/${MYHOSTNAME}"
22
23 # extract the key into the system keytab
24 kadmin.local -q "ktadd -k /etc/krb5.keytab ldap/${MYHOSTNAME}"
25
26 # make sure the user under which the service runs can read that keytab
27 chown root:openldap /etc/krb5.keytab
28 chmod 0640 /etc/krb5.keytab
29
30 # Prepare some LDAP defaults
31 # The LDAP base doesn't matter for this test
32 cat > /etc/ldap/ldap.conf <<EOF
33 BASE dc=example,dc=internal
34 URI ldap://${MYHOSTNAME}/
35 SASL_REALM ${TEST_REALM}
36 # Do not perform reverse DNS lookups to canonicalize SASL host names.
37 SASL_NOCANON yes
38 EOF
39
40 # moment of truth
41 # first, authenticate ourselves
42 echo secret | kinit ${principal}
43 klist | grep krbtgt/${TEST_REALM}@${TEST_REALM}
44
45 # now let's see if ldap thinks we are authenticated with gssapi
46 ldapwhoami -Y GSSAPI -Q | grep -E "^dn:uid=${principal},cn=gssapi,cn=auth"
47
48 # and we should have an ldap ticket
49 klist | grep ldap/${MYHOSTNAME}@${TEST_REALM}
50
51 # remove tickets
52 kdestroy