HDFS-5739. ACL RPC must allow null name or unspecified permissions in ACL entries. Contributed by Chris Nauroth.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-4685@1556663 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
023c11ec7e
commit
21d4167179
@ -34,3 +34,6 @@ HDFS-4685 (Unreleased)
|
|||||||
|
|
||||||
HDFS-5737. Replacing only the default ACL can fail to copy unspecified base
|
HDFS-5737. Replacing only the default ACL can fail to copy unspecified base
|
||||||
entries from the access ACL. (cnauroth)
|
entries from the access ACL. (cnauroth)
|
||||||
|
|
||||||
|
HDFS-5739. ACL RPC must allow null name or unspecified permissions in ACL
|
||||||
|
entries. (cnauroth)
|
||||||
|
@ -1928,7 +1928,7 @@ private static AclEntryType convert(AclEntryTypeProto v) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static FsActionProto convert(FsAction v) {
|
private static FsActionProto convert(FsAction v) {
|
||||||
return FsActionProto.valueOf(v.ordinal());
|
return FsActionProto.valueOf(v != null ? v.ordinal() : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static FsAction convert(FsActionProto v) {
|
private static FsAction convert(FsActionProto v) {
|
||||||
@ -1939,9 +1939,14 @@ public static List<AclEntryProto> convertAclEntryProto(
|
|||||||
List<AclEntry> aclSpec) {
|
List<AclEntry> aclSpec) {
|
||||||
ArrayList<AclEntryProto> r = Lists.newArrayListWithCapacity(aclSpec.size());
|
ArrayList<AclEntryProto> r = Lists.newArrayListWithCapacity(aclSpec.size());
|
||||||
for (AclEntry e : aclSpec) {
|
for (AclEntry e : aclSpec) {
|
||||||
r.add(AclEntryProto.newBuilder().setType(convert(e.getType()))
|
AclEntryProto.Builder builder = AclEntryProto.newBuilder();
|
||||||
.setName(e.getName()).setPermissions(convert(e.getPermission()))
|
builder.setType(convert(e.getType()));
|
||||||
.setScope(convert(e.getScope())).build());
|
builder.setScope(convert(e.getScope()));
|
||||||
|
builder.setPermissions(convert(e.getPermission()));
|
||||||
|
if (e.getName() != null) {
|
||||||
|
builder.setName(e.getName());
|
||||||
|
}
|
||||||
|
r.add(builder.build());
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
@ -1949,9 +1954,14 @@ public static List<AclEntryProto> convertAclEntryProto(
|
|||||||
public static List<AclEntry> convertAclEntry(List<AclEntryProto> aclSpec) {
|
public static List<AclEntry> convertAclEntry(List<AclEntryProto> aclSpec) {
|
||||||
ArrayList<AclEntry> r = Lists.newArrayListWithCapacity(aclSpec.size());
|
ArrayList<AclEntry> r = Lists.newArrayListWithCapacity(aclSpec.size());
|
||||||
for (AclEntryProto e : aclSpec) {
|
for (AclEntryProto e : aclSpec) {
|
||||||
r.add(new AclEntry.Builder().setType(convert(e.getType()))
|
AclEntry.Builder builder = new AclEntry.Builder();
|
||||||
.setName(e.getName()).setPermission(convert(e.getPermissions()))
|
builder.setType(convert(e.getType()));
|
||||||
.setScope(convert(e.getScope())).build());
|
builder.setScope(convert(e.getScope()));
|
||||||
|
builder.setPermission(convert(e.getPermissions()));
|
||||||
|
if (e.hasName()) {
|
||||||
|
builder.setName(e.getName());
|
||||||
|
}
|
||||||
|
r.add(builder.build());
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ message AclEntryProto {
|
|||||||
required AclEntryTypeProto type = 1;
|
required AclEntryTypeProto type = 1;
|
||||||
required AclEntryScopeProto scope = 2;
|
required AclEntryScopeProto scope = 2;
|
||||||
required FsActionProto permissions = 3;
|
required FsActionProto permissions = 3;
|
||||||
required string name = 4;
|
optional string name = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
message AclStatusProto {
|
message AclStatusProto {
|
||||||
|
@ -589,16 +589,27 @@ public void testChecksumTypeProto() {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAclEntryProto() {
|
public void testAclEntryProto() {
|
||||||
AclEntry e = new AclEntry.Builder().setName("test")
|
// All fields populated.
|
||||||
|
AclEntry e1 = new AclEntry.Builder().setName("test")
|
||||||
.setPermission(FsAction.READ_EXECUTE).setScope(AclEntryScope.DEFAULT)
|
.setPermission(FsAction.READ_EXECUTE).setScope(AclEntryScope.DEFAULT)
|
||||||
.setType(AclEntryType.OTHER).build();
|
.setType(AclEntryType.OTHER).build();
|
||||||
AclEntry[] lists = new AclEntry[] { e };
|
// No name.
|
||||||
|
AclEntry e2 = new AclEntry.Builder().setScope(AclEntryScope.ACCESS)
|
||||||
Assert.assertArrayEquals(
|
.setType(AclEntryType.USER).setPermission(FsAction.ALL).build();
|
||||||
lists,
|
// No permission, which will default to the 0'th enum element.
|
||||||
Lists.newArrayList(
|
AclEntry e3 = new AclEntry.Builder().setScope(AclEntryScope.ACCESS)
|
||||||
|
.setType(AclEntryType.USER).setName("test").build();
|
||||||
|
AclEntry[] expected = new AclEntry[] { e1, e2,
|
||||||
|
new AclEntry.Builder()
|
||||||
|
.setScope(e3.getScope())
|
||||||
|
.setType(e3.getType())
|
||||||
|
.setName(e3.getName())
|
||||||
|
.setPermission(FsAction.NONE)
|
||||||
|
.build() };
|
||||||
|
AclEntry[] actual = Lists.newArrayList(
|
||||||
PBHelper.convertAclEntry(PBHelper.convertAclEntryProto(Lists
|
PBHelper.convertAclEntry(PBHelper.convertAclEntryProto(Lists
|
||||||
.newArrayList(e)))).toArray());
|
.newArrayList(e1, e2, e3)))).toArray(new AclEntry[0]);
|
||||||
|
Assert.assertArrayEquals(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
Reference in New Issue
Block a user