|
@@ -344,25 +344,33 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
}
|
|
|
|
|
|
private void logAuditEvent(boolean succeeded, String cmd, String src,
|
|
|
- String dst, HdfsFileStatus stat) throws IOException {
|
|
|
+ String dst, FileStatus stat) throws IOException {
|
|
|
if (isAuditEnabled() && isExternalInvocation()) {
|
|
|
logAuditEvent(succeeded, Server.getRemoteUser(), Server.getRemoteIp(),
|
|
|
cmd, src, dst, stat);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void logAuditEvent(boolean succeeded,
|
|
|
- UserGroupInformation ugi, InetAddress addr, String cmd, String src,
|
|
|
- String dst, HdfsFileStatus stat) {
|
|
|
+ private void logAuditEvent(boolean succeeded, String cmd, String src,
|
|
|
+ HdfsFileStatus stat) throws IOException {
|
|
|
+ if (!isAuditEnabled() || !isExternalInvocation()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
FileStatus status = null;
|
|
|
if (stat != null) {
|
|
|
Path symlink = stat.isSymlink() ? new Path(stat.getSymlink()) : null;
|
|
|
- Path path = dst != null ? new Path(dst) : new Path(src);
|
|
|
+ Path path = new Path(src);
|
|
|
status = new FileStatus(stat.getLen(), stat.isDir(),
|
|
|
stat.getReplication(), stat.getBlockSize(), stat.getModificationTime(),
|
|
|
stat.getAccessTime(), stat.getPermission(), stat.getOwner(),
|
|
|
stat.getGroup(), symlink, path);
|
|
|
}
|
|
|
+ logAuditEvent(succeeded, cmd, src, null, status);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void logAuditEvent(boolean succeeded,
|
|
|
+ UserGroupInformation ugi, InetAddress addr, String cmd, String src,
|
|
|
+ String dst, FileStatus status) {
|
|
|
final String ugiStr = ugi.toString();
|
|
|
for (AuditLogger logger : auditLoggers) {
|
|
|
if (logger instanceof HdfsAuditLogger) {
|
|
@@ -1704,7 +1712,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
*/
|
|
|
void setPermission(String src, FsPermission permission) throws IOException {
|
|
|
final String operationName = "setPermission";
|
|
|
- HdfsFileStatus auditStat;
|
|
|
+ FileStatus auditStat;
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
writeLock();
|
|
|
try {
|
|
@@ -1728,7 +1736,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
void setOwner(String src, String username, String group)
|
|
|
throws IOException {
|
|
|
final String operationName = "setOwner";
|
|
|
- HdfsFileStatus auditStat;
|
|
|
+ FileStatus auditStat;
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
writeLock();
|
|
|
try {
|
|
@@ -1857,7 +1865,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
throws IOException {
|
|
|
waitForLoadingFSImage();
|
|
|
final String operationName = "concat";
|
|
|
- HdfsFileStatus stat = null;
|
|
|
+ FileStatus stat = null;
|
|
|
boolean success = false;
|
|
|
writeLock();
|
|
|
try {
|
|
@@ -1882,7 +1890,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
*/
|
|
|
void setTimes(String src, long mtime, long atime) throws IOException {
|
|
|
final String operationName = "setTimes";
|
|
|
- HdfsFileStatus auditStat;
|
|
|
+ FileStatus auditStat;
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
writeLock();
|
|
|
try {
|
|
@@ -1910,7 +1918,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
if (!FileSystem.areSymlinksEnabled()) {
|
|
|
throw new UnsupportedOperationException("Symlinks not supported");
|
|
|
}
|
|
|
- HdfsFileStatus auditStat = null;
|
|
|
+ FileStatus auditStat = null;
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
writeLock();
|
|
|
try {
|
|
@@ -2021,7 +2029,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
*/
|
|
|
void setStoragePolicy(String src, String policyName) throws IOException {
|
|
|
final String operationName = "setStoragePolicy";
|
|
|
- HdfsFileStatus auditStat;
|
|
|
+ FileStatus auditStat;
|
|
|
waitForLoadingFSImage();
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
writeLock();
|
|
@@ -2047,7 +2055,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
*/
|
|
|
void unsetStoragePolicy(String src) throws IOException {
|
|
|
final String operationName = "unsetStoragePolicy";
|
|
|
- HdfsFileStatus auditStat;
|
|
|
+ FileStatus auditStat;
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
writeLock();
|
|
|
try {
|
|
@@ -2169,7 +2177,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
logAuditEvent(false, "create", src);
|
|
|
throw e;
|
|
|
}
|
|
|
- logAuditEvent(true, "create", src, null, status);
|
|
|
+ logAuditEvent(true, "create", src, status);
|
|
|
return status;
|
|
|
}
|
|
|
|
|
@@ -2972,7 +2980,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
boolean mkdirs(String src, PermissionStatus permissions,
|
|
|
boolean createParent) throws IOException {
|
|
|
final String operationName = "mkdirs";
|
|
|
- HdfsFileStatus auditStat = null;
|
|
|
+ FileStatus auditStat = null;
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
writeLock();
|
|
|
try {
|
|
@@ -7195,7 +7203,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
void modifyAclEntries(final String src, List<AclEntry> aclSpec)
|
|
|
throws IOException {
|
|
|
final String operationName = "modifyAclEntries";
|
|
|
- HdfsFileStatus auditStat = null;
|
|
|
+ FileStatus auditStat = null;
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
writeLock();
|
|
|
try {
|
|
@@ -7216,7 +7224,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
throws IOException {
|
|
|
final String operationName = "removeAclEntries";
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
- HdfsFileStatus auditStat = null;
|
|
|
+ FileStatus auditStat = null;
|
|
|
writeLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
@@ -7234,7 +7242,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
|
|
|
void removeDefaultAcl(final String src) throws IOException {
|
|
|
final String operationName = "removeDefaultAcl";
|
|
|
- HdfsFileStatus auditStat = null;
|
|
|
+ FileStatus auditStat = null;
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
writeLock();
|
|
|
try {
|
|
@@ -7253,7 +7261,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
|
|
|
void removeAcl(final String src) throws IOException {
|
|
|
final String operationName = "removeAcl";
|
|
|
- HdfsFileStatus auditStat = null;
|
|
|
+ FileStatus auditStat = null;
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
writeLock();
|
|
|
try {
|
|
@@ -7272,7 +7280,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
|
|
|
void setAcl(final String src, List<AclEntry> aclSpec) throws IOException {
|
|
|
final String operationName = "setAcl";
|
|
|
- HdfsFileStatus auditStat = null;
|
|
|
+ FileStatus auditStat = null;
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
writeLock();
|
|
|
try {
|
|
@@ -7326,7 +7334,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
checkSuperuserPrivilege();
|
|
|
FSPermissionChecker pc = getPermissionChecker();
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
- final HdfsFileStatus resultingStat;
|
|
|
+ final FileStatus resultingStat;
|
|
|
writeLock();
|
|
|
try {
|
|
|
checkSuperuserPrivilege();
|
|
@@ -7357,14 +7365,14 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
EncryptionZone getEZForPath(final String srcArg)
|
|
|
throws AccessControlException, UnresolvedLinkException, IOException {
|
|
|
final String operationName = "getEZForPath";
|
|
|
- HdfsFileStatus resultingStat = null;
|
|
|
+ FileStatus resultingStat = null;
|
|
|
boolean success = false;
|
|
|
final FSPermissionChecker pc = getPermissionChecker();
|
|
|
checkOperation(OperationCategory.READ);
|
|
|
readLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.READ);
|
|
|
- Entry<EncryptionZone, HdfsFileStatus> ezForPath = FSDirEncryptionZoneOp
|
|
|
+ Entry<EncryptionZone, FileStatus> ezForPath = FSDirEncryptionZoneOp
|
|
|
.getEZForPath(dir, srcArg, pc);
|
|
|
success = true;
|
|
|
resultingStat = ezForPath.getValue();
|
|
@@ -7399,7 +7407,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
boolean logRetryCache)
|
|
|
throws IOException {
|
|
|
final String operationName = "setXAttr";
|
|
|
- HdfsFileStatus auditStat = null;
|
|
|
+ FileStatus auditStat = null;
|
|
|
writeLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
@@ -7449,7 +7457,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
void removeXAttr(String src, XAttr xAttr, boolean logRetryCache)
|
|
|
throws IOException {
|
|
|
final String operationName = "removeXAttr";
|
|
|
- HdfsFileStatus auditStat = null;
|
|
|
+ FileStatus auditStat = null;
|
|
|
writeLock();
|
|
|
try {
|
|
|
checkOperation(OperationCategory.WRITE);
|