Skip to content

Commit ef178da

Browse files
committed
fix krb5conf is not refresh
1 parent 2080cd0 commit ef178da

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

core/src/main/java/com/dtstack/flink/sql/util/KrbUtils.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@
2020

2121
import org.apache.hadoop.conf.Configuration;
2222
import org.apache.hadoop.security.UserGroupInformation;
23+
import org.apache.hadoop.security.authentication.util.KerberosName;
2324
import org.slf4j.Logger;
2425
import org.slf4j.LoggerFactory;
26+
import sun.security.krb5.Config;
27+
import sun.security.krb5.KrbException;
2528

2629
import java.io.IOException;
2730

@@ -43,6 +46,13 @@ public class KrbUtils {
4346
public static UserGroupInformation getUgi(String principal, String keytabPath, String krb5confPath) throws IOException {
4447
LOG.info("Kerberos login with principal: {} and keytab: {}", principal, keytabPath);
4548
System.setProperty(KRB5_CONF_KEY, krb5confPath);
49+
// 不刷新会读/etc/krb5.conf
50+
try {
51+
Config.refresh();
52+
KerberosName.resetDefaultRealm();
53+
} catch (KrbException e) {
54+
LOG.warn("resetting default realm failed, current default realm will still be used.", e);
55+
}
4656
// TODO 尚未探索出此选项的意义,以后研究明白方可打开
4757
// System.setProperty(SUBJECT_ONLY_KEY, FALSE_STR);
4858
Configuration configuration = new Configuration();

0 commit comments

Comments
 (0)