1 alias kssh='ssh -o preferredauthentications=gssapi-with-mic'
2 alias pssh='ssh -o preferredauthentications=password,keyboard-interactive'
4 if [ -z "$OLDSOLARIS" -a -z "$OLDREDHAT" ]; then
6 if [ ! "$SUDO_UID" ]; then
7 if klist -s 2>/dev/null; then
8 # We already have a ticket cache. Renew it.
11 # Try to find an existing cache but only if we are using FILE: caches.
12 default=$((unset KRB5CCNAME; klist 2>&1) | sed -n 's/.*FILE:\([^)]*\).*/\1/p')
13 if [ ! -z "$default" ]; then
14 # Check for Exceed onDemand stupidity.
15 if [ "$KRB5CCNAME" = "FILE:" ]; then
19 # Check for bogus FILE: KRB5CCNAME.
20 if [ ! -z "$KRB5CCNAME" -a "${KRB5CCNAME##*:}" = "$KRB5CCNAME" ]; then
21 export KRB5CCNAME="FILE:$KRB5CCNAME"
25 ccname="${KRB5CCNAME##FILE:}"
26 if [ "$ccname" = "$KRB5CCNAME" ]; then
27 # Our cache isn't a file cache. Throw it away.
32 # Remember if nullglob was on.
35 # Turn it on so we can look for caches safely.
38 for cache in $default*; do
39 if klist -s -c "$cache"; then
40 if [ ! "$cache" = "$ccname" ]; then
41 # It may not be safe to simply point the environment to this
42 # cache as it may belong to a session which is about to end.
43 # Therefore we copy it.
44 cp -p "$cache" "$ccname" || continue
51 # Maybe turn nocaseglob back off.
52 [ $ng = 0 ] || shopt -u nullglob
55 # By now we should have found a cache if there's one to find.
56 klist -s 2>/dev/null || kinit
58 elif [ ! -z "$KRB5CCNAME" ]; then
59 # Don't break permissions of inherited cache under sudo.
60 cache="${KRB5CCNAME##FILE:}"
61 if [ ! "$cache" = "$KRB5CCNAME" ]; then
62 ccname="${cache/_$SUDO_UID/_${UID}_sudo_$SUDO_UID}_$$"
63 export KRB5CCNAME="FILE:$ccname"
66 if cat "$cache" > "$ccname" 2>/dev/null; then
67 klist -s 2>/dev/null && kinit -R 2>/dev/null || kinit $PRINCIPAL
68 elif [ -n "$KRB5BASE64" ]; then
69 if [ -n "$KRB5OPENSSL" ]; then
70 builtin echo "$KRB5BASE64" | $KRB5OPENSSL enc -a -d -out "$ccname"
72 unset KRB5BASE64 KRB5OPENSSL
74 # XXX: Don't kinit every time if we aren't root.
75 # TODO: Split the "set my cache" and "get my credentials" parts so
76 # that becoming a user other than root will work without
78 rm "$ccname" 2>/dev/null
81 trap "kdestroy 2>/dev/null" EXIT
87 unset cache ccname default ng