[fix](auth)Fix no priv to insert to mysql catalog (#25678)
fix user can not insert to mysql catalog even if he has load permission
This commit is contained in:
@ -278,16 +278,17 @@ public class NativeInsertStmt extends InsertStmt {
|
||||
}
|
||||
String dbName = tblName.getDb();
|
||||
String tableName = tblName.getTbl();
|
||||
String ctlName = tblName.getCtl();
|
||||
// check exist
|
||||
DatabaseIf db = analyzer.getEnv().getCatalogMgr().getCatalog(tblName.getCtl()).getDbOrAnalysisException(dbName);
|
||||
TableIf table = db.getTableOrAnalysisException(tblName.getTbl());
|
||||
|
||||
// check access
|
||||
if (!Env.getCurrentEnv().getAccessManager()
|
||||
.checkTblPriv(ConnectContext.get(), dbName, tableName, PrivPredicate.LOAD)) {
|
||||
.checkTblPriv(ConnectContext.get(), ctlName, dbName, tableName, PrivPredicate.LOAD)) {
|
||||
ErrorReport.reportAnalysisException(ErrorCode.ERR_TABLEACCESS_DENIED_ERROR, "LOAD",
|
||||
ConnectContext.get().getQualifiedUser(), ConnectContext.get().getRemoteIP(),
|
||||
dbName + ": " + tableName);
|
||||
ctlName + ": " + dbName + ": " + tableName);
|
||||
}
|
||||
|
||||
tableMap.put(table.getId(), table);
|
||||
@ -334,11 +335,13 @@ public class NativeInsertStmt extends InsertStmt {
|
||||
}
|
||||
|
||||
// Check privilege
|
||||
if (!Env.getCurrentEnv().getAccessManager().checkTblPriv(ConnectContext.get(), tblName.getDb(),
|
||||
tblName.getTbl(), PrivPredicate.LOAD)) {
|
||||
if (!Env.getCurrentEnv().getAccessManager()
|
||||
.checkTblPriv(ConnectContext.get(), tblName.getCtl(), tblName.getDb(),
|
||||
tblName.getTbl(), PrivPredicate.LOAD)) {
|
||||
ErrorReport.reportAnalysisException(ErrorCode.ERR_TABLEACCESS_DENIED_ERROR, "LOAD",
|
||||
ConnectContext.get().getQualifiedUser(),
|
||||
ConnectContext.get().getRemoteIP(), tblName.getDb() + ": " + tblName.getTbl());
|
||||
ConnectContext.get().getRemoteIP(),
|
||||
tblName.getCtl() + ": " + tblName.getDb() + ": " + tblName.getTbl());
|
||||
}
|
||||
|
||||
// check partition
|
||||
|
||||
Reference in New Issue
Block a user