|
@@ -36,6 +36,8 @@ import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_HA_STANDBY_CHECKPOINTS_KE
|
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_ACCESSTIME_PRECISION_DEFAULT;
|
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_ACCESSTIME_PRECISION_DEFAULT;
|
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_ACCESSTIME_PRECISION_KEY;
|
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_ACCESSTIME_PRECISION_KEY;
|
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_AUDIT_LOGGERS_KEY;
|
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_AUDIT_LOGGERS_KEY;
|
|
|
|
+import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_AUDIT_LOG_TOKEN_TRACKING_ID_DEFAULT;
|
|
|
|
+import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_AUDIT_LOG_TOKEN_TRACKING_ID_KEY;
|
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_DEFAULT_AUDIT_LOGGER_NAME;
|
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_DEFAULT_AUDIT_LOGGER_NAME;
|
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_DELEGATION_KEY_UPDATE_INTERVAL_DEFAULT;
|
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_DELEGATION_KEY_UPDATE_INTERVAL_DEFAULT;
|
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_DELEGATION_KEY_UPDATE_INTERVAL_KEY;
|
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_DELEGATION_KEY_UPDATE_INTERVAL_KEY;
|
|
@@ -218,6 +220,8 @@ import org.apache.hadoop.security.UserGroupInformation;
|
|
import org.apache.hadoop.security.UserGroupInformation.AuthenticationMethod;
|
|
import org.apache.hadoop.security.UserGroupInformation.AuthenticationMethod;
|
|
import org.apache.hadoop.security.token.SecretManager.InvalidToken;
|
|
import org.apache.hadoop.security.token.SecretManager.InvalidToken;
|
|
import org.apache.hadoop.security.token.Token;
|
|
import org.apache.hadoop.security.token.Token;
|
|
|
|
+import org.apache.hadoop.security.token.TokenIdentifier;
|
|
|
|
+import org.apache.hadoop.security.token.delegation.AbstractDelegationTokenIdentifier;
|
|
import org.apache.hadoop.security.token.delegation.DelegationKey;
|
|
import org.apache.hadoop.security.token.delegation.DelegationKey;
|
|
import org.apache.hadoop.util.Daemon;
|
|
import org.apache.hadoop.util.Daemon;
|
|
import org.apache.hadoop.util.DataChecksum;
|
|
import org.apache.hadoop.util.DataChecksum;
|
|
@@ -293,8 +297,14 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
stat.getGroup(), symlink, path);
|
|
stat.getGroup(), symlink, path);
|
|
}
|
|
}
|
|
for (AuditLogger logger : auditLoggers) {
|
|
for (AuditLogger logger : auditLoggers) {
|
|
- logger.logAuditEvent(succeeded, ugi.toString(), addr,
|
|
|
|
- cmd, src, dst, status);
|
|
|
|
|
|
+ if (logger instanceof HdfsAuditLogger) {
|
|
|
|
+ HdfsAuditLogger hdfsLogger = (HdfsAuditLogger) logger;
|
|
|
|
+ hdfsLogger.logAuditEvent(succeeded, ugi.toString(), addr, cmd, src, dst,
|
|
|
|
+ status, ugi, dtSecretManager);
|
|
|
|
+ } else {
|
|
|
|
+ logger.logAuditEvent(succeeded, ugi.toString(), addr,
|
|
|
|
+ cmd, src, dst, status);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -5840,7 +5850,10 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
DFS_NAMENODE_DELEGATION_TOKEN_MAX_LIFETIME_DEFAULT),
|
|
DFS_NAMENODE_DELEGATION_TOKEN_MAX_LIFETIME_DEFAULT),
|
|
conf.getLong(DFS_NAMENODE_DELEGATION_TOKEN_RENEW_INTERVAL_KEY,
|
|
conf.getLong(DFS_NAMENODE_DELEGATION_TOKEN_RENEW_INTERVAL_KEY,
|
|
DFS_NAMENODE_DELEGATION_TOKEN_RENEW_INTERVAL_DEFAULT),
|
|
DFS_NAMENODE_DELEGATION_TOKEN_RENEW_INTERVAL_DEFAULT),
|
|
- DELEGATION_TOKEN_REMOVER_SCAN_INTERVAL, this);
|
|
|
|
|
|
+ DELEGATION_TOKEN_REMOVER_SCAN_INTERVAL,
|
|
|
|
+ conf.getBoolean(DFS_NAMENODE_AUDIT_LOG_TOKEN_TRACKING_ID_KEY,
|
|
|
|
+ DFS_NAMENODE_AUDIT_LOG_TOKEN_TRACKING_ID_DEFAULT),
|
|
|
|
+ this);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -6647,17 +6660,22 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
* defined in the config file. It can also be explicitly listed in the
|
|
* defined in the config file. It can also be explicitly listed in the
|
|
* config file.
|
|
* config file.
|
|
*/
|
|
*/
|
|
- private static class DefaultAuditLogger implements AuditLogger {
|
|
|
|
|
|
+ private static class DefaultAuditLogger extends HdfsAuditLogger {
|
|
|
|
+
|
|
|
|
+ private boolean logTokenTrackingId;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void initialize(Configuration conf) {
|
|
public void initialize(Configuration conf) {
|
|
- // Nothing to do.
|
|
|
|
|
|
+ logTokenTrackingId = conf.getBoolean(
|
|
|
|
+ DFSConfigKeys.DFS_NAMENODE_AUDIT_LOG_TOKEN_TRACKING_ID_KEY,
|
|
|
|
+ DFSConfigKeys.DFS_NAMENODE_AUDIT_LOG_TOKEN_TRACKING_ID_DEFAULT);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void logAuditEvent(boolean succeeded, String userName,
|
|
public void logAuditEvent(boolean succeeded, String userName,
|
|
InetAddress addr, String cmd, String src, String dst,
|
|
InetAddress addr, String cmd, String src, String dst,
|
|
- FileStatus status) {
|
|
|
|
|
|
+ FileStatus status, UserGroupInformation ugi,
|
|
|
|
+ DelegationTokenSecretManager dtSecretManager) {
|
|
if (auditLog.isInfoEnabled()) {
|
|
if (auditLog.isInfoEnabled()) {
|
|
final StringBuilder sb = auditBuffer.get();
|
|
final StringBuilder sb = auditBuffer.get();
|
|
sb.setLength(0);
|
|
sb.setLength(0);
|
|
@@ -6675,6 +6693,22 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
sb.append(status.getGroup()).append(":");
|
|
sb.append(status.getGroup()).append(":");
|
|
sb.append(status.getPermission());
|
|
sb.append(status.getPermission());
|
|
}
|
|
}
|
|
|
|
+ if (logTokenTrackingId) {
|
|
|
|
+ sb.append("\t").append("trackingId=");
|
|
|
|
+ String trackingId = null;
|
|
|
|
+ if (ugi != null && dtSecretManager != null
|
|
|
|
+ && ugi.getAuthenticationMethod() == AuthenticationMethod.TOKEN) {
|
|
|
|
+ for (TokenIdentifier tid: ugi.getTokenIdentifiers()) {
|
|
|
|
+ if (tid instanceof DelegationTokenIdentifier) {
|
|
|
|
+ DelegationTokenIdentifier dtid =
|
|
|
|
+ (DelegationTokenIdentifier)tid;
|
|
|
|
+ trackingId = dtSecretManager.getTokenTrackingId(dtid);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ sb.append(trackingId);
|
|
|
|
+ }
|
|
auditLog.info(sb);
|
|
auditLog.info(sb);
|
|
}
|
|
}
|
|
}
|
|
}
|