Skip to content

Commit 35205ac

Browse files
committed
fix kerberos auth error
1 parent d2406a4 commit 35205ac

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

flinkx-core/src/main/java/com/dtstack/flinkx/util/FileSystemUtil.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ public static void setHadoopUserName(Configuration conf){
6969
}
7070

7171
try {
72-
String ticketCachePath = conf.get("hadoop.security.kerberos.ticket.cache.path");
73-
UserGroupInformation ugi = UserGroupInformation.getBestUGI(ticketCachePath, hadoopUserName);
72+
UserGroupInformation ugi = UserGroupInformation.createRemoteUser(hadoopUserName);
7473
UserGroupInformation.setLoginUser(ugi);
7574
} catch (Exception e) {
7675
LOG.warn("Set hadoop user name error:", e);
@@ -87,7 +86,6 @@ public static boolean isOpenKerberos(Map<String, Object> hadoopConfig){
8786

8887
private static FileSystem getFsWithKerberos(Map<String, Object> hadoopConfig, String defaultFs) throws Exception{
8988
UserGroupInformation ugi = getUGI(hadoopConfig, defaultFs);
90-
UserGroupInformation.setLoginUser(ugi);
9189

9290
return ugi.doAs(new PrivilegedAction<FileSystem>() {
9391
@Override
@@ -110,7 +108,6 @@ public static UserGroupInformation getUGI(Map<String, Object> hadoopConfig, Stri
110108
KerberosUtil.refreshConfig();
111109

112110
UserGroupInformation ugi = KerberosUtil.loginAndReturnUgi(getConfiguration(hadoopConfig, defaultFs), principal, keytabFileName);
113-
UserGroupInformation.setLoginUser(ugi);
114111

115112
return ugi;
116113
}

0 commit comments

Comments
 (0)