Skip to content

Commit 97a5b0d

Browse files
authored
[fix](auth)fix show load priv bug (apache#41723) (apache#42109)
pick: apache#41723
1 parent bf34be8 commit 97a5b0d

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

fe/fe-core/src/main/java/org/apache/doris/load/loadv2/BulkLoadJob.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ public static BulkLoadJob fromLoadStmt(LoadStmt stmt) throws DdlException {
140140
bulkLoadJob.setComment(stmt.getComment());
141141
bulkLoadJob.setJobProperties(stmt.getProperties());
142142
bulkLoadJob.checkAndSetDataSourceInfo((Database) db, stmt.getDataDescriptions());
143+
// In the construction method, there may not be table information yet
144+
bulkLoadJob.rebuildAuthorizationInfo();
143145
return bulkLoadJob;
144146
} catch (MetaNotFoundException e) {
145147
throw new DdlException(e.getMessage());
@@ -172,6 +174,10 @@ private AuthorizationInfo gatherAuthInfo() throws MetaNotFoundException {
172174
return new AuthorizationInfo(database.getFullName(), getTableNames());
173175
}
174176

177+
public void rebuildAuthorizationInfo() throws MetaNotFoundException {
178+
this.authorizationInfo = gatherAuthInfo();
179+
}
180+
175181
@Override
176182
public Set<String> getTableNamesForShow() {
177183
Optional<Database> db = Env.getCurrentInternalCatalog().getDb(dbId);

fe/fe-core/src/main/java/org/apache/doris/load/loadv2/LoadJob.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ public void cancelJob(FailMsg failMsg) throws DdlException {
602602
}
603603
}
604604

605-
private void checkAuth(String command) throws DdlException {
605+
public void checkAuth(String command) throws DdlException {
606606
if (authorizationInfo == null) {
607607
// use the old method to check priv
608608
checkAuthWithoutAuthInfo(command);
@@ -754,8 +754,6 @@ public void unprotectReadEndOperation(LoadJobFinalOperation loadJobFinalOperatio
754754
public List<Comparable> getShowInfo() throws DdlException {
755755
readLock();
756756
try {
757-
// check auth
758-
checkAuth("SHOW LOAD");
759757
List<Comparable> jobInfo = Lists.newArrayList();
760758
// jobId
761759
jobInfo.add(id);

fe/fe-core/src/main/java/org/apache/doris/load/loadv2/LoadManager.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,12 @@ public List<List<Comparable>> getLoadJobInfosByDb(long dbId, String labelValue,
611611
if (!states.contains(loadJob.getState())) {
612612
continue;
613613
}
614+
// check auth
615+
try {
616+
loadJob.checkAuth("show load");
617+
} catch (DdlException e) {
618+
continue;
619+
}
614620
// add load job info
615621
loadJobInfos.add(loadJob.getShowInfo());
616622
} catch (RuntimeException | DdlException e) {

0 commit comments

Comments
 (0)