Debian Codegraph @

debian/tests/slapd-gssapi

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2
3 set -ex
4
5 . debian/tests/utilscip-shell source . . `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 chownscip-shell system . . chown. root:openldap /etc/krb5.keytabscip-shell filesystem . . `/etc/krb5.keytab`.
28 chmodscip-shell system . . chmod. 0640 /etc/krb5.keytabscip-shell filesystem . . `/etc/krb5.keytab`.
29
30 # Prepare some LDAP defaults
31 # The LDAP base doesn't matter for this test
32 catscip-shell system . . cat. > /etc/ldap/ldap.confscip-shell filesystem . . `/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 echoscip-shell system . . echo. secret | kinit ${principal}
43 klist | grepscip-shell system . . 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 | grepscip-shell system . . grep. -E "^dn:uid=${principal},cn=gssapi,cn=auth"
47
48 # and we should have an ldap ticket
49 klist | grepscip-shell system . . grep. ldap/${MYHOSTNAME}@${TEST_REALM}
50
51 # remove tickets
52 kdestroy