You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2022/12/19 08:05:15 UTC
[doris] 02/02: [fix](auth) fix bug that user info may lost when upgrading to 1.2.0 (#15144)
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git
commit 708492d74e63e57f8c29c05ffc1f1b069e750366
Author: Mingyu Chen <mo...@163.com>
AuthorDate: Mon Dec 19 16:01:18 2022 +0800
[fix](auth) fix bug that user info may lost when upgrading to 1.2.0 (#15144)
* [fix](auth) fix bug that user info may lost when upgrading to 1.2.0
* fix
---
.../main/java/org/apache/doris/mysql/privilege/PrivBitSet.java | 5 +++++
.../java/org/apache/doris/mysql/privilege/UserPrivTable.java | 10 +++-------
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/PrivBitSet.java b/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/PrivBitSet.java
index a5a46cb294..f6e31e217f 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/PrivBitSet.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/PrivBitSet.java
@@ -73,6 +73,10 @@ public class PrivBitSet implements Writable {
set ^= other.set;
}
+ public void clean() {
+ this.set = 0;
+ }
+
public void remove(PrivBitSet privs) {
PrivBitSet tmp = copy();
tmp.xor(privs);
@@ -171,3 +175,4 @@ public class PrivBitSet implements Writable {
Text.writeString(out, GsonUtils.GSON.toJson(this));
}
}
+
diff --git a/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/UserPrivTable.java b/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/UserPrivTable.java
index b69b1157d5..354da66904 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/UserPrivTable.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/UserPrivTable.java
@@ -31,7 +31,6 @@ import org.apache.logging.log4j.Logger;
import java.io.DataOutput;
import java.io.IOException;
-import java.util.LinkedList;
import java.util.List;
/*
@@ -200,7 +199,6 @@ public class UserPrivTable extends PrivTable {
*/
public CatalogPrivTable degradeToInternalCatalogPriv() throws IOException {
CatalogPrivTable catalogPrivTable = new CatalogPrivTable();
- List<PrivEntry> degradedEntries = new LinkedList<>();
for (PrivEntry privEntry : entries) {
GlobalPrivEntry globalPrivEntry = (GlobalPrivEntry) privEntry;
if (!globalPrivEntry.match(UserIdentity.ROOT, true)
@@ -215,19 +213,17 @@ public class UserPrivTable extends PrivTable {
entry.setSetByDomainResolver(false);
catalogPrivTable.addEntry(entry, false, false);
if (globalPrivEntry.privSet.containsResourcePriv()) {
- // Should keep the USAGE_PRIV in userPrivTable, and remove other privs and entries.
+ // Should only keep the USAGE_PRIV in userPrivTable, and remove other privs and entries.
globalPrivEntry.privSet.and(PrivBitSet.of(PaloPrivilege.USAGE_PRIV));
} else {
- degradedEntries.add(globalPrivEntry);
+ // Remove all other privs
+ globalPrivEntry.privSet.clean();
}
} catch (Exception e) {
throw new IOException(e.getMessage());
}
}
}
- for (PrivEntry degraded : degradedEntries) {
- dropEntry(degraded);
- }
return catalogPrivTable;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org