HBASE-12301 user_permission command does not show global permissions

This commit is contained in:
Matteo Bertozzi 2014-10-22 10:08:31 +01:00
parent feaa8fa9c8
commit 2908c11371
5 changed files with 14 additions and 19 deletions

View File

@ -2279,7 +2279,7 @@ public final class ProtobufUtil {
AccessControlProtos.GetUserPermissionsRequest request = builder.build();
AccessControlProtos.GetUserPermissionsResponse response =
protocol.getUserPermissions(null, request);
List<UserPermission> perms = new ArrayList<UserPermission>();
List<UserPermission> perms = new ArrayList<UserPermission>(response.getUserPermissionCount());
for (AccessControlProtos.UserPermission perm: response.getUserPermissionList()) {
perms.add(ProtobufUtil.toUserPermission(perm));
}
@ -2307,7 +2307,7 @@ public final class ProtobufUtil {
AccessControlProtos.GetUserPermissionsRequest request = builder.build();
AccessControlProtos.GetUserPermissionsResponse response =
protocol.getUserPermissions(null, request);
List<UserPermission> perms = new ArrayList<UserPermission>();
List<UserPermission> perms = new ArrayList<UserPermission>(response.getUserPermissionCount());
for (AccessControlProtos.UserPermission perm: response.getUserPermissionList()) {
perms.add(ProtobufUtil.toUserPermission(perm));
}
@ -2335,7 +2335,7 @@ public final class ProtobufUtil {
AccessControlProtos.GetUserPermissionsRequest request = builder.build();
AccessControlProtos.GetUserPermissionsResponse response =
protocol.getUserPermissions(null, request);
List<UserPermission> perms = new ArrayList<UserPermission>();
List<UserPermission> perms = new ArrayList<UserPermission>(response.getUserPermissionCount());
for (AccessControlProtos.UserPermission perm: response.getUserPermissionList()) {
perms.add(ProtobufUtil.toUserPermission(perm));
}

View File

@ -47,12 +47,11 @@ import org.apache.hadoop.hbase.util.Bytes;
@InterfaceAudience.Public
@InterfaceStability.Evolving
public class AccessControlClient {
public static final TableName ACL_TABLE_NAME =
TableName.valueOf(NamespaceDescriptor.SYSTEM_NAMESPACE_NAME_STR, "acl");
private static HTable getAclTable(Configuration conf) throws IOException {
TableName aclTableName =
TableName.valueOf(NamespaceDescriptor.SYSTEM_NAMESPACE_NAME_STR,
AccessControlConstants.OP_ATTRIBUTE_ACL);
return new HTable(conf, aclTableName.getName());
return new HTable(conf, ACL_TABLE_NAME);
}
private static BlockingInterface getAccessControlServiceStub(HTable ht)
@ -111,12 +110,10 @@ public class AccessControlClient {
public static boolean isAccessControllerRunning(Configuration conf)
throws MasterNotRunningException, ZooKeeperConnectionException, IOException {
TableName aclTableName = TableName
.valueOf(NamespaceDescriptor.SYSTEM_NAMESPACE_NAME_STR, "acl");
HBaseAdmin ha = null;
try {
ha = new HBaseAdmin(conf);
return ha.isTableAvailable(aclTableName.getNameAsString());
return ha.isTableAvailable(ACL_TABLE_NAME);
} finally {
if (ha != null) {
ha.close();
@ -183,16 +180,14 @@ public class AccessControlClient {
Table ht = null;
Admin ha = null;
try {
TableName aclTableName = TableName.valueOf(NamespaceDescriptor.SYSTEM_NAMESPACE_NAME_STR,
"acl");
ha = new HBaseAdmin(conf);
ht = new HTable(conf, aclTableName);
ht = new HTable(conf, ACL_TABLE_NAME);
CoprocessorRpcChannel service = ht.coprocessorService(HConstants.EMPTY_START_ROW);
BlockingInterface protocol = AccessControlProtos.AccessControlService
.newBlockingStub(service);
HTableDescriptor[] htds = null;
if (tableRegex == null) {
if (tableRegex == null || tableRegex.isEmpty()) {
permList = ProtobufUtil.getUserPermissions(protocol);
} else if (tableRegex.charAt(0) == '@') {
String namespace = tableRegex.substring(1);

View File

@ -464,7 +464,7 @@ public class AccessControlLists {
*/
static ListMultimap<String, TablePermission> getPermissions(Configuration conf,
byte[] entryName) throws IOException {
if (entryName == null) entryName = ACL_TABLE_NAME.getName();
if (entryName == null) entryName = ACL_GLOBAL_NAME;
// for normal user tables, we just read the table row from _acl_
ListMultimap<String, TablePermission> perms = ArrayListMultimap.create();

View File

@ -156,7 +156,7 @@ module Hbase
count = 0
all_perms.each do |value|
user_name = String.from_java_bytes(value.getUser)
if (isNamespace?(table_regex))
if (table_regex != nil && isNamespace?(table_regex))
namespace = table_regex[1...table_regex.length]
else
namespace = (value.getTableName != nil) ? value.getTableName.getNamespaceAsString() : ''

View File

@ -33,7 +33,7 @@ For example:
EOF
end
def command(table_regex=".*")
def command(table_regex=nil)
#format_simple_command do
#admin.user_permission(table_regex)
now = Time.now