HADOOP-10191. Merging change r1580170 from trunk to branch-2.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1580171 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Chris Nauroth 2014-03-22 05:12:33 +00:00
parent ebd254117d
commit 3f32bb0e7f
5 changed files with 82 additions and 40 deletions

View File

@ -127,6 +127,9 @@ Release 2.4.0 - UNRELEASED
HADOOP-10407. Fix the javac warnings in org.apache.hadoop.ipc package.
(szetszwo)
HADOOP-10191. Missing executable permission on viewfs internal dirs.
(Gera Shegalov via cnauroth)
BREAKDOWN OF HADOOP-10184 SUBTASKS AND RELATED JIRAS
HADOOP-10185. FileSystem API for ACLs. (cnauroth)

View File

@ -64,6 +64,6 @@ public interface Constants {
*/
public static final String CONFIG_VIEWFS_LINK_MERGE_SLASH = "linkMergeSlash";
static public final FsPermission PERMISSION_RRR =
new FsPermission((short) 0444);
static public final FsPermission PERMISSION_555 =
new FsPermission((short) 0555);
}

View File

@ -17,7 +17,7 @@
*/
package org.apache.hadoop.fs.viewfs;
import static org.apache.hadoop.fs.viewfs.Constants.PERMISSION_RRR;
import static org.apache.hadoop.fs.viewfs.Constants.PERMISSION_555;
import java.io.FileNotFoundException;
import java.io.IOException;
@ -714,7 +714,7 @@ public FileChecksum getFileChecksum(final Path f)
public FileStatus getFileStatus(Path f) throws IOException {
checkPathIsSlash(f);
return new FileStatus(0, true, 0, 0, creationTime, creationTime,
PERMISSION_RRR, ugi.getUserName(), ugi.getGroupNames()[0],
PERMISSION_555, ugi.getUserName(), ugi.getGroupNames()[0],
new Path(theInternalDir.fullPath).makeQualified(
myUri, ROOT_PATH));
@ -734,14 +734,14 @@ public FileStatus[] listStatus(Path f) throws AccessControlException,
INodeLink<FileSystem> link = (INodeLink<FileSystem>) inode;
result[i++] = new FileStatus(0, false, 0, 0,
creationTime, creationTime, PERMISSION_RRR,
creationTime, creationTime, PERMISSION_555,
ugi.getUserName(), ugi.getGroupNames()[0],
link.getTargetLink(),
new Path(inode.fullPath).makeQualified(
myUri, null));
} else {
result[i++] = new FileStatus(0, true, 0, 0,
creationTime, creationTime, PERMISSION_RRR,
creationTime, creationTime, PERMISSION_555,
ugi.getUserName(), ugi.getGroupNames()[0],
new Path(inode.fullPath).makeQualified(
myUri, null));

View File

@ -17,7 +17,7 @@
*/
package org.apache.hadoop.fs.viewfs;
import static org.apache.hadoop.fs.viewfs.Constants.PERMISSION_RRR;
import static org.apache.hadoop.fs.viewfs.Constants.PERMISSION_555;
import java.io.FileNotFoundException;
import java.io.IOException;
@ -677,7 +677,7 @@ public FileChecksum getFileChecksum(final Path f)
public FileStatus getFileStatus(final Path f) throws IOException {
checkPathIsSlash(f);
return new FileStatus(0, true, 0, 0, creationTime, creationTime,
PERMISSION_RRR, ugi.getUserName(), ugi.getGroupNames()[0],
PERMISSION_555, ugi.getUserName(), ugi.getGroupNames()[0],
new Path(theInternalDir.fullPath).makeQualified(
myUri, null));
}
@ -697,13 +697,13 @@ public FileStatus getFileLinkStatus(final Path f)
INodeLink<AbstractFileSystem> inodelink =
(INodeLink<AbstractFileSystem>) inode;
result = new FileStatus(0, false, 0, 0, creationTime, creationTime,
PERMISSION_RRR, ugi.getUserName(), ugi.getGroupNames()[0],
PERMISSION_555, ugi.getUserName(), ugi.getGroupNames()[0],
inodelink.getTargetLink(),
new Path(inode.fullPath).makeQualified(
myUri, null));
} else {
result = new FileStatus(0, true, 0, 0, creationTime, creationTime,
PERMISSION_RRR, ugi.getUserName(), ugi.getGroupNames()[0],
PERMISSION_555, ugi.getUserName(), ugi.getGroupNames()[0],
new Path(inode.fullPath).makeQualified(
myUri, null));
}
@ -742,14 +742,14 @@ public FileStatus[] listStatus(final Path f) throws AccessControlException,
result[i++] = new FileStatus(0, false, 0, 0,
creationTime, creationTime,
PERMISSION_RRR, ugi.getUserName(), ugi.getGroupNames()[0],
PERMISSION_555, ugi.getUserName(), ugi.getGroupNames()[0],
link.getTargetLink(),
new Path(inode.fullPath).makeQualified(
myUri, null));
} else {
result[i++] = new FileStatus(0, true, 0, 0,
creationTime, creationTime,
PERMISSION_RRR, ugi.getUserName(), ugi.getGroupNames()[0],
PERMISSION_555, ugi.getUserName(), ugi.getGroupNames()[0],
new Path(inode.fullPath).makeQualified(
myUri, null));
}

View File

@ -31,6 +31,8 @@
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FsConstants;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.permission.FsAction;
import org.apache.hadoop.fs.permission.FsPermission;
import org.apache.hadoop.fs.viewfs.ConfigUtil;
import org.apache.hadoop.fs.viewfs.ViewFileSystem;
import org.apache.hadoop.fs.viewfs.ViewFileSystem.MountPoint;
@ -400,6 +402,23 @@ public void testListOnInternalDirsOfMountTable() throws IOException {
// list on Slash
FileStatus[] dirPaths = fsView.listStatus(new Path("/"));
FileStatus fs;
verifyRootChildren(dirPaths);
// list on internal dir
dirPaths = fsView.listStatus(new Path("/internalDir"));
Assert.assertEquals(2, dirPaths.length);
fs = fileSystemTestHelper.containsPath(fsView, "/internalDir/internalDir2", dirPaths);
Assert.assertNotNull(fs);
Assert.assertTrue("A mount should appear as symlink", fs.isDirectory());
fs = fileSystemTestHelper.containsPath(fsView, "/internalDir/linkToDir2",
dirPaths);
Assert.assertNotNull(fs);
Assert.assertTrue("A mount should appear as symlink", fs.isSymlink());
}
private void verifyRootChildren(FileStatus[] dirPaths) throws IOException {
FileStatus fs;
Assert.assertEquals(getExpectedDirPaths(), dirPaths.length);
fs = fileSystemTestHelper.containsPath(fsView, "/user", dirPaths);
@ -417,20 +436,6 @@ public void testListOnInternalDirsOfMountTable() throws IOException {
fs = fileSystemTestHelper.containsPath(fsView, "/linkToAFile", dirPaths);
Assert.assertNotNull(fs);
Assert.assertTrue("A mount should appear as symlink", fs.isSymlink());
// list on internal dir
dirPaths = fsView.listStatus(new Path("/internalDir"));
Assert.assertEquals(2, dirPaths.length);
fs = fileSystemTestHelper.containsPath(fsView, "/internalDir/internalDir2", dirPaths);
Assert.assertNotNull(fs);
Assert.assertTrue("A mount should appear as symlink", fs.isDirectory());
fs = fileSystemTestHelper.containsPath(fsView, "/internalDir/linkToDir2",
dirPaths);
Assert.assertNotNull(fs);
Assert.assertTrue("A mount should appear as symlink", fs.isSymlink());
}
int getExpectedDirPaths() {
@ -681,4 +686,38 @@ public void testCreateNonRecursive() throws IOException {
Assert.assertTrue("Target of created file should be type file",
fsTarget.isFile(new Path(targetTestRoot,"user/foo")));
}
@Test
public void testRootReadableExecutable() throws IOException {
// verify executable permission on root: cd /
//
Assert.assertFalse("In root before cd",
fsView.getWorkingDirectory().isRoot());
fsView.setWorkingDirectory(new Path("/"));
Assert.assertTrue("Not in root dir after cd",
fsView.getWorkingDirectory().isRoot());
// verify readable
//
verifyRootChildren(fsView.listStatus(fsView.getWorkingDirectory()));
// verify permissions
//
final FileStatus rootStatus =
fsView.getFileStatus(fsView.getWorkingDirectory());
final FsPermission perms = rootStatus.getPermission();
Assert.assertTrue("User-executable permission not set!",
perms.getUserAction().implies(FsAction.EXECUTE));
Assert.assertTrue("User-readable permission not set!",
perms.getUserAction().implies(FsAction.READ));
Assert.assertTrue("Group-executable permission not set!",
perms.getGroupAction().implies(FsAction.EXECUTE));
Assert.assertTrue("Group-readable permission not set!",
perms.getGroupAction().implies(FsAction.READ));
Assert.assertTrue("Other-executable permission not set!",
perms.getOtherAction().implies(FsAction.EXECUTE));
Assert.assertTrue("Other-readable permission not set!",
perms.getOtherAction().implies(FsAction.READ));
}
}