diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/table/info/show/properties/ShowTablePropertiesAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/table/info/show/properties/ShowTablePropertiesAnalyzer.java index aa1939885fdc..7446697a7a1f 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/table/info/show/properties/ShowTablePropertiesAnalyzer.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/table/info/show/properties/ShowTablePropertiesAnalyzer.java @@ -24,6 +24,8 @@ import org.apache.hadoop.hive.ql.ddl.DDLSemanticAnalyzerFactory.DDLType; import org.apache.hadoop.hive.ql.exec.Task; import org.apache.hadoop.hive.ql.exec.TaskFactory; +import org.apache.hadoop.hive.ql.hooks.ReadEntity; +import org.apache.hadoop.hive.ql.metadata.Table; import org.apache.hadoop.hive.ql.parse.ASTNode; import org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer; import org.apache.hadoop.hive.ql.parse.HiveParser; @@ -45,7 +47,8 @@ public void analyzeInternal(ASTNode root) throws SemanticException { TableName tableName = getQualifiedTableName((ASTNode) root.getChild(0)); String propertyName = (root.getChildCount() > 1) ? unescapeSQLString(root.getChild(1).getText()) : null; - getTable(tableName); // validate that table exists + Table table = getTable(tableName); + inputs.add(new ReadEntity(table)); ShowTablePropertiesDesc desc = new ShowTablePropertiesDesc(ctx.getResFile().toString(), tableName, propertyName); Task task = TaskFactory.get(new DDLWork(getInputs(), getOutputs(), desc)); diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/table/info/show/status/ShowTableStatusAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/table/info/show/status/ShowTableStatusAnalyzer.java index 54e54b3ec1ef..d096dc6b8dc4 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/table/info/show/status/ShowTableStatusAnalyzer.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/table/info/show/status/ShowTableStatusAnalyzer.java @@ -27,10 +27,11 @@ import org.apache.hadoop.hive.ql.ddl.table.partition.PartitionUtils; import org.apache.hadoop.hive.ql.exec.Task; import org.apache.hadoop.hive.ql.exec.TaskFactory; +import org.apache.hadoop.hive.ql.hooks.ReadEntity; +import org.apache.hadoop.hive.ql.metadata.Table; import org.apache.hadoop.hive.ql.parse.ASTNode; import org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer; import org.apache.hadoop.hive.ql.parse.HiveParser; -import org.apache.hadoop.hive.ql.parse.HiveTableName; import org.apache.hadoop.hive.ql.parse.SemanticException; import org.apache.hadoop.hive.ql.session.SessionState; @@ -68,9 +69,12 @@ public void analyzeInternal(ASTNode root) throws SemanticException { } } + Table table = getTable(dbName, tableNames, true); + inputs.add(new ReadEntity(table)); + if (partitionSpec != null) { // validate that partition exists - PartitionUtils.getPartition(db, getTable(HiveTableName.of(tableNames)), partitionSpec, true); + PartitionUtils.getPartition(db, table, partitionSpec, true); } ShowTableStatusDesc desc = new ShowTableStatusDesc(ctx.getResFile(), dbName, tableNames, partitionSpec); diff --git a/ql/src/test/queries/clientnegative/authorization_show_tableextended_nosel.q b/ql/src/test/queries/clientnegative/authorization_show_tableextended_nosel.q new file mode 100644 index 000000000000..1a88c5524e98 --- /dev/null +++ b/ql/src/test/queries/clientnegative/authorization_show_tableextended_nosel.q @@ -0,0 +1,10 @@ +--! qt:authorizer +set user.name=user1; + +create table t_show_ext(i int); + +grant all on table t_show_ext to user user2; +revoke select on table t_show_ext from user user2; + +set user.name=user2; +show table extended like 't_show_ext'; diff --git a/ql/src/test/queries/clientnegative/authorization_show_tblproperties_nosel.q b/ql/src/test/queries/clientnegative/authorization_show_tblproperties_nosel.q new file mode 100644 index 000000000000..fe3054e05a66 --- /dev/null +++ b/ql/src/test/queries/clientnegative/authorization_show_tblproperties_nosel.q @@ -0,0 +1,10 @@ +--! qt:authorizer +set user.name=user1; + +create table t_show_props(i int); + +grant all on table t_show_props to user user2; +revoke select on table t_show_props from user user2; + +set user.name=user2; +show tblproperties t_show_props; diff --git a/ql/src/test/results/clientnegative/authorization_show_tableextended_nosel.q.out b/ql/src/test/results/clientnegative/authorization_show_tableextended_nosel.q.out new file mode 100644 index 000000000000..7e498cbf7960 --- /dev/null +++ b/ql/src/test/results/clientnegative/authorization_show_tableextended_nosel.q.out @@ -0,0 +1,21 @@ +PREHOOK: query: create table t_show_ext(i int) +PREHOOK: type: CREATETABLE +PREHOOK: Output: database:default +PREHOOK: Output: default@t_show_ext +POSTHOOK: query: create table t_show_ext(i int) +POSTHOOK: type: CREATETABLE +POSTHOOK: Output: database:default +POSTHOOK: Output: default@t_show_ext +PREHOOK: query: grant all on table t_show_ext to user user2 +PREHOOK: type: GRANT_PRIVILEGE +PREHOOK: Output: default@t_show_ext +POSTHOOK: query: grant all on table t_show_ext to user user2 +POSTHOOK: type: GRANT_PRIVILEGE +POSTHOOK: Output: default@t_show_ext +PREHOOK: query: revoke select on table t_show_ext from user user2 +PREHOOK: type: REVOKE_PRIVILEGE +PREHOOK: Output: default@t_show_ext +POSTHOOK: query: revoke select on table t_show_ext from user user2 +POSTHOOK: type: REVOKE_PRIVILEGE +POSTHOOK: Output: default@t_show_ext +FAILED: HiveAccessControlException Permission denied: Principal [name=user2, type=USER] does not have following privileges for operation SHOW_TABLESTATUS [[SELECT] on Object [type=TABLE_OR_VIEW, name=hive.default.t_show_ext]] diff --git a/ql/src/test/results/clientnegative/authorization_show_tblproperties_nosel.q.out b/ql/src/test/results/clientnegative/authorization_show_tblproperties_nosel.q.out new file mode 100644 index 000000000000..f2db4af99d7f --- /dev/null +++ b/ql/src/test/results/clientnegative/authorization_show_tblproperties_nosel.q.out @@ -0,0 +1,21 @@ +PREHOOK: query: create table t_show_props(i int) +PREHOOK: type: CREATETABLE +PREHOOK: Output: database:default +PREHOOK: Output: default@t_show_props +POSTHOOK: query: create table t_show_props(i int) +POSTHOOK: type: CREATETABLE +POSTHOOK: Output: database:default +POSTHOOK: Output: default@t_show_props +PREHOOK: query: grant all on table t_show_props to user user2 +PREHOOK: type: GRANT_PRIVILEGE +PREHOOK: Output: default@t_show_props +POSTHOOK: query: grant all on table t_show_props to user user2 +POSTHOOK: type: GRANT_PRIVILEGE +POSTHOOK: Output: default@t_show_props +PREHOOK: query: revoke select on table t_show_props from user user2 +PREHOOK: type: REVOKE_PRIVILEGE +PREHOOK: Output: default@t_show_props +POSTHOOK: query: revoke select on table t_show_props from user user2 +POSTHOOK: type: REVOKE_PRIVILEGE +POSTHOOK: Output: default@t_show_props +FAILED: HiveAccessControlException Permission denied: Principal [name=user2, type=USER] does not have following privileges for operation SHOW_TBLPROPERTIES [[SELECT] on Object [type=TABLE_OR_VIEW, name=hive.default.t_show_props]]