HDFS-16750. NameNode should use NameNode.getRemoteUser() to log audit event to avoid possible NPE (#4821)
This commit is contained in:
parent
c48ed3e96c
commit
7b239a80fe
@ -160,6 +160,7 @@
|
||||
import org.apache.hadoop.hdfs.server.datanode.fsdataset.impl.BlockPoolSlice;
|
||||
import org.apache.hadoop.hdfs.server.datanode.fsdataset.impl.FsVolumeImpl;
|
||||
import org.apache.hadoop.hdfs.util.DataTransferThrottler;
|
||||
import org.apache.hadoop.ipc.Server;
|
||||
import org.apache.hadoop.util.*;
|
||||
import org.apache.hadoop.hdfs.client.BlockReportOptions;
|
||||
import org.apache.hadoop.hdfs.client.HdfsClientConfigKeys;
|
||||
@ -1439,7 +1440,7 @@ private void checkSuperuserPrivilege() throws IOException, AccessControlExceptio
|
||||
return;
|
||||
}
|
||||
// Try to get the ugi in the RPC call.
|
||||
UserGroupInformation callerUgi = ipcServer.getRemoteUser();
|
||||
UserGroupInformation callerUgi = Server.getRemoteUser();
|
||||
if (callerUgi == null) {
|
||||
// This is not from RPC.
|
||||
callerUgi = UserGroupInformation.getCurrentUser();
|
||||
|
@ -417,7 +417,7 @@ void logAuditEvent(boolean succeeded, String cmd, String src)
|
||||
private void logAuditEvent(boolean succeeded, String cmd, String src,
|
||||
String dst, FileStatus stat) throws IOException {
|
||||
if (isAuditEnabled() && isExternalInvocation()) {
|
||||
logAuditEvent(succeeded, Server.getRemoteUser(), Server.getRemoteIp(),
|
||||
logAuditEvent(succeeded, NameNode.getRemoteUser(), Server.getRemoteIp(),
|
||||
cmd, src, dst, stat);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user