Skip to content

Commit 52b4c73

Browse files
committed
HADOOP-7091. reloginFromKeytab() should happen even if TGT can't be found. Contribued by Kan Zhang.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1057455 13f79535-47bb-0310-9956-ffa450edef68
1 parent 366e400 commit 52b4c73

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ Trunk (unreleased changes)
5656
HADOOP-6939. Inconsistent lock ordering in
5757
AbstractDelegationTokenSecretManager. (Todd Lipcon via tomwhite)
5858

59+
HADOOP-7091. reloginFromKeytab() should happen even if TGT can't be found.
60+
(Kan Zhang via jghoman)
61+
5962
Release 0.22.0 - Unreleased
6063

6164
INCOMPATIBLE CHANGES

src/java/org/apache/hadoop/security/UserGroupInformation.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ public boolean isFromKeytab() {
526526
* Get the Kerberos TGT
527527
* @return the user's TGT or null if none was found
528528
*/
529-
private KerberosTicket getTGT() {
529+
private synchronized KerberosTicket getTGT() {
530530
Set<KerberosTicket> tickets = subject
531531
.getPrivateCredentials(KerberosTicket.class);
532532
for (KerberosTicket ticket : tickets) {
@@ -657,20 +657,21 @@ public synchronized void reloginFromKeytab()
657657
!isKeytab)
658658
return;
659659

660-
KerberosTicket tgt = getTGT();
661-
if (tgt == null) {
660+
long now = System.currentTimeMillis();
661+
if (!hasSufficientTimeElapsed(now)) {
662662
return;
663663
}
664+
665+
KerberosTicket tgt = getTGT();
664666
//Return if TGT is valid and is not going to expire soon.
665-
if (System.currentTimeMillis() < getRefreshTime(tgt)) {
667+
if (tgt != null && now < getRefreshTime(tgt)) {
666668
return;
667669
}
668670

669671
LoginContext login = getLogin();
670672
if (login == null || keytabFile == null) {
671673
throw new IOException("loginUserFromKeyTab must be done first");
672674
}
673-
long now = System.currentTimeMillis();
674675

675676
long start = 0;
676677
// register most recent relogin attempt

0 commit comments

Comments
 (0)