Save path to .bash_profile in PROFILE_RC variable.
[profile.git] / .profile.d / krb5.bashrc
index 2ca4337..9c56dda 100644 (file)
@@ -3,7 +3,12 @@ alias pssh='ssh -o preferredauthentications=password,keyboard-interactive'
 
 unalias kinit 2>/dev/null
 if [ 1 = 0 -a -z "$OLDSOLARIS" -a -z "$OLDREDHAT" ]; then
-  if tty -s; 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.
@@ -87,6 +92,11 @@ fi
 
 unset cache ccname default ng
 function kinit() {
-  [ -n "$KRB5CCNAME" ] && krb5ccname="env KRB5CCNAME=$KRB5CCNAME"
-  ( builtin cd /; exec -c $krb5ccname kinit ${1+"$@"} )
+  local args=
+  local krb5ccname=
+  if [ -n "$KRB5CCNAME" ]; then
+    args="$@"
+    [ "${args/-c /}" = "$args" ] && krb5ccname="-c $KRB5CCNAME"
+  fi
+  ( builtin cd /; exec -c kinit $krb5ccname ${1+"$@"} )
 }