Skip to content

Commit

Permalink
fix(chown): use 'id' command to replace SUDO_UID, SUDO_UID env
Browse files Browse the repository at this point in the history
解决容器内无法获取 SUDO_UID, SUDO_UID,的问题,社区暂未合并此PR
kubesphere#1864
  • Loading branch information
sunlintong committed Sep 4, 2023
1 parent 75805e0 commit 6429eac
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/kk/pkg/filesystem/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ type LocalTaskChown struct {

func (l *LocalTaskChown) Execute(runtime connector.Runtime) error {
if exist := util.IsExist(l.Path); exist {
if err := exec.Command("/bin/sh", "-c", fmt.Sprintf("chown -R ${SUDO_UID}:${SUDO_GID} %s", l.Path)).Run(); err != nil {
if err := exec.Command("/bin/sh", "-c", fmt.Sprintf("chown -R $(id -u):$(id -g) %s", l.Path)).Run(); err != nil {
return errors.Wrapf(errors.WithStack(err), "chown %s failed", l.Path)
}
}
Expand Down

0 comments on commit 6429eac

Please sign in to comment.