Skip to content

Commit

Permalink
Remove username from sudo command
Browse files Browse the repository at this point in the history
Fix pingcap#731

Signed-off-by: lucklove <gnu.crazier@gmail.com>
  • Loading branch information
lucklove committed Sep 1, 2020
1 parent a13ad71 commit e8e2226
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/cluster/executor/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func (e *EasySSHExecutor) initialize(config SSHConfig) {
func (e *EasySSHExecutor) Execute(cmd string, sudo bool, timeout ...time.Duration) ([]byte, []byte, error) {
// try to acquire root permission
if e.Sudo || sudo {
cmd = fmt.Sprintf("sudo -H -u root bash -c \"%s\"", cmd)
cmd = fmt.Sprintf("sudo -H bash -c \"%s\"", cmd)
}

// set a basic PATH in case it's empty on login
Expand Down Expand Up @@ -278,7 +278,7 @@ func (e *NativeSSHExecutor) Execute(cmd string, sudo bool, timeout ...time.Durat

// try to acquire root permission
if e.Sudo || sudo {
cmd = fmt.Sprintf("sudo -H -u root bash -c \"%s\"", cmd)
cmd = fmt.Sprintf("sudo -H bash -c \"%s\"", cmd)
}

// set a basic PATH in case it's empty on login
Expand Down

0 comments on commit e8e2226

Please sign in to comment.