diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/security/access/AccessControlClient.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/security/access/AccessControlClient.java index d80e3ae..df4a2d0 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/security/access/AccessControlClient.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/security/access/AccessControlClient.java @@ -201,10 +201,25 @@ public class AccessControlClient { String namespace = tableRegex.substring(1); permList = ProtobufUtil.getUserPermissions(protocol, Bytes.toBytes(namespace)); } else { + // Tables htds = admin.listTables(Pattern.compile(tableRegex), true); for (HTableDescriptor hd : htds) { permList.addAll(ProtobufUtil.getUserPermissions(protocol, hd.getTableName())); } + + // Namespaces + for (NamespaceDescriptor nsds : admin.listNamespaceDescriptors()) { // Read out all namespaces + String namespace = nsds.getName(); + if (namespace.matches(tableRegex)) { // Match the specified table regex ? + for (UserPermission userPerm : ProtobufUtil.getUserPermissions(protocol, Bytes.toBytes(namespace))) { + // For each userPerm, + // clone a new UserPermission object, whose user and actions are the same as the original userPerm, + // but set namespace additionally, + // and then add the cloned one to permList to display. + permList.add(new UserPermission(userPerm.getUser(), namespace, userPerm.getActions())); + } + } + } } } } diff --git a/hbase-shell/src/main/ruby/hbase/security.rb b/hbase-shell/src/main/ruby/hbase/security.rb index c7b94e8..aa8a32b 100644 --- a/hbase-shell/src/main/ruby/hbase/security.rb +++ b/hbase-shell/src/main/ruby/hbase/security.rb @@ -139,7 +139,7 @@ module Hbase if (table_regex != nil && isNamespace?(table_regex)) namespace = table_regex[1...table_regex.length] else - namespace = (value.getTableName != nil) ? value.getTableName.getNamespaceAsString() : '' + namespace = (value.getTableName != nil) ? value.getTableName.getNamespaceAsString() : value.getNamespace() end table = (value.getTableName != nil) ? value.getTableName.getNameAsString() : '' family = (value.getFamily != nil) ?