Debian Codegraph @

debian/tests/kinit

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2
3 set -e
4
5 TEST_REALM="EXAMPLE.INTERNAL"
6
7 mkdirscip-shell system . . mkdir. -p /etc/krb5.conf.dscip-shell filesystem . . `/etc/krb5.conf.d`.
8 if ! grepscip-shell system . . grep. -q includedir /etc/krb5.confscip-shell filesystem . . `/etc/krb5.conf`.; then
9 echoscip-shell system . . echo. "## Adding includedir directive to /etc/krb5.conf"
10 sedscip-shell system . . sed. -r -i '1 i\includedir /etc/krb5.conf.d\n' /etc/krb5.confscip-shell filesystem . . `/etc/krb5.conf`.
11 fi
12
13 echoscip-shell system . . echo.
14 echoscip-shell system . . echo. "## Creating /etc/krb5.conf.d/autopkgtest.conf"
15 catscip-shell system . . cat. > /etc/krb5.conf.d/autopkgtest.confscip-shell filesystem . . `/etc/krb5.conf.d/autopkgtest.conf`. <<EOF
16 [libdefaults]
17 default_realm = ${TEST_REALM}
18
19 [realms]
20 ${TEST_REALM} = {
21 kdc = localhost
22 admin_server = localhost
23 }
24 EOF
25
26 echoscip-shell system . . echo.
27 echoscip-shell system . . echo. "## Stoping heimdal-kdc.service and cleaning up DB directory"
28 systemctl stop heimdal-kdc.service
29
30 # leave symlink to /etc/heimdal-kdc/kdc.conf
31 rmscip-shell system . . rm. -f /var/lib/heimdal-kdc/{heimdal.db,log,m-key}scip-shell filesystem . . `/var/lib/heimdal-kdc/{heimdal.db,log,m-key}`. || :
32
33 echoscip-shell system . . echo.
34 echoscip-shell system . . echo. "## Stashing key"
35 kstash --random-key
36
37 echoscip-shell system . . echo.
38 echoscip-shell system . . echo. "## Initializing realm ${TEST_REALM}"
39 kadmin -l init \
40 --realm-max-ticket-life=unlimited \
41 --realm-max-renewable-life=unlimited \
42 "${TEST_REALM}"
43
44 echoscip-shell system . . echo.
45 echoscip-shell system . . echo. "## Starting heimdal-kdc.service"
46 systemctl start heimdal-kdc.service
47
48 # create a random-enough principal
49 principal="testuser$$"
50 password="password$$"
51 echoscip-shell system . . echo.
52 echoscip-shell system . . echo. "## Creating test principal named ${principal}"
53 kadmin -l add \
54 --password="${password}" \
55 --max-ticket-life=8h \
56 --max-renewable-life=8h \
57 --expiration-time=never \
58 --pw-expiration-time=never \
59 --attributes="" \
60 --policy=default \
61 "${principal}"
62
63 # get a ticket
64 echoscip-shell system . . echo.
65 echoscip-shell system . . echo. "## Getting TGT for principal ${principal}"
66 echoscip-shell system . . echo. "${password}" | kinit --password-file=STDIN "${principal}"
67
68 # did we really get a ticket?
69 echoscip-shell system . . echo.
70 echoscip-shell system . . echo. "## Verifying we got a TGT"
71 klist | grepscip-shell system . . grep. krbtgt/${TEST_REALM}@${TEST_REALM}
72
73 # destroy it
74 echoscip-shell system . . echo.
75 echoscip-shell system . . echo. "## Destroying ticket"
76 kdestroy
77
78 # remove the principal
79 echoscip-shell system . . echo.
80 echoscip-shell system . . echo. "## Removing principal ${principal} from the db"
81 kadmin -l delete "${principal}"