HDFS-15667. Audit log record the unexpected allowed result when delete (#2437)
(cherry picked from commit 95c96605b3
)
This commit is contained in:
parent
90bbaca88b
commit
2b207ea402
@ -3256,7 +3256,7 @@ boolean delete(String src, boolean recursive, boolean logRetryCache)
|
|||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
getEditLog().logSync();
|
getEditLog().logSync();
|
||||||
logAuditEvent(true, operationName, src);
|
logAuditEvent(ret, operationName, src);
|
||||||
if (toRemovedBlocks != null) {
|
if (toRemovedBlocks != null) {
|
||||||
removeBlocks(toRemovedBlocks); // Incremental deletion of blocks
|
removeBlocks(toRemovedBlocks); // Incremental deletion of blocks
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,7 @@
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_DELEGATION_TOKEN_ALWAYS_USE_KEY;
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_DELEGATION_TOKEN_ALWAYS_USE_KEY;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
@ -1205,6 +1206,18 @@ public void testGetDatanodeStorageReport() throws Exception {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDeleteRoot() throws Exception {
|
||||||
|
Path srcDir = new Path("/");
|
||||||
|
fileSys = DFSTestUtil.getFileSystemAs(user1, conf);
|
||||||
|
boolean result = fileSys.delete(srcDir, true);
|
||||||
|
fileSys.close();
|
||||||
|
assertFalse(result);
|
||||||
|
String aceDeletePattern =
|
||||||
|
".*allowed=false.*ugi=theDoctor.*cmd=delete.*";
|
||||||
|
verifyAuditLogs(aceDeletePattern);
|
||||||
|
}
|
||||||
|
|
||||||
private void verifyAuditRestoreFailedStorageACE(
|
private void verifyAuditRestoreFailedStorageACE(
|
||||||
FSNamesystem fsNamesystem, String arg) throws IOException {
|
FSNamesystem fsNamesystem, String arg) throws IOException {
|
||||||
String operationName = fsNamesystem.getFailedStorageCommand(arg);
|
String operationName = fsNamesystem.getFailedStorageCommand(arg);
|
||||||
|
Loading…
Reference in New Issue
Block a user