HDFS-6785. Should not be able to create encryption zone using path to a non-directory file. (clamb)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/fs-encryption@1614755 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7405953692
commit
ab47b666d0
|
@ -78,3 +78,6 @@ fs-encryption (Unreleased)
|
||||||
|
|
||||||
HDFS-6733. Creating encryption zone results in NPE when
|
HDFS-6733. Creating encryption zone results in NPE when
|
||||||
KeyProvider is null. (clamb)
|
KeyProvider is null. (clamb)
|
||||||
|
|
||||||
|
HDFS-6785. Should not be able to create encryption zone using path
|
||||||
|
to a non-directory file. (clamb)
|
||||||
|
|
|
@ -213,6 +213,11 @@ public class EncryptionZoneManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
final INodesInPath srcIIP = dir.getINodesInPath4Write(src, false);
|
final INodesInPath srcIIP = dir.getINodesInPath4Write(src, false);
|
||||||
|
if (srcIIP != null &&
|
||||||
|
srcIIP.getLastINode() != null &&
|
||||||
|
!srcIIP.getLastINode().isDirectory()) {
|
||||||
|
throw new IOException("Attempt to create an encryption zone for a file.");
|
||||||
|
}
|
||||||
EncryptionZoneInt ezi = getEncryptionZoneForPath(srcIIP);
|
EncryptionZoneInt ezi = getEncryptionZoneForPath(srcIIP);
|
||||||
if (ezi != null) {
|
if (ezi != null) {
|
||||||
throw new IOException("Directory " + src + " is already in an " +
|
throw new IOException("Directory " + src + " is already in an " +
|
||||||
|
|
|
@ -227,6 +227,14 @@ public class TestEncryptionZones {
|
||||||
assertExceptionContains("create an encryption zone", e);
|
assertExceptionContains("create an encryption zone", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Test failure of create EZ on a file. */
|
||||||
|
try {
|
||||||
|
dfsAdmin.createEncryptionZone(notEmptyChild, TEST_KEY);
|
||||||
|
fail("Created EZ on a file");
|
||||||
|
} catch (IOException e) {
|
||||||
|
assertExceptionContains("create an encryption zone for a file.", e);
|
||||||
|
}
|
||||||
|
|
||||||
/* Test failure of creating an EZ passing a key that doesn't exist. */
|
/* Test failure of creating an EZ passing a key that doesn't exist. */
|
||||||
final Path zone2 = new Path("/zone2");
|
final Path zone2 = new Path("/zone2");
|
||||||
fsWrapper.mkdir(zone2, FsPermission.getDirDefault(), false);
|
fsWrapper.mkdir(zone2, FsPermission.getDirDefault(), false);
|
||||||
|
|
Loading…
Reference in New Issue