HADOOP-10191. Missing executable permission on viewfs internal dirs. Contributed by Gera Shegalov.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1580170 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Chris Nauroth 2014-03-22 05:04:39 +00:00
parent ef9634bf79
commit 62d28901d6
5 changed files with 82 additions and 40 deletions

View File

@ -430,6 +430,9 @@ Release 2.4.0 - UNRELEASED
HADOOP-10407. Fix the javac warnings in org.apache.hadoop.ipc package. HADOOP-10407. Fix the javac warnings in org.apache.hadoop.ipc package.
(szetszwo) (szetszwo)
HADOOP-10191. Missing executable permission on viewfs internal dirs.
(Gera Shegalov via cnauroth)
BREAKDOWN OF HADOOP-10184 SUBTASKS AND RELATED JIRAS BREAKDOWN OF HADOOP-10184 SUBTASKS AND RELATED JIRAS
HADOOP-10185. FileSystem API for ACLs. (cnauroth) 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"; public static final String CONFIG_VIEWFS_LINK_MERGE_SLASH = "linkMergeSlash";
static public final FsPermission PERMISSION_RRR = static public final FsPermission PERMISSION_555 =
new FsPermission((short) 0444); new FsPermission((short) 0555);
} }

View File

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

View File

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

View File

@ -31,6 +31,8 @@
import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FsConstants; import org.apache.hadoop.fs.FsConstants;
import org.apache.hadoop.fs.Path; 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.ConfigUtil;
import org.apache.hadoop.fs.viewfs.ViewFileSystem; import org.apache.hadoop.fs.viewfs.ViewFileSystem;
import org.apache.hadoop.fs.viewfs.ViewFileSystem.MountPoint; import org.apache.hadoop.fs.viewfs.ViewFileSystem.MountPoint;
@ -401,38 +403,41 @@ public void testListOnInternalDirsOfMountTable() throws IOException {
FileStatus[] dirPaths = fsView.listStatus(new Path("/")); FileStatus[] dirPaths = fsView.listStatus(new Path("/"));
FileStatus fs; FileStatus fs;
Assert.assertEquals(getExpectedDirPaths(), dirPaths.length); verifyRootChildren(dirPaths);
fs = fileSystemTestHelper.containsPath(fsView, "/user", dirPaths);
Assert.assertNotNull(fs); // list on internal dir
Assert.assertTrue("A mount should appear as symlink", fs.isSymlink()); dirPaths = fsView.listStatus(new Path("/internalDir"));
fs = fileSystemTestHelper.containsPath(fsView, "/data", dirPaths); Assert.assertEquals(2, dirPaths.length);
Assert.assertNotNull(fs);
Assert.assertTrue("A mount should appear as symlink", fs.isSymlink()); fs = fileSystemTestHelper.containsPath(fsView, "/internalDir/internalDir2", dirPaths);
fs = fileSystemTestHelper.containsPath(fsView, "/internalDir", dirPaths);
Assert.assertNotNull(fs); Assert.assertNotNull(fs);
Assert.assertTrue("A mount should appear as symlink", fs.isDirectory()); Assert.assertTrue("A mount should appear as symlink", fs.isDirectory());
fs = fileSystemTestHelper.containsPath(fsView, "/danglingLink", dirPaths); fs = fileSystemTestHelper.containsPath(fsView, "/internalDir/linkToDir2",
dirPaths);
Assert.assertNotNull(fs); Assert.assertNotNull(fs);
Assert.assertTrue("A mount should appear as symlink", fs.isSymlink()); Assert.assertTrue("A mount should appear as symlink", fs.isSymlink());
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());
} }
private void verifyRootChildren(FileStatus[] dirPaths) throws IOException {
FileStatus fs;
Assert.assertEquals(getExpectedDirPaths(), dirPaths.length);
fs = fileSystemTestHelper.containsPath(fsView, "/user", dirPaths);
Assert.assertNotNull(fs);
Assert.assertTrue("A mount should appear as symlink", fs.isSymlink());
fs = fileSystemTestHelper.containsPath(fsView, "/data", dirPaths);
Assert.assertNotNull(fs);
Assert.assertTrue("A mount should appear as symlink", fs.isSymlink());
fs = fileSystemTestHelper.containsPath(fsView, "/internalDir", dirPaths);
Assert.assertNotNull(fs);
Assert.assertTrue("A mount should appear as symlink", fs.isDirectory());
fs = fileSystemTestHelper.containsPath(fsView, "/danglingLink", dirPaths);
Assert.assertNotNull(fs);
Assert.assertTrue("A mount should appear as symlink", fs.isSymlink());
fs = fileSystemTestHelper.containsPath(fsView, "/linkToAFile", dirPaths);
Assert.assertNotNull(fs);
Assert.assertTrue("A mount should appear as symlink", fs.isSymlink());
}
int getExpectedDirPaths() { int getExpectedDirPaths() {
return 7; return 7;
} }
@ -681,4 +686,38 @@ public void testCreateNonRecursive() throws IOException {
Assert.assertTrue("Target of created file should be type file", Assert.assertTrue("Target of created file should be type file",
fsTarget.isFile(new Path(targetTestRoot,"user/foo"))); 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));
}
} }