From 94defc3e0cbdd6c08b859d39fc1a001614acbeb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Thu, 23 Nov 2023 16:12:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96SSH=E8=AE=A4=E8=AF=81sudo?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/db/models/node_grant_dao.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/db/models/node_grant_dao.go b/internal/db/models/node_grant_dao.go index e6ba1b9f..ffbfbe9a 100644 --- a/internal/db/models/node_grant_dao.go +++ b/internal/db/models/node_grant_dao.go @@ -89,7 +89,9 @@ func (this *NodeGrantDAO) CreateGrant(tx *dbs.Tx, adminId int64, name string, me op.PrivateKey = privateKey op.Passphrase = passphrase } - op.Su = su + if username != "root" { // only for non-root user + op.Su = su + } op.Description = description op.NodeId = nodeId op.State = NodeGrantStateEnabled @@ -117,7 +119,11 @@ func (this *NodeGrantDAO) UpdateGrant(tx *dbs.Tx, grantId int64, name string, me op.PrivateKey = privateKey op.Passphrase = passphrase } - op.Su = su + if username != "root" { // only for non-root user + op.Su = su + } else { + op.Su = false + } op.Description = description op.NodeId = nodeId err := this.Save(tx, op)