source: web/old/remctl-2.14/tests/tap/kerberos.sh @ f6f3e91

web
Last change on this file since f6f3e91 was f6f3e91, checked in by Jessica B. Hamrick <jhamrick@…>, 15 years ago

Preserve directory hierarchy (not sure what happened to it)

  • Property mode set to 100644
File size: 1.5 KB
Line 
1# Shell function library to initialize Kerberos credentials
2#
3# Written by Russ Allbery <rra@stanford.edu>
4# Copyright 2009 Board of Trustees, Leland Stanford Jr. University
5#
6# See LICENSE for licensing terms.
7
8# Set up Kerberos, including the ticket cache environment variable.  Bail out
9# if not successful, return 0 if successful, and return 1 if Kerberos is not
10# configured.  Sets the global principal variable to the principal to use.
11kerberos_setup () {
12    local keytab
13    keytab=''
14    for f in "$BUILD/data/test.keytab" "$SOURCE/data/test.keytab" ; do
15        if [ -r "$f" ] ; then
16            keytab="$f"
17        fi
18    done
19    principal=''
20    for f in "$BUILD/data/test.principal" "$SOURCE/data/test.principal" ; do
21        if [ -r "$f" ] ; then
22            principal=`cat "$BUILD/data/test.principal"`
23        fi
24    done
25    if [ -z "$keytab" ] || [ -z "$principal" ] ; then
26        return 1
27    fi
28    KRB5CCNAME="$BUILD/data/test.cache"; export KRB5CCNAME
29    kinit -k -t "$keytab" "$principal" >/dev/null </dev/null
30    status=$?
31    if [ $status != 0 ] ; then
32        kinit -t "$keytab" "$principal" >/dev/null </dev/null
33        status=$?
34    fi
35    if [ $status != 0 ] ; then
36        kinit -k -K "$keytab" "$principal" >/dev/null </dev/null
37        status=$?
38    fi
39    if [ $status != 0 ] ; then
40        bail "Can't get Kerberos tickets"
41    fi
42    return 0
43}
44
45# Clean up at the end of a test.  Currently only removes the ticket cache.
46kerberos_cleanup () {
47    rm -f "$BUILD/data/test.cache"
48}
Note: See TracBrowser for help on using the repository browser.