This is an automated email from the ASF dual-hosted git repository. morrysnow pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new 094f2dd02a9 [fix](auth)Prohibit other users from modifying the root (#48752) 094f2dd02a9 is described below commit 094f2dd02a93304693db549ac4a284469d59d842 Author: zhangdong <zhangd...@selectdb.com> AuthorDate: Thu Mar 27 17:56:07 2025 +0800 [fix](auth)Prohibit other users from modifying the root (#48752) --- .../org/apache/doris/analysis/AlterUserStmt.java | 8 ++++ .../suites/account_p0/test_root_user.groovy | 45 ++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/AlterUserStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/AlterUserStmt.java index 2815f2a30b1..aa5c69c29ac 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/AlterUserStmt.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/AlterUserStmt.java @@ -18,10 +18,12 @@ package org.apache.doris.analysis; import org.apache.doris.catalog.Env; +import org.apache.doris.cluster.ClusterNamespace; import org.apache.doris.common.AnalysisException; import org.apache.doris.common.ErrorCode; import org.apache.doris.common.ErrorReport; import org.apache.doris.common.UserException; +import org.apache.doris.mysql.privilege.Auth; import org.apache.doris.mysql.privilege.PasswordPolicy.FailedLoginPolicy; import org.apache.doris.mysql.privilege.PrivPredicate; import org.apache.doris.qe.ConnectContext; @@ -133,6 +135,12 @@ public class AlterUserStmt extends DdlStmt implements NotFallbackInParser { throw new AnalysisException("Only support doing one type of operation at one time"); } + if (userDesc.getUserIdent().getQualifiedUser().equals(Auth.ROOT_USER) + && !ClusterNamespace.getNameFromFullName(ConnectContext.get().getQualifiedUser()) + .equals(Auth.ROOT_USER)) { + throw new AnalysisException("Only root user can modify root user"); + } + if (!Env.getCurrentEnv().getAccessManager().checkGlobalPriv(ConnectContext.get(), PrivPredicate.GRANT)) { ErrorReport.reportAnalysisException(ErrorCode.ERR_SPECIFIC_ACCESS_DENIED_ERROR, "GRANT"); } diff --git a/regression-test/suites/account_p0/test_root_user.groovy b/regression-test/suites/account_p0/test_root_user.groovy new file mode 100644 index 00000000000..7296120a8b8 --- /dev/null +++ b/regression-test/suites/account_p0/test_root_user.groovy @@ -0,0 +1,45 @@ +// 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. + +import org.junit.Assert; + +suite("test_root_user", "account") { + String suiteName = "test_root_user" + String user = "${suiteName}_user" + String pwd = 'C123_567p' + + try_sql("DROP USER ${user}") + sql """CREATE USER '${user}' IDENTIFIED BY '${pwd}'""" + sql """GRANT ADMIN_PRIV ON *.*.* TO ${user}""" + connect(user, "${pwd}", context.config.jdbcUrl) { + test { + sql """ + alter user root identified by '123456'; + """ + exception "root" + } + + test { + sql """ + set password for 'root' = password('123456'); + """ + exception "root" + } + } + +} + --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org