# Shell function library for Kerberos test support. # # Written by Russ Allbery # Copyright 2009, 2010 Board of Trustees, Leland Stanford Jr. University # # See LICENSE for licensing terms. # Set up Kerberos, including the ticket cache environment variable. Bail out # if not successful, return 0 if successful, and return 1 if Kerberos is not # configured. Sets the global principal variable to the principal to use. kerberos_setup () { local keytab keytab='' for f in "$BUILD/data/test.keytab" "$SOURCE/data/test.keytab" ; do if [ -r "$f" ] ; then keytab="$f" fi done principal='' for f in "$BUILD/data/test.principal" "$SOURCE/data/test.principal" ; do if [ -r "$f" ] ; then principal=`cat "$BUILD/data/test.principal"` fi done if [ -z "$keytab" ] || [ -z "$principal" ] ; then return 1 fi KRB5CCNAME="$BUILD/data/test.cache"; export KRB5CCNAME kinit -k -t "$keytab" "$principal" >/dev/null /dev/null /dev/null ktutil-tmp 2>/dev/null ; then : else ktutil -k "$1" list --keys > ktutil-tmp < /dev/null 2>/dev/null fi sed -e '/Keytab name:/d' -e "/^[^ ]*:/d" ktutil-tmp > "$2" rm -f ktutil-tmp }