Skip to content

Commit

Permalink
perf: support only su or sudo
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeEirc committed Aug 7, 2024
1 parent 8a6a49c commit 42387a3
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pkg/srvconn/conn_ssh_su.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ const (

LinuxSudoCommand = "sudo su - %s; exit"

LinuxOnlySuCommand = "su %s; exit"

LinuxOnlySudoCommand = "sudo su %s; exit"

/*
Cisco 相关
*/
Expand Down Expand Up @@ -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"
Expand All @@ -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:

}
Expand All @@ -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:

}
Expand Down

0 comments on commit 42387a3

Please sign in to comment.