Apache9 commented on code in PR #8826:
URL: https://github.com/apache/hbase/pull/8826#discussion_r4424541244
##########
hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/PermissionStorage.java:
##########
@@ -285,53 +284,37 @@ static void removeNamespacePermissions(Configuration
conf, String namespace, Tab
}
}
- static private void removeTablePermissions(TableName tableName, byte[]
column, Table table,
- boolean closeTable) throws IOException {
- Scan scan = new Scan();
- scan.addFamily(ACL_LIST_FAMILY);
-
- String columnName = Bytes.toString(column);
- scan.setFilter(new QualifierFilter(CompareOperator.EQUAL,
- new RegexStringComparator(String.format("(%s%s%s)|(%s%s)$",
ACL_KEY_DELIMITER, columnName,
- ACL_KEY_DELIMITER, ACL_KEY_DELIMITER, columnName))));
-
- Set<byte[]> qualifierSet = new TreeSet<>(Bytes.BYTES_COMPARATOR);
- ResultScanner scanner = null;
+ /**
+ * Remove permissions of the specified column families of the given table
from the acl table.
+ */
+ static void removeTableColumnFamiliesPermissions(Configuration conf,
TableName tableName,
+ Collection<byte[]> columns, Table t) throws IOException {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Removing permissions of removed columns {} from table {}",
+
columns.stream().map(Bytes::toStringBinary).collect(Collectors.joining(", ")),
tableName);
+ }
try {
- scanner = table.getScanner(scan);
- for (Result res : scanner) {
- for (byte[] q : res.getFamilyMap(ACL_LIST_FAMILY).navigableKeySet()) {
- qualifierSet.add(q);
+ Set<byte[]> families = new TreeSet<>(Bytes.BYTES_COMPARATOR);
+ families.addAll(columns);
+ ListMultimap<String, UserPermission> perms = getTablePermissions(conf,
tableName, t);
+ Delete d = new Delete(tableName.getName());
+ boolean found = false;
+ for (UserPermission perm : perms.values()) {
+ Permission permission = perm.getPermission();
+ if (permission instanceof TablePermission) {
+ byte[] family = ((TablePermission) permission).getFamily();
+ if (family != null && families.contains(family)) {
+ d.addColumns(ACL_LIST_FAMILY, userPermissionKey(perm));
+ found = true;
+ }
}
}
Review Comment:
The key is username, which is text. Family is stored in TablePermission as
bytes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]