|
@@ -337,25 +337,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) {
|
|
@@ -1710,7 +1718,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 {
|
|
@@ -1734,7 +1742,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 {
|
|
@@ -1862,7 +1870,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
void concat(String target, String [] srcs, boolean logRetryCache)
|
|
|
throws IOException {
|
|
|
final String operationName = "concat";
|
|
|
- HdfsFileStatus stat = null;
|
|
|
+ FileStatus stat = null;
|
|
|
boolean success = false;
|
|
|
writeLock();
|
|
|
try {
|
|
@@ -1887,7 +1895,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 {
|
|
@@ -1915,7 +1923,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 {
|
|
@@ -2025,7 +2033,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
*/
|
|
|
void setStoragePolicy(String src, String policyName) throws IOException {
|
|
|
final String operationName = "setStoragePolicy";
|
|
|
- HdfsFileStatus auditStat;
|
|
|
+ FileStatus auditStat;
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
writeLock();
|
|
|
try {
|
|
@@ -2050,7 +2058,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 {
|
|
@@ -2170,7 +2178,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;
|
|
|
}
|
|
|
|
|
@@ -2917,7 +2925,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 {
|
|
@@ -6512,7 +6520,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 {
|
|
@@ -6533,7 +6541,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);
|
|
@@ -6551,7 +6559,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 {
|
|
@@ -6570,7 +6578,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 {
|
|
@@ -6589,7 +6597,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 {
|
|
@@ -6643,7 +6651,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
checkSuperuserPrivilege();
|
|
|
FSPermissionChecker pc = getPermissionChecker();
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
- final HdfsFileStatus resultingStat;
|
|
|
+ final FileStatus resultingStat;
|
|
|
writeLock();
|
|
|
try {
|
|
|
checkSuperuserPrivilege();
|
|
@@ -6674,14 +6682,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();
|
|
@@ -6716,7 +6724,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);
|
|
@@ -6766,7 +6774,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);
|