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:
parent
ef9634bf79
commit
62d28901d6
|
@ -430,6 +430,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)
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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 class ViewFileSystem extends FileSystem {
|
|||
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 class ViewFileSystem extends FileSystem {
|
|||
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));
|
||||
|
|
|
@ -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 class ViewFs extends AbstractFileSystem {
|
|||
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 class ViewFs extends AbstractFileSystem {
|
|||
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 class ViewFs extends AbstractFileSystem {
|
|||
|
||||
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));
|
||||
}
|
||||
|
|
|
@ -31,6 +31,8 @@ import static org.apache.hadoop.fs.FileSystemTestHelper.*;
|
|||
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;
|
||||
|
@ -401,36 +403,39 @@ public class ViewFileSystemBaseTest {
|
|||
|
||||
FileStatus[] dirPaths = fsView.listStatus(new Path("/"));
|
||||
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);
|
||||
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);
|
||||
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());
|
||||
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());
|
||||
|
||||
|
||||
|
||||
// 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());
|
||||
Assert.assertNotNull(fs);
|
||||
Assert.assertTrue("A mount should appear as symlink", fs.isSymlink());
|
||||
}
|
||||
|
||||
int getExpectedDirPaths() {
|
||||
|
@ -681,4 +686,38 @@ public class ViewFileSystemBaseTest {
|
|||
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));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue