From 3659662d39ceb3bc4707e4eca45b7f01b9882bf2 Mon Sep 17 00:00:00 2001 From: Eric Date: Tue, 6 Aug 2024 19:32:03 +0800 Subject: [PATCH] perf: support only su or sudo --- pkg/srvconn/conn_ssh_su.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pkg/srvconn/conn_ssh_su.go b/pkg/srvconn/conn_ssh_su.go index 9724214da..d30e6315d 100644 --- a/pkg/srvconn/conn_ssh_su.go +++ b/pkg/srvconn/conn_ssh_su.go @@ -65,6 +65,10 @@ const ( LinuxSudoCommand = "sudo su - %s; exit" + LinuxOnlySuCommand = "su %s; exit" + + LinuxOnlySudoCommand = "sudo su %s; exit" + /* Cisco 相关 */ @@ -115,6 +119,8 @@ type SUMethodType string const ( SuMethodSudo SUMethodType = "sudo" SuMethodSu SUMethodType = "su" + SuMethodOnlySudo SUMethodType = "only_sudo" + SuMethodOnlySu SUMethodType = "only_su" SuMethodEnable SUMethodType = "enable" SuMethodSuper SUMethodType = "super" SuMethodSuperLevel SUMethodType = "super_level" @@ -133,6 +139,10 @@ func NewSuMethodType(suMethod string) SUMethodType { return SuMethodSu case "sudo": return SuMethodSudo + case "only_sudo": + return SuMethodOnlySudo + case "only_su": + return SuMethodOnlySu default: } @@ -155,6 +165,10 @@ func (s *SuConfig) SuCommand() string { return SuCommandSuperH3C case SuMethodSudo: return fmt.Sprintf(LinuxSudoCommand, s.SudoUsername) + case SuMethodOnlySudo: + return fmt.Sprintf(LinuxOnlySudoCommand, s.SudoUsername) + case SuMethodOnlySu: + return fmt.Sprintf(LinuxOnlySuCommand, s.SudoUsername) default: }