|
@@ -414,9 +414,20 @@ public class NameNode implements NamenodeProtocols, FSConstants {
|
|
|
}
|
|
|
|
|
|
private void startHttpServer(final Configuration conf) throws IOException {
|
|
|
- // Kerberized SSL servers must be run from the host principal...
|
|
|
- DFSUtil.login(conf, DFSConfigKeys.DFS_NAMENODE_KEYTAB_FILE_KEY,
|
|
|
- DFSConfigKeys.DFS_NAMENODE_KRB_HTTPS_USER_NAME_KEY);
|
|
|
+ if(UserGroupInformation.isSecurityEnabled()) {
|
|
|
+ String httpsUser = conf.get(DFSConfigKeys.DFS_NAMENODE_KRB_HTTPS_USER_NAME_KEY);
|
|
|
+ if(httpsUser == null) {
|
|
|
+ LOG.warn(DFSConfigKeys.DFS_NAMENODE_KRB_HTTPS_USER_NAME_KEY +
|
|
|
+ " not defined in config. Starting http server as "
|
|
|
+ + conf.get(DFSConfigKeys.DFS_NAMENODE_USER_NAME_KEY)
|
|
|
+ + ": Kerberized SSL may be not function correctly.");
|
|
|
+ } else {
|
|
|
+ // Kerberized SSL servers must be run from the host principal...
|
|
|
+ LOG.info("Logging in as " + httpsUser + " to start http server.");
|
|
|
+ DFSUtil.login(conf, DFSConfigKeys.DFS_NAMENODE_KEYTAB_FILE_KEY,
|
|
|
+ DFSConfigKeys.DFS_NAMENODE_KRB_HTTPS_USER_NAME_KEY);
|
|
|
+ }
|
|
|
+ }
|
|
|
UserGroupInformation ugi = UserGroupInformation.getLoginUser();
|
|
|
try {
|
|
|
this.httpServer = ugi.doAs(new PrivilegedExceptionAction<HttpServer>() {
|
|
@@ -483,9 +494,15 @@ public class NameNode implements NamenodeProtocols, FSConstants {
|
|
|
} catch (InterruptedException e) {
|
|
|
throw new IOException(e);
|
|
|
} finally {
|
|
|
- // Go back to being the correct Namenode principal
|
|
|
- DFSUtil.login(conf, DFSConfigKeys.DFS_NAMENODE_KEYTAB_FILE_KEY,
|
|
|
- DFSConfigKeys.DFS_NAMENODE_USER_NAME_KEY);
|
|
|
+ if(UserGroupInformation.isSecurityEnabled() &&
|
|
|
+ conf.get(DFSConfigKeys.DFS_NAMENODE_KRB_HTTPS_USER_NAME_KEY) != null) {
|
|
|
+ // Go back to being the correct Namenode principal
|
|
|
+ LOG.info("Logging back in as "
|
|
|
+ + conf.get(DFSConfigKeys.DFS_NAMENODE_USER_NAME_KEY)
|
|
|
+ + " following http server start.");
|
|
|
+ DFSUtil.login(conf, DFSConfigKeys.DFS_NAMENODE_KEYTAB_FILE_KEY,
|
|
|
+ DFSConfigKeys.DFS_NAMENODE_USER_NAME_KEY);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|