Github user jerryshao commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21178#discussion_r184844613
  
    --- Diff: 
sql/hive-thriftserver/src/main/java/org/apache/hive/service/auth/HiveAuthFactory.java
 ---
    @@ -362,4 +371,34 @@ public static void verifyProxyAccess(String realUser, 
String proxyUser, String i
         }
       }
     
    +  public static boolean needUgiLogin(UserGroupInformation ugi, String 
principal, String keytab) {
    +    return null == ugi || !ugi.hasKerberosCredentials() || 
!ugi.getUserName().equals(principal) ||
    +      !keytab.equals(getKeytabFromUgi());
    +  }
    +
    +  private static String getKeytabFromUgi() {
    +    Class<?> clz = UserGroupInformation.class;
    +    try {
    +      synchronized (clz) {
    +        Field field = clz.getDeclaredField("keytabFile");
    +        field.setAccessible(true);
    +        return (String) field.get(null);
    +      }
    +    } catch (NoSuchFieldException e) {
    +      try {
    +        synchronized (clz) {
    +          // In Hadoop 3 we don't have "keytabFile" field, instead we 
should use private method
    +          // getKeytab().
    +          Method method = clz.getDeclaredMethod("getKeytab");
    +          method.setAccessible(true);
    +          return (String) 
method.invoke(UserGroupInformation.getCurrentUser());
    --- End diff --
    
    Sure, I will change it.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to