You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by GitBox <gi...@apache.org> on 2021/11/19 10:08:32 UTC
[GitHub] [hive] shameersss1 commented on a change in pull request #2770: HIVE-25680 : Authorize #get_table_meta HiveMetastore Server API to use any of the HiveMetastore Authorization model
shameersss1 commented on a change in pull request #2770:
URL: https://github.com/apache/hive/pull/2770#discussion_r753053040
##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java
##########
@@ -3633,21 +3633,46 @@ private Table getTableInternal(GetTableRequest getTableRequest) throws MetaExcep
@Override
public List<TableMeta> get_table_meta(String dbnames, String tblNames, List<String> tblTypes)
throws MetaException, NoSuchObjectException {
+
List<TableMeta> t = null;
+ List<TableMeta> finalT = new ArrayList<>();
String[] parsedDbName = parseDbName(dbnames, conf);
startTableFunction("get_table_metas", parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tblNames);
Exception ex = null;
try {
t = getMS().getTableMeta(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tblNames, tblTypes);
t = FilterUtils.filterTableMetasIfEnabled(isServerFilterEnabled, filterHook,
parsedDbName[CAT_NAME], parsedDbName[DB_NAME], t);
+
+ // metastore authorization : If any listeners are attached then for each tablemeta check if
+ // the database is readable, if so keep the tablemeta else remove it from the final list.
+ if(preListeners.size() > 0) {
+ Map<String, Boolean> databaseNames = new HashMap();
+ for (TableMeta tableMeta : t) {
+ String fullDbName = prependCatalogToDbName(parsedDbName[CAT_NAME], tableMeta.getDbName(), conf);
+ if (databaseNames.get(fullDbName) == null) {
+ boolean isExecptionThrown = false;
+ try {
+ fireReadDatabasePreEvent(fullDbName);
+ } catch (MetaException e) {
+ isExecptionThrown = true;
+ }
+ databaseNames.put(fullDbName, isExecptionThrown);
+ }
+ if (!databaseNames.get(fullDbName)) {
+ finalT.add(tableMeta);
+ }
+ }
+ } else {
+ finalT.addAll(t);
+ }
Review comment:
ack
##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java
##########
@@ -5484,6 +5509,29 @@ private void fireReadTablePreEvent(String catName, String dbName, String tblName
}
}
+ /**
+ * Fire a pre-event for read database operation, if there are any
+ * pre-event listeners registered
+ */
+ private void fireReadDatabasePreEvent(final String name)
+ throws MetaException, NoSuchObjectException {
+ if(preListeners.size() > 0) {
+ // do this only if there is a pre event listener registered (avoid unnecessary
+ // metastore api call)
Review comment:
ack
--
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: gitbox-unsubscribe@hive.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org