Skip to content

Commit

Permalink
[fix](auth)fix show load priv bug (apache#41723) (apache#42109)
Browse files Browse the repository at this point in the history
  • Loading branch information
zddr authored Nov 6, 2024
1 parent bf34be8 commit 97a5b0d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ public static BulkLoadJob fromLoadStmt(LoadStmt stmt) throws DdlException {
bulkLoadJob.setComment(stmt.getComment());
bulkLoadJob.setJobProperties(stmt.getProperties());
bulkLoadJob.checkAndSetDataSourceInfo((Database) db, stmt.getDataDescriptions());
// In the construction method, there may not be table information yet
bulkLoadJob.rebuildAuthorizationInfo();
return bulkLoadJob;
} catch (MetaNotFoundException e) {
throw new DdlException(e.getMessage());
Expand Down Expand Up @@ -172,6 +174,10 @@ private AuthorizationInfo gatherAuthInfo() throws MetaNotFoundException {
return new AuthorizationInfo(database.getFullName(), getTableNames());
}

public void rebuildAuthorizationInfo() throws MetaNotFoundException {
this.authorizationInfo = gatherAuthInfo();
}

@Override
public Set<String> getTableNamesForShow() {
Optional<Database> db = Env.getCurrentInternalCatalog().getDb(dbId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ public void cancelJob(FailMsg failMsg) throws DdlException {
}
}

private void checkAuth(String command) throws DdlException {
public void checkAuth(String command) throws DdlException {
if (authorizationInfo == null) {
// use the old method to check priv
checkAuthWithoutAuthInfo(command);
Expand Down Expand Up @@ -754,8 +754,6 @@ public void unprotectReadEndOperation(LoadJobFinalOperation loadJobFinalOperatio
public List<Comparable> getShowInfo() throws DdlException {
readLock();
try {
// check auth
checkAuth("SHOW LOAD");
List<Comparable> jobInfo = Lists.newArrayList();
// jobId
jobInfo.add(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,12 @@ public List<List<Comparable>> getLoadJobInfosByDb(long dbId, String labelValue,
if (!states.contains(loadJob.getState())) {
continue;
}
// check auth
try {
loadJob.checkAuth("show load");
} catch (DdlException e) {
continue;
}
// add load job info
loadJobInfos.add(loadJob.getShowInfo());
} catch (RuntimeException | DdlException e) {
Expand Down

0 comments on commit 97a5b0d

Please sign in to comment.