HDFS-9851. NameNode throws NPE when setPermission is called on a path that does not exist. Contributed by Brahma Reddy Battula.
This commit is contained in:
parent
e2ddf82469
commit
27e0681f28
@ -2974,6 +2974,9 @@ Release 2.7.3 - UNRELEASED
|
|||||||
HDFS-9766. TestDataNodeMetrics#testDataNodeTimeSpend fails intermittently.
|
HDFS-9766. TestDataNodeMetrics#testDataNodeTimeSpend fails intermittently.
|
||||||
(Xiao Chen via aajisaka)
|
(Xiao Chen via aajisaka)
|
||||||
|
|
||||||
|
HDFS-9851. NameNode throws NPE when setPermission is called on a path that
|
||||||
|
does not exist. (Brahma Reddy Battula via aajisaka)
|
||||||
|
|
||||||
Release 2.7.2 - 2016-01-25
|
Release 2.7.2 - 2016-01-25
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
import org.apache.hadoop.hdfs.protocolPB.PBHelperClient;
|
import org.apache.hadoop.hdfs.protocolPB.PBHelperClient;
|
||||||
import org.apache.hadoop.security.AccessControlException;
|
import org.apache.hadoop.security.AccessControlException;
|
||||||
|
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -388,7 +389,7 @@ static XAttr unprotectedGetXAttrByPrefixedName(
|
|||||||
private static void checkXAttrChangeAccess(
|
private static void checkXAttrChangeAccess(
|
||||||
FSDirectory fsd, INodesInPath iip, XAttr xAttr,
|
FSDirectory fsd, INodesInPath iip, XAttr xAttr,
|
||||||
FSPermissionChecker pc)
|
FSPermissionChecker pc)
|
||||||
throws AccessControlException {
|
throws AccessControlException, FileNotFoundException {
|
||||||
if (fsd.isPermissionEnabled() && xAttr.getNameSpace() == XAttr.NameSpace
|
if (fsd.isPermissionEnabled() && xAttr.getNameSpace() == XAttr.NameSpace
|
||||||
.USER) {
|
.USER) {
|
||||||
final INode inode = iip.getLastINode();
|
final INode inode = iip.getLastINode();
|
||||||
|
@ -1547,7 +1547,11 @@ FSPermissionChecker getPermissionChecker(String fsOwner, String superGroup,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void checkOwner(FSPermissionChecker pc, INodesInPath iip)
|
void checkOwner(FSPermissionChecker pc, INodesInPath iip)
|
||||||
throws AccessControlException {
|
throws AccessControlException, FileNotFoundException {
|
||||||
|
if (iip.getLastINode() == null) {
|
||||||
|
throw new FileNotFoundException(
|
||||||
|
"Directory/File does not exist " + iip.getPath());
|
||||||
|
}
|
||||||
checkPermission(pc, iip, true, null, null, null, null);
|
checkPermission(pc, iip, true, null, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3344,7 +3344,7 @@ public void testSnapshotReserved() throws IOException {
|
|||||||
fs.createSnapshot(reserved, "snap");
|
fs.createSnapshot(reserved, "snap");
|
||||||
fail("Can't create snapshot on /.reserved");
|
fail("Can't create snapshot on /.reserved");
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
assertTrue(e.getMessage().contains("Directory does not exist"));
|
assertTrue(e.getMessage().contains("Directory/File does not exist"));
|
||||||
}
|
}
|
||||||
cluster.shutdown();
|
cluster.shutdown();
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,7 @@ public class TestPermission {
|
|||||||
final private static Path CHILD_DIR2 = new Path(ROOT_PATH, "child2");
|
final private static Path CHILD_DIR2 = new Path(ROOT_PATH, "child2");
|
||||||
final private static Path CHILD_FILE1 = new Path(ROOT_PATH, "file1");
|
final private static Path CHILD_FILE1 = new Path(ROOT_PATH, "file1");
|
||||||
final private static Path CHILD_FILE2 = new Path(ROOT_PATH, "file2");
|
final private static Path CHILD_FILE2 = new Path(ROOT_PATH, "file2");
|
||||||
|
final private static Path CHILD_FILE3 = new Path(ROOT_PATH, "file3");
|
||||||
|
|
||||||
final private static int FILE_LEN = 100;
|
final private static int FILE_LEN = 100;
|
||||||
final private static Random RAN = new Random();
|
final private static Random RAN = new Random();
|
||||||
@ -270,6 +271,18 @@ public void testFilePermission() throws Exception {
|
|||||||
final Path RENAME_PATH = new Path("/foo/bar");
|
final Path RENAME_PATH = new Path("/foo/bar");
|
||||||
userfs.mkdirs(RENAME_PATH);
|
userfs.mkdirs(RENAME_PATH);
|
||||||
assertTrue(canRename(userfs, RENAME_PATH, CHILD_DIR1));
|
assertTrue(canRename(userfs, RENAME_PATH, CHILD_DIR1));
|
||||||
|
// test permissions on files that do not exist
|
||||||
|
assertFalse(userfs.exists(CHILD_FILE3));
|
||||||
|
try {
|
||||||
|
userfs.setOwner(CHILD_FILE3, "foo", "bar");
|
||||||
|
fail("setOwner should fail for non-exist file");
|
||||||
|
} catch (java.io.FileNotFoundException ignored) {
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
userfs.setPermission(CHILD_FILE3, new FsPermission((short) 0777));
|
||||||
|
fail("setPermission should fail for non-exist file");
|
||||||
|
} catch (java.io.FileNotFoundException ignored) {
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
cluster.shutdown();
|
cluster.shutdown();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user