# Copyright 2018 Canonical Ltd. # This code is licensed under the same terms as MIT Kerberos. set -e adjust_hostname() { local myhostname="$1" echo "${myhostname}" > /etc/hostname hostname "${myhostname}" if ! grep -qE "${myhostname}" /etc/hosts; then # just so it's resolvable echo "127.0.1.10 ${myhostname}" >> /etc/hosts fi } create_realm() { local realm_name="$1" local kerberos_server="$2" # start fresh rm -rf /var/lib/krb5kdc/* rm -rf /etc/krb5kdc/* rm -f /etc/krb5.keytab # setup some defaults cat > /etc/krb5kdc/kdc.conf < /etc/krb5.conf < /etc/krb5kdc/kadm5.acl # create the realm kdb5_util create -s -P secretpassword # restart services systemctl restart krb5-kdc.service krb5-admin-server.service } run_test() { local testfunc="${1}" local -i result=0 shift echo "## TEST ${testfunc}" "${testfunc}" "${@}" || result=$? if [ ${result} -ne 0 ]; then echo "## FAIL ${testfunc}" else echo "## PASS ${testfunc}" fi echo return ${result} }