This is an automated email from the ASF dual-hosted git repository.

kxiao pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git

commit 0d89d7d7d2333dc6866e2bba25cecf141a944bf8
Author: zhangdong <493738...@qq.com>
AuthorDate: Fri Oct 13 11:56:00 2023 +0800

    [fix](auth)fix not display be_port (#25197)
    
    fix not display be_port who has ADMIN_PRIV
---
 .../apache/doris/common/proc/BackendsProcDir.java  |  2 --
 .../java/org/apache/doris/qe/ShowExecutor.java     | 13 -------
 .../nereids_p0/system/test_query_sys_tables.groovy |  2 +-
 .../suites/show_p0/test_show_backends.groovy       | 42 ++++++++++++++++++++++
 4 files changed, 43 insertions(+), 16 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/common/proc/BackendsProcDir.java 
b/fe/fe-core/src/main/java/org/apache/doris/common/proc/BackendsProcDir.java
index 7658cfae071..193c3404c2d 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/common/proc/BackendsProcDir.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/common/proc/BackendsProcDir.java
@@ -51,8 +51,6 @@ public class BackendsProcDir implements ProcDirInterface {
             .add("HeartbeatFailureCounter").add("NodeRole")
             .build();
 
-    public static final int HOSTNAME_INDEX = 3;
-
     private SystemInfoService systemInfoService;
 
     public BackendsProcDir(SystemInfoService systemInfoService) {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/ShowExecutor.java 
b/fe/fe-core/src/main/java/org/apache/doris/qe/ShowExecutor.java
index 06e8f4d3929..a75ff619152 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/ShowExecutor.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/ShowExecutor.java
@@ -676,19 +676,6 @@ public class ShowExecutor {
         ProcNodeInterface procNode = showProcStmt.getNode();
 
         List<List<String>> finalRows = procNode.fetchResult().getRows();
-        // if this is superuser, hide ip and host info form backends info proc
-        if (procNode instanceof BackendsProcDir) {
-            if 
(!Env.getCurrentEnv().getAccessManager().checkGlobalPriv(ConnectContext.get(), 
PrivPredicate.OPERATOR)) {
-                // hide host info
-                for (List<String> row : finalRows) {
-                    row.remove(BackendsProcDir.HOSTNAME_INDEX);
-                }
-
-                // mod meta data
-                metaData.removeColumn(BackendsProcDir.HOSTNAME_INDEX);
-            }
-        }
-
         resultSet = new ShowResultSet(metaData, finalRows);
     }
 
diff --git 
a/regression-test/suites/nereids_p0/system/test_query_sys_tables.groovy 
b/regression-test/suites/nereids_p0/system/test_query_sys_tables.groovy
index 7b96e1dc32f..d48b5235b91 100644
--- a/regression-test/suites/nereids_p0/system/test_query_sys_tables.groovy
+++ b/regression-test/suites/nereids_p0/system/test_query_sys_tables.groovy
@@ -180,7 +180,7 @@ suite("test_query_sys_tables", "query,p0") {
     sql("GRANT SELECT_PRIV ON *.*.* TO 'test_sys_tables'")
     sql("use information_schema")
     qt_user_privileges """
-        select GRANTEE, PRIVILEGE_TYPE, IS_GRANTABLE from user_privileges 
where GRANTEE regexp '^\\'test'
+        select GRANTEE, PRIVILEGE_TYPE, IS_GRANTABLE from user_privileges 
where GRANTEE regexp '^\\'test_sys_tables'
     """
     sql("DROP USER 'test_sys_tables'")
 
diff --git a/regression-test/suites/show_p0/test_show_backends.groovy 
b/regression-test/suites/show_p0/test_show_backends.groovy
new file mode 100644
index 00000000000..0ac438345e2
--- /dev/null
+++ b/regression-test/suites/show_p0/test_show_backends.groovy
@@ -0,0 +1,42 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_show_backends", "show") {
+
+    sql """drop user if exists test_show_backends_user1"""
+
+    sql """create user test_show_backends_user1 identified by '12345'"""
+
+    sql """grant ADMIN_PRIV on *.*.* to test_show_backends_user1"""
+
+    result1 = connect(user = 'test_show_backends_user1', password = '12345', 
url = context.config.jdbcUrl) {
+        sql """ show backends """
+    }
+    println result1.toString()
+    result2 = connect(user = 'test_show_backends_user1', password = '12345', 
url = context.config.jdbcUrl) {
+            sql """ show proc '/backends' """
+        }
+    println result2.toString()
+    assertEquals(result1[0][0],result2[0][0])
+    assertEquals(result1[0][1],result2[0][1])
+    assertEquals(result1[0][2],result2[0][2])
+    assertEquals(result1[0][3],result2[0][3])
+    assertEquals(result1[0][4],result2[0][4])
+    assertEquals(result1[0][5],result2[0][5])
+    assertEquals(result1[0][6],result2[0][6])
+}
+


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to