Author: cnauroth Date: Sat Mar 22 05:21:33 2014 New Revision: 1580172 URL: http://svn.apache.org/r1580172 Log: HADOOP-10191. Merging change r1580171 from branch-2 to branch-2.4
Modified: hadoop/common/branches/branch-2.4/hadoop-common-project/hadoop-common/CHANGES.txt hadoop/common/branches/branch-2.4/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/Constants.java hadoop/common/branches/branch-2.4/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java hadoop/common/branches/branch-2.4/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFs.java hadoop/common/branches/branch-2.4/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java Modified: hadoop/common/branches/branch-2.4/hadoop-common-project/hadoop-common/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.4/hadoop-common-project/hadoop-common/CHANGES.txt?rev=1580172&r1=1580171&r2=1580172&view=diff ============================================================================== --- hadoop/common/branches/branch-2.4/hadoop-common-project/hadoop-common/CHANGES.txt (original) +++ hadoop/common/branches/branch-2.4/hadoop-common-project/hadoop-common/CHANGES.txt Sat Mar 22 05:21:33 2014 @@ -109,6 +109,9 @@ Release 2.4.0 - UNRELEASED HADOOP-10070. RPC client doesn't use per-connection conf to determine server's expected Kerberos principal name. (atm) + 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) Modified: hadoop/common/branches/branch-2.4/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/Constants.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.4/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/Constants.java?rev=1580172&r1=1580171&r2=1580172&view=diff ============================================================================== --- hadoop/common/branches/branch-2.4/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/Constants.java (original) +++ hadoop/common/branches/branch-2.4/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/Constants.java Sat Mar 22 05:21:33 2014 @@ -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); } Modified: hadoop/common/branches/branch-2.4/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.4/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java?rev=1580172&r1=1580171&r2=1580172&view=diff ============================================================================== --- hadoop/common/branches/branch-2.4/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java (original) +++ hadoop/common/branches/branch-2.4/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java Sat Mar 22 05:21:33 2014 @@ -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 File 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 File 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)); Modified: hadoop/common/branches/branch-2.4/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFs.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.4/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFs.java?rev=1580172&r1=1580171&r2=1580172&view=diff ============================================================================== --- hadoop/common/branches/branch-2.4/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFs.java (original) +++ hadoop/common/branches/branch-2.4/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFs.java Sat Mar 22 05:21:33 2014 @@ -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; @@ -676,8 +676,8 @@ public class ViewFs extends AbstractFile @Override 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], + return new FileStatus(0, true, 0, 0, creationTime, creationTime, + PERMISSION_555, ugi.getUserName(), ugi.getGroupNames()[0], new Path(theInternalDir.fullPath).makeQualified( myUri, null)); } @@ -697,13 +697,13 @@ public class ViewFs extends AbstractFile 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 AbstractFile 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)); } Modified: hadoop/common/branches/branch-2.4/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.4/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java?rev=1580172&r1=1580171&r2=1580172&view=diff ============================================================================== --- hadoop/common/branches/branch-2.4/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java (original) +++ hadoop/common/branches/branch-2.4/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java Sat Mar 22 05:21:33 2014 @@ -31,6 +31,8 @@ import static org.apache.hadoop.fs.FileS 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,38 +403,41 @@ public class ViewFileSystemBaseTest { FileStatus[] dirPaths = fsView.listStatus(new Path("/")); FileStatus fs; - Assert.assertEquals(getExpectedDirPaths(), dirPaths.length); - fs = fileSystemTestHelper.containsPath(fsView, "/user", 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.isSymlink()); - fs = fileSystemTestHelper.containsPath(fsView, "/data", dirPaths); + 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()); + 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() { return 7; } @@ -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)); + } }