Whamcloud - gitweb
Allow GSS password to be passed to the test-framework in $GSS_PASS.
[fs/lustre-release.git] / lustre / tests / krb5_refresh_cache.sh
1 #!/bin/sh
2
3 KRB5DIR=${KRB5DIR:-"/usr/kerberos"}
4
5 $KRB5DIR/bin/klist -5 -s
6 invalid=$?
7
8 if [ $invalid -eq 0 ]; then
9     exit 0
10 fi
11
12 #
13 # check installed service keytab for root
14 #
15 if [ $UID -eq 0 ]; then
16     output=`$KRB5DIR/bin/klist -5 -k`
17     if [ $? == 0 ]; then
18         item=`echo $output | egrep "lustre_mds/.*@"`
19         if [ "x$item" != "x" ]; then
20             echo "Using service keytab"
21             exit 0
22         fi
23     fi
24 fi
25
26 echo "***** refresh Kerberos V5 TGT for uid $UID *****"
27 if [ -z "$GSS_PASS" ]; then
28     $KRB5DIR/bin/kinit
29 else
30     expect <<EOF
31 set timeout 30 
32
33 log_user 1 
34
35 set spawnid [spawn /bin/bash]
36 send "export PS1=\"user@host $ \" \r"
37 expect {
38     timeout {puts "timeout" ;exit 1}
39     "user@host $ "
40 }
41
42 send "$KRB5DIR/bin/kinit\r"
43 {
44     timeout {puts "timeout" ;exit 1}
45     "Password for "
46
47 send "$GSS_PASS\r"
48 expect {
49     timeout {puts "timeout" ;exit 1}
50     "user@host $ "
51 }
52
53 exit 0
54 EOF
55 fi
56 ret=$?
57 exit $ret