Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lustre / tests / krb5_login.sh
1 #!/bin/sh
2
3 #
4 # nothing need for root
5 #
6 if [ $UID -eq 0 ]; then
7     exit 0
8 fi
9
10 if [ -z "$KRB5DIR" ]; then
11     KRB5DIR=/usr/kerberos
12 fi
13
14 $KRB5DIR/bin/klist -5 -s
15 invalid=$?
16
17 if [ $invalid -eq 0 ]; then
18     exit 0
19 fi
20
21 echo "***** refresh Kerberos V5 TGT for uid $UID *****"
22 if [ -z "$GSS_PASS" ]; then
23     $KRB5DIR/bin/kinit
24 else
25     expect <<EOF
26 set timeout 30 
27
28 log_user 1 
29
30 set spawnid [spawn /bin/bash]
31 send "export PS1=\"user@host $ \" \r"
32 expect {
33     timeout {puts "timeout" ;exit 1}
34     "user@host $ "
35 }
36
37 send "$KRB5DIR/bin/kinit\r"
38 expect {
39     timeout {puts "timeout" ;exit 1}
40     "Password for "
41 }
42
43 send "$GSS_PASS\r"
44 expect {
45     timeout {puts "timeout" ;exit 1}
46     "user@host $ "
47 }
48
49 exit 0
50 EOF
51 fi
52 ret=$?
53 exit $ret