Whamcloud - gitweb
LU-17662 osd-zfs: Support for ZFS 2.2.3
[fs/lustre-release.git] / lustre / tests / krb5_login.sh
1 #!/bin/bash
2 #
3 # krb5_login.sh - obtain and cache Kerberos ticket-granting ticket
4 #
5 ###############################################################################
6
7 #
8 # nothing need for root
9 #
10 [ $UID -eq 0 ] && exit 0
11
12 #
13 # list Kerberos 5 credentials silently
14 # exit status:
15 # 0 - klist finds a credentials cache
16 # 1 - klist does not find a credentials cache or the tickets are expired
17 #
18 klist -5 -s && exit 0
19
20 # get the user name for uid $UID
21 GSS_USER=$(getent passwd $UID | cut -d: -f1)
22
23 GSS_PASS=${GSS_PASS:-"$GSS_USER"}
24
25 echo "***** refresh Kerberos V5 TGT for uid $UID *****"
26 if [ -z "$GSS_PASS" ]; then
27     kinit
28 else
29     echo $GSS_PASS | kinit
30 fi
31 ret=$?
32 exit $ret