Search in sources :

Example 11 with AclStatus

use of org.apache.hadoop.fs.permission.AclStatus in project hadoop by apache.

the class TestAclWithSnapshot method testRemoveReadsCurrentState.

@Test
public void testRemoveReadsCurrentState() throws Exception {
    FileSystem.mkdirs(hdfs, path, FsPermission.createImmutable((short) 0700));
    SnapshotTestHelper.createSnapshot(hdfs, path, snapshotName);
    List<AclEntry> aclSpec = Lists.newArrayList(aclEntry(ACCESS, USER, "bruce", ALL));
    hdfs.modifyAclEntries(path, aclSpec);
    hdfs.removeAcl(path);
    AclEntry[] expected = new AclEntry[] {};
    AclStatus s = hdfs.getAclStatus(path);
    AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
    assertArrayEquals(expected, returned);
    assertPermission((short) 0700, path);
    assertDirPermissionDenied(fsAsBruce, BRUCE, path);
    assertDirPermissionDenied(fsAsDiana, DIANA, path);
}
Also used : AclStatus(org.apache.hadoop.fs.permission.AclStatus) AclEntry(org.apache.hadoop.fs.permission.AclEntry) FSAclBaseTest(org.apache.hadoop.hdfs.server.namenode.FSAclBaseTest) Test(org.junit.Test)

Example 12 with AclStatus

use of org.apache.hadoop.fs.permission.AclStatus in project hadoop by apache.

the class TestAclWithSnapshot method doSnapshotContentsRemovalAssertions.

private static void doSnapshotContentsRemovalAssertions(Path filePath, Path fileSnapshotPath, Path subdirPath, Path subdirSnapshotPath) throws Exception {
    AclEntry[] expected = new AclEntry[] {};
    AclStatus s = hdfs.getAclStatus(filePath);
    AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
    assertArrayEquals(expected, returned);
    assertPermission((short) 0500, filePath);
    assertFilePermissionDenied(fsAsBruce, BRUCE, filePath);
    assertFilePermissionDenied(fsAsDiana, DIANA, filePath);
    s = hdfs.getAclStatus(subdirPath);
    returned = s.getEntries().toArray(new AclEntry[0]);
    assertArrayEquals(expected, returned);
    assertPermission((short) 0500, subdirPath);
    assertDirPermissionDenied(fsAsBruce, BRUCE, subdirPath);
    assertDirPermissionDenied(fsAsDiana, DIANA, subdirPath);
    expected = new AclEntry[] { aclEntry(ACCESS, USER, "bruce", READ_EXECUTE), aclEntry(ACCESS, GROUP, NONE) };
    s = hdfs.getAclStatus(fileSnapshotPath);
    returned = s.getEntries().toArray(new AclEntry[0]);
    assertArrayEquals(expected, returned);
    assertPermission((short) 010550, fileSnapshotPath);
    assertFilePermissionGranted(fsAsBruce, BRUCE, fileSnapshotPath);
    assertFilePermissionDenied(fsAsDiana, DIANA, fileSnapshotPath);
    s = hdfs.getAclStatus(subdirSnapshotPath);
    returned = s.getEntries().toArray(new AclEntry[0]);
    assertArrayEquals(expected, returned);
    assertPermission((short) 010550, subdirSnapshotPath);
    assertDirPermissionGranted(fsAsBruce, BRUCE, subdirSnapshotPath);
    assertDirPermissionDenied(fsAsDiana, DIANA, subdirSnapshotPath);
}
Also used : AclStatus(org.apache.hadoop.fs.permission.AclStatus) AclEntry(org.apache.hadoop.fs.permission.AclEntry)

Example 13 with AclStatus

use of org.apache.hadoop.fs.permission.AclStatus in project hadoop by apache.

the class TestLs method resetMock.

@Before
public void resetMock() throws IOException {
    reset(mockFs);
    AclStatus mockAclStatus = mock(AclStatus.class);
    when(mockAclStatus.getEntries()).thenReturn(new ArrayList<AclEntry>());
    when(mockFs.getAclStatus(any(Path.class))).thenReturn(mockAclStatus);
}
Also used : Path(org.apache.hadoop.fs.Path) AclStatus(org.apache.hadoop.fs.permission.AclStatus) AclEntry(org.apache.hadoop.fs.permission.AclEntry) Before(org.junit.Before)

Example 14 with AclStatus

use of org.apache.hadoop.fs.permission.AclStatus in project hadoop by apache.

the class ClientNamenodeProtocolTranslatorPB method getAclStatus.

@Override
public AclStatus getAclStatus(String src) throws IOException {
    GetAclStatusRequestProto req = GetAclStatusRequestProto.newBuilder().setSrc(src).build();
    try {
        if (Client.isAsynchronousMode()) {
            rpcProxy.getAclStatus(null, req);
            final AsyncGet<Message, Exception> asyncReturnMessage = ProtobufRpcEngine.getAsyncReturnMessage();
            final AsyncGet<AclStatus, Exception> asyncGet = new AsyncGet<AclStatus, Exception>() {

                @Override
                public AclStatus get(long timeout, TimeUnit unit) throws Exception {
                    return PBHelperClient.convert((GetAclStatusResponseProto) asyncReturnMessage.get(timeout, unit));
                }

                @Override
                public boolean isDone() {
                    return asyncReturnMessage.isDone();
                }
            };
            AsyncCallHandler.setLowerLayerAsyncReturn(asyncGet);
            return null;
        } else {
            return PBHelperClient.convert(rpcProxy.getAclStatus(null, req));
        }
    } catch (ServiceException e) {
        throw ProtobufHelper.getRemoteException(e);
    }
}
Also used : Message(com.google.protobuf.Message) AclStatus(org.apache.hadoop.fs.permission.AclStatus) ServiceException(com.google.protobuf.ServiceException) GetAclStatusRequestProto(org.apache.hadoop.hdfs.protocol.proto.AclProtos.GetAclStatusRequestProto) AsyncGet(org.apache.hadoop.util.concurrent.AsyncGet) TimeUnit(java.util.concurrent.TimeUnit) IOException(java.io.IOException) ServiceException(com.google.protobuf.ServiceException)

Example 15 with AclStatus

use of org.apache.hadoop.fs.permission.AclStatus in project hadoop by apache.

the class PBHelperClient method convert.

public static AclStatus convert(GetAclStatusResponseProto e) {
    AclStatusProto r = e.getResult();
    AclStatus.Builder builder = new AclStatus.Builder();
    builder.owner(r.getOwner()).group(r.getGroup()).stickyBit(r.getSticky()).addEntries(convertAclEntry(r.getEntriesList()));
    if (r.hasPermission()) {
        builder.setPermission(convert(r.getPermission()));
    }
    return builder.build();
}
Also used : AclStatus(org.apache.hadoop.fs.permission.AclStatus) Builder(org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.LocatedBlockProto.Builder) DatanodeInfoBuilder(org.apache.hadoop.hdfs.protocol.DatanodeInfo.DatanodeInfoBuilder) AclStatusProto(org.apache.hadoop.hdfs.protocol.proto.AclProtos.AclStatusProto)

Aggregations

AclStatus (org.apache.hadoop.fs.permission.AclStatus)91 AclEntry (org.apache.hadoop.fs.permission.AclEntry)81 Test (org.junit.Test)73 Path (org.apache.hadoop.fs.Path)38 FsPermission (org.apache.hadoop.fs.permission.FsPermission)12 FSAclBaseTest (org.apache.hadoop.hdfs.server.namenode.FSAclBaseTest)10 FileSystem (org.apache.hadoop.fs.FileSystem)5 Configuration (org.apache.hadoop.conf.Configuration)3 FileStatus (org.apache.hadoop.fs.FileStatus)3 DistributedFileSystem (org.apache.hadoop.hdfs.DistributedFileSystem)3 DatanodeInfoBuilder (org.apache.hadoop.hdfs.protocol.DatanodeInfo.DatanodeInfoBuilder)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Builder (org.apache.hadoop.fs.ContentSummary.Builder)2 AccessControlException (org.apache.hadoop.security.AccessControlException)2 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ObjectReader (com.fasterxml.jackson.databind.ObjectReader)1 Message (com.google.protobuf.Message)1