X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=.profile.d%2Fkrb5.bashrc;h=9c56dda0baad256d8a16b32c24bb805f6468970f;hb=96345c68b1b8a5b1b4159ebd38abbe4a6992a090;hp=9938a30ce51b9b82e0ef997afd3eabb538197298;hpb=f5a7e98a8d77bd6a74ba040266016f369ca4e2dc;p=profile.git diff --git a/.profile.d/krb5.bashrc b/.profile.d/krb5.bashrc index 9938a30..9c56dda 100644 --- a/.profile.d/krb5.bashrc +++ b/.profile.d/krb5.bashrc @@ -2,8 +2,13 @@ alias kssh='ssh -o preferredauthentications=gssapi-with-mic' alias pssh='ssh -o preferredauthentications=password,keyboard-interactive' unalias kinit 2>/dev/null -if [ -z "$OLDSOLARIS" -a -z "$OLDREDHAT" ]; then - if tty -s; then +if [ 1 = 0 -a -z "$OLDSOLARIS" -a -z "$OLDREDHAT" ]; then + if [ -t 0 ]; then + # Canonicalise the cache name. + if [ -n "$KRB5CCNAME" -a "${KRB5CCNAME##*:}" = "$KRB5CCNAME" ]; then + export KRB5CCNAME="FILE:$KRB5CCNAME" + fi + if [ ! "$SUDO_UID" ]; then if klist -s 2>/dev/null; then # We already have a ticket cache. Renew it. @@ -86,4 +91,12 @@ if [ -z "$OLDSOLARIS" -a -z "$OLDREDHAT" ]; then fi unset cache ccname default ng -alias kinit='( builtin cd /; exec -c kinit )' +function kinit() { + local args= + local krb5ccname= + if [ -n "$KRB5CCNAME" ]; then + args="$@" + [ "${args/-c /}" = "$args" ] && krb5ccname="-c $KRB5CCNAME" + fi + ( builtin cd /; exec -c kinit $krb5ccname ${1+"$@"} ) +}