Skip to content

Commit

Permalink
Merge 244b96b into 5ef4728
Browse files Browse the repository at this point in the history
  • Loading branch information
nexustar authored Aug 12, 2021
2 parents 5ef4728 + 244b96b commit c8a1e70
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions components/playground/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ var (
)

const (
mode = "mode"
withMonitor = "monitor"
mode = "mode"
withMonitor = "monitor"
withoutMonitor = "without-monitor"

// instance numbers
Expand Down
6 changes: 3 additions & 3 deletions pkg/cluster/executor/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ var _ ctxt.Executor = &Local{}
func (l *Local) Execute(ctx context.Context, cmd string, sudo bool, timeout ...time.Duration) ([]byte, []byte, error) {
// try to acquire root permission
if l.Sudo || sudo {
cmd = fmt.Sprintf("sudo -H -u root bash -c 'cd; %s'", cmd)
cmd = fmt.Sprintf("/usr/bin/sudo -H -u root bash -c 'cd; %s'", cmd)
} else {
cmd = fmt.Sprintf("sudo -H -u %s bash -c 'cd; %s'", l.Config.User, cmd)
cmd = fmt.Sprintf("/usr/bin/sudo -H -u %s bash -c 'cd; %s'", l.Config.User, cmd)
}

// set a basic PATH in case it's empty on login
Expand Down Expand Up @@ -114,7 +114,7 @@ func (l *Local) Transfer(ctx context.Context, src, dst string, download bool, li
if download || user.Username == l.Config.User {
cmd = fmt.Sprintf("cp %s %s", src, dst)
} else {
cmd = fmt.Sprintf("sudo -H -u root bash -c \"cp %[1]s %[2]s && chown %[3]s:$(id -g -n %[3]s) %[2]s\"", src, dst, l.Config.User)
cmd = fmt.Sprintf("/usr/bin/sudo -H -u root bash -c \"cp %[1]s %[2]s && chown %[3]s:$(id -g -n %[3]s) %[2]s\"", src, dst, l.Config.User)
}

command := exec.Command("/bin/sh", "-c", cmd)
Expand Down
4 changes: 2 additions & 2 deletions pkg/cluster/executor/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func (e *EasySSHExecutor) initialize(config SSHConfig) {
func (e *EasySSHExecutor) Execute(ctx context.Context, cmd string, sudo bool, timeout ...time.Duration) ([]byte, []byte, error) {
// try to acquire root permission
if e.Sudo || sudo {
cmd = fmt.Sprintf("sudo -H bash -c \"%s\"", cmd)
cmd = fmt.Sprintf("/usr/bin/sudo -H bash -c \"%s\"", cmd)
}

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

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

// set a basic PATH in case it's empty on login
Expand Down
2 changes: 1 addition & 1 deletion pkg/cluster/operation/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ func CheckDirPermission(ctx context.Context, e ctxt.Executor, user, path string)

_, stderr, err := e.Execute(ctx,
fmt.Sprintf(
"sudo -u %[1]s touch %[2]s/.tiup_cluster_check_file && rm -f %[2]s/.tiup_cluster_check_file",
"/usr/bin/sudo -u %[1]s touch %[2]s/.tiup_cluster_check_file && rm -f %[2]s/.tiup_cluster_check_file",
user,
path,
),
Expand Down

0 comments on commit c8a1e70

Please sign in to comment.