#!/bin/sh # # Build a Kerberos test realm for Heimdal. # # This script automates the process of setting up a Kerberos test realm from # scratch. It is primarily intended to be run from inside CI in a VM or # container from the top of the source tree, and must be run as root. It # expects to be operating on the Debian Heimdal package. # # Copyright 2014, 2020-2021 Russ Allbery # # SPDX-License-Identifier: MIT set -eux # Install the KDC. apt-get install heimdal-kdc # Install its configuration files. cp ci/files/heimdal/heimdal-kdc /etc/default/heimdal-kdc cp ci/files/heimdal/kdc.conf /etc/heimdal-kdc/kdc.conf cp ci/files/heimdal/krb5.conf /etc/krb5.conf touch /etc/heimdal-kdc/kadmind.acl # Some versions of heimdal-kdc require this. ln -s /etc/heimdal-kdc/kadmind.acl /var/lib/heimdal-kdc/kadmind.acl # Add domain-realm mappings for the local host, since otherwise Heimdal and # MIT Kerberos may attempt to discover the realm of the local domain, and the # DNS server for GitHub Actions has a habit of just not responding and causing # the test to hang. cat <>/etc/krb5.conf [domain_realm] $(hostname -f) = HEIMDAL.TEST EOF cat <>/etc/heimdal-kdc/kdc.conf [domain_realm] $(hostname -f) = HEIMDAL.TEST EOF # Create the basic KDC. kstash --random-key kadmin -l init --realm-max-ticket-life='1 day 1 hour' \ --realm-max-renewable-life='1 week' HEIMDAL.TEST # Set default principal policies. kadmin -l modify --attributes=requires-pre-auth,disallow-svr \ default@HEIMDAL.TEST # Create and store the keytab. kadmin -l add -r --use-defaults --attributes=requires-pre-auth \ test/keytab@HEIMDAL.TEST kadmin -l ext_keytab -k tests/data/test.keytab test/keytab@HEIMDAL.TEST echo 'test/keytab@HEIMDAL.TEST' >tests/data/test.principal # Fix permissions on all the newly-created files. chmod 644 tests/data/test.* # Restart the Heimdal KDC and services. systemctl stop heimdal-kdc systemctl start heimdal-kdc