You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by cn...@apache.org on 2014/07/16 07:16:43 UTC
svn commit: r1610911 - in
/hadoop/common/trunk/hadoop-common-project/hadoop-common: ./
src/main/java/org/apache/hadoop/fs/viewfs/
src/test/java/org/apache/hadoop/fs/viewfs/
Author: cnauroth
Date: Wed Jul 16 05:16:42 2014
New Revision: 1610911
URL: http://svn.apache.org/r1610911
Log:
HADOOP-10845. Add common tests for ACLs in combination with viewfs. Contributed by Stephen Chu.
Modified:
hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ChRootedFs.java
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFs.java
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java
Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt?rev=1610911&r1=1610910&r2=1610911&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt Wed Jul 16 05:16:42 2014
@@ -404,6 +404,9 @@ Release 2.6.0 - UNRELEASED
HADOOP-10673. Update rpc metrics when the call throws an exception. (Ming Ma
via jing9)
+ HADOOP-10845. Add common tests for ACLs in combination with viewfs.
+ (Stephen Chu via cnauroth)
+
OPTIMIZATIONS
BUG FIXES
Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ChRootedFs.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ChRootedFs.java?rev=1610911&r1=1610910&r2=1610911&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ChRootedFs.java (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ChRootedFs.java Wed Jul 16 05:16:42 2014
@@ -37,6 +37,8 @@ import org.apache.hadoop.fs.FsStatus;
import org.apache.hadoop.fs.Options.ChecksumOpt;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.UnresolvedLinkException;
+import org.apache.hadoop.fs.permission.AclEntry;
+import org.apache.hadoop.fs.permission.AclStatus;
import org.apache.hadoop.fs.permission.FsPermission;
import org.apache.hadoop.security.token.Token;
import org.apache.hadoop.util.Progressable;
@@ -280,6 +282,38 @@ class ChRootedFs extends AbstractFileSys
}
@Override
+ public void modifyAclEntries(Path path, List<AclEntry> aclSpec)
+ throws IOException {
+ myFs.modifyAclEntries(fullPath(path), aclSpec);
+ }
+
+ @Override
+ public void removeAclEntries(Path path, List<AclEntry> aclSpec)
+ throws IOException {
+ myFs.removeAclEntries(fullPath(path), aclSpec);
+ }
+
+ @Override
+ public void removeDefaultAcl(Path path) throws IOException {
+ myFs.removeDefaultAcl(fullPath(path));
+ }
+
+ @Override
+ public void removeAcl(Path path) throws IOException {
+ myFs.removeAcl(fullPath(path));
+ }
+
+ @Override
+ public void setAcl(Path path, List<AclEntry> aclSpec) throws IOException {
+ myFs.setAcl(fullPath(path), aclSpec);
+ }
+
+ @Override
+ public AclStatus getAclStatus(Path path) throws IOException {
+ return myFs.getAclStatus(fullPath(path));
+ }
+
+ @Override
public void setVerifyChecksum(final boolean verifyChecksum)
throws IOException, UnresolvedLinkException {
myFs.setVerifyChecksum(verifyChecksum);
Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java?rev=1610911&r1=1610910&r2=1610911&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java Wed Jul 16 05:16:42 2014
@@ -50,6 +50,7 @@ import org.apache.hadoop.fs.UnsupportedF
import org.apache.hadoop.fs.XAttrSetFlag;
import org.apache.hadoop.fs.permission.AclEntry;
import org.apache.hadoop.fs.permission.AclStatus;
+import org.apache.hadoop.fs.permission.AclUtil;
import org.apache.hadoop.fs.permission.FsPermission;
import org.apache.hadoop.fs.viewfs.InodeTree.INode;
import org.apache.hadoop.fs.viewfs.InodeTree.INodeLink;
@@ -871,5 +872,46 @@ public class ViewFileSystem extends File
public short getDefaultReplication(Path f) {
throw new NotInMountpointException(f, "getDefaultReplication");
}
+
+ @Override
+ public void modifyAclEntries(Path path, List<AclEntry> aclSpec)
+ throws IOException {
+ checkPathIsSlash(path);
+ throw readOnlyMountTable("modifyAclEntries", path);
+ }
+
+ @Override
+ public void removeAclEntries(Path path, List<AclEntry> aclSpec)
+ throws IOException {
+ checkPathIsSlash(path);
+ throw readOnlyMountTable("removeAclEntries", path);
+ }
+
+ @Override
+ public void removeDefaultAcl(Path path) throws IOException {
+ checkPathIsSlash(path);
+ throw readOnlyMountTable("removeDefaultAcl", path);
+ }
+
+ @Override
+ public void removeAcl(Path path) throws IOException {
+ checkPathIsSlash(path);
+ throw readOnlyMountTable("removeAcl", path);
+ }
+
+ @Override
+ public void setAcl(Path path, List<AclEntry> aclSpec) throws IOException {
+ checkPathIsSlash(path);
+ throw readOnlyMountTable("setAcl", path);
+ }
+
+ @Override
+ public AclStatus getAclStatus(Path path) throws IOException {
+ checkPathIsSlash(path);
+ return new AclStatus.Builder().owner(ugi.getUserName())
+ .group(ugi.getGroupNames()[0])
+ .addEntries(AclUtil.getMinimalAcl(PERMISSION_555))
+ .stickyBit(false).build();
+ }
}
}
Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFs.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFs.java?rev=1610911&r1=1610910&r2=1610911&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFs.java (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFs.java Wed Jul 16 05:16:42 2014
@@ -49,6 +49,9 @@ import org.apache.hadoop.fs.RemoteIterat
import org.apache.hadoop.fs.UnresolvedLinkException;
import org.apache.hadoop.fs.UnsupportedFileSystemException;
import org.apache.hadoop.fs.local.LocalConfigKeys;
+import org.apache.hadoop.fs.permission.AclEntry;
+import org.apache.hadoop.fs.permission.AclUtil;
+import org.apache.hadoop.fs.permission.AclStatus;
import org.apache.hadoop.fs.permission.FsPermission;
import org.apache.hadoop.fs.viewfs.InodeTree.INode;
import org.apache.hadoop.fs.viewfs.InodeTree.INodeLink;
@@ -603,6 +606,51 @@ public class ViewFs extends AbstractFile
return true;
}
+ @Override
+ public void modifyAclEntries(Path path, List<AclEntry> aclSpec)
+ throws IOException {
+ InodeTree.ResolveResult<AbstractFileSystem> res =
+ fsState.resolve(getUriPath(path), true);
+ res.targetFileSystem.modifyAclEntries(res.remainingPath, aclSpec);
+ }
+
+ @Override
+ public void removeAclEntries(Path path, List<AclEntry> aclSpec)
+ throws IOException {
+ InodeTree.ResolveResult<AbstractFileSystem> res =
+ fsState.resolve(getUriPath(path), true);
+ res.targetFileSystem.removeAclEntries(res.remainingPath, aclSpec);
+ }
+
+ @Override
+ public void removeDefaultAcl(Path path)
+ throws IOException {
+ InodeTree.ResolveResult<AbstractFileSystem> res =
+ fsState.resolve(getUriPath(path), true);
+ res.targetFileSystem.removeDefaultAcl(res.remainingPath);
+ }
+
+ @Override
+ public void removeAcl(Path path)
+ throws IOException {
+ InodeTree.ResolveResult<AbstractFileSystem> res =
+ fsState.resolve(getUriPath(path), true);
+ res.targetFileSystem.removeAcl(res.remainingPath);
+ }
+
+ @Override
+ public void setAcl(Path path, List<AclEntry> aclSpec) throws IOException {
+ InodeTree.ResolveResult<AbstractFileSystem> res =
+ fsState.resolve(getUriPath(path), true);
+ res.targetFileSystem.setAcl(res.remainingPath, aclSpec);
+ }
+
+ @Override
+ public AclStatus getAclStatus(Path path) throws IOException {
+ InodeTree.ResolveResult<AbstractFileSystem> res =
+ fsState.resolve(getUriPath(path), true);
+ return res.targetFileSystem.getAclStatus(res.remainingPath);
+ }
/*
@@ -832,5 +880,46 @@ public class ViewFs extends AbstractFile
throws AccessControlException {
throw readOnlyMountTable("setVerifyChecksum", "");
}
+
+ @Override
+ public void modifyAclEntries(Path path, List<AclEntry> aclSpec)
+ throws IOException {
+ checkPathIsSlash(path);
+ throw readOnlyMountTable("modifyAclEntries", path);
+ }
+
+ @Override
+ public void removeAclEntries(Path path, List<AclEntry> aclSpec)
+ throws IOException {
+ checkPathIsSlash(path);
+ throw readOnlyMountTable("removeAclEntries", path);
+ }
+
+ @Override
+ public void removeDefaultAcl(Path path) throws IOException {
+ checkPathIsSlash(path);
+ throw readOnlyMountTable("removeDefaultAcl", path);
+ }
+
+ @Override
+ public void removeAcl(Path path) throws IOException {
+ checkPathIsSlash(path);
+ throw readOnlyMountTable("removeAcl", path);
+ }
+
+ @Override
+ public void setAcl(Path path, List<AclEntry> aclSpec) throws IOException {
+ checkPathIsSlash(path);
+ throw readOnlyMountTable("setAcl", path);
+ }
+
+ @Override
+ public AclStatus getAclStatus(Path path) throws IOException {
+ checkPathIsSlash(path);
+ return new AclStatus.Builder().owner(ugi.getUserName())
+ .group(ugi.getGroupNames()[0])
+ .addEntries(AclUtil.getMinimalAcl(PERMISSION_555))
+ .stickyBit(false).build();
+ }
}
}
Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java?rev=1610911&r1=1610910&r2=1610911&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java Wed Jul 16 05:16:42 2014
@@ -20,6 +20,7 @@ package org.apache.hadoop.fs.viewfs;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Arrays;
+import java.util.ArrayList;
import java.util.List;
@@ -28,9 +29,16 @@ import org.apache.hadoop.fs.BlockLocatio
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.FileSystemTestHelper;
import static org.apache.hadoop.fs.FileSystemTestHelper.*;
+import org.apache.hadoop.fs.permission.AclEntry;
+import static org.apache.hadoop.fs.viewfs.Constants.PERMISSION_555;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FsConstants;
import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.permission.AclStatus;
+import org.apache.hadoop.fs.permission.AclUtil;
import org.apache.hadoop.fs.permission.FsAction;
import org.apache.hadoop.fs.permission.FsPermission;
import org.apache.hadoop.fs.viewfs.ConfigUtil;
@@ -38,6 +46,7 @@ import org.apache.hadoop.fs.viewfs.ViewF
import org.apache.hadoop.fs.viewfs.ViewFileSystem.MountPoint;
import org.apache.hadoop.security.AccessControlException;
import org.apache.hadoop.security.Credentials;
+import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.security.token.Token;
import org.junit.After;
import org.junit.Assert;
@@ -96,7 +105,6 @@ public class ViewFileSystemBaseTest {
// in the test root
// Set up the defaultMT in the config with our mount point links
- //Configuration conf = new Configuration();
conf = ViewFileSystemTestSetup.createConfig();
setupMountPoints();
fsView = FileSystem.get(FsConstants.VIEWFS_URI, conf);
@@ -720,4 +728,49 @@ public class ViewFileSystemBaseTest {
Assert.assertTrue("Other-readable permission not set!",
perms.getOtherAction().implies(FsAction.READ));
}
+
+ /**
+ * Verify the behavior of ACL operations on paths above the root of
+ * any mount table entry.
+ */
+
+ @Test(expected=AccessControlException.class)
+ public void testInternalModifyAclEntries() throws IOException {
+ fsView.modifyAclEntries(new Path("/internalDir"),
+ new ArrayList<AclEntry>());
+ }
+
+ @Test(expected=AccessControlException.class)
+ public void testInternalRemoveAclEntries() throws IOException {
+ fsView.removeAclEntries(new Path("/internalDir"),
+ new ArrayList<AclEntry>());
+ }
+
+ @Test(expected=AccessControlException.class)
+ public void testInternalRemoveDefaultAcl() throws IOException {
+ fsView.removeDefaultAcl(new Path("/internalDir"));
+ }
+
+ @Test(expected=AccessControlException.class)
+ public void testInternalRemoveAcl() throws IOException {
+ fsView.removeAcl(new Path("/internalDir"));
+ }
+
+ @Test(expected=AccessControlException.class)
+ public void testInternalSetAcl() throws IOException {
+ fsView.setAcl(new Path("/internalDir"), new ArrayList<AclEntry>());
+ }
+
+ @Test
+ public void testInternalGetAclStatus() throws IOException {
+ final UserGroupInformation currentUser =
+ UserGroupInformation.getCurrentUser();
+ AclStatus aclStatus = fsView.getAclStatus(new Path("/internalDir"));
+ assertEquals(aclStatus.getOwner(), currentUser.getUserName());
+ assertEquals(aclStatus.getGroup(), currentUser.getGroupNames()[0]);
+ assertEquals(aclStatus.getEntries(),
+ AclUtil.getMinimalAcl(PERMISSION_555));
+ assertFalse(aclStatus.isStickyBit());
+ }
+
}
Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java?rev=1610911&r1=1610910&r2=1610911&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java Wed Jul 16 05:16:42 2014
@@ -22,10 +22,14 @@ import static org.apache.hadoop.fs.FileC
import static org.apache.hadoop.fs.FileContextTestHelper.exists;
import static org.apache.hadoop.fs.FileContextTestHelper.isDir;
import static org.apache.hadoop.fs.FileContextTestHelper.isFile;
+import static org.apache.hadoop.fs.viewfs.Constants.PERMISSION_555;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URI;
+import java.util.ArrayList;
import java.util.List;
import org.apache.hadoop.conf.Configuration;
@@ -39,8 +43,12 @@ import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FsConstants;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.UnresolvedLinkException;
+import org.apache.hadoop.fs.permission.AclEntry;
+import org.apache.hadoop.fs.permission.AclStatus;
+import org.apache.hadoop.fs.permission.AclUtil;
import org.apache.hadoop.fs.viewfs.ViewFs.MountPoint;
import org.apache.hadoop.security.AccessControlException;
+import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.security.token.Token;
import org.junit.After;
import org.junit.Assert;
@@ -695,4 +703,48 @@ public class ViewFsBaseTest {
public void testInternalSetOwner() throws IOException {
fcView.setOwner(new Path("/internalDir"), "foo", "bar");
}
+
+ /**
+ * Verify the behavior of ACL operations on paths above the root of
+ * any mount table entry.
+ */
+
+ @Test(expected=AccessControlException.class)
+ public void testInternalModifyAclEntries() throws IOException {
+ fcView.modifyAclEntries(new Path("/internalDir"),
+ new ArrayList<AclEntry>());
+ }
+
+ @Test(expected=AccessControlException.class)
+ public void testInternalRemoveAclEntries() throws IOException {
+ fcView.removeAclEntries(new Path("/internalDir"),
+ new ArrayList<AclEntry>());
+ }
+
+ @Test(expected=AccessControlException.class)
+ public void testInternalRemoveDefaultAcl() throws IOException {
+ fcView.removeDefaultAcl(new Path("/internalDir"));
+ }
+
+ @Test(expected=AccessControlException.class)
+ public void testInternalRemoveAcl() throws IOException {
+ fcView.removeAcl(new Path("/internalDir"));
+ }
+
+ @Test(expected=AccessControlException.class)
+ public void testInternalSetAcl() throws IOException {
+ fcView.setAcl(new Path("/internalDir"), new ArrayList<AclEntry>());
+ }
+
+ @Test
+ public void testInternalGetAclStatus() throws IOException {
+ final UserGroupInformation currentUser =
+ UserGroupInformation.getCurrentUser();
+ AclStatus aclStatus = fcView.getAclStatus(new Path("/internalDir"));
+ assertEquals(aclStatus.getOwner(), currentUser.getUserName());
+ assertEquals(aclStatus.getGroup(), currentUser.getGroupNames()[0]);
+ assertEquals(aclStatus.getEntries(),
+ AclUtil.getMinimalAcl(PERMISSION_555));
+ assertFalse(aclStatus.isStickyBit());
+ }
}