From c565a493e1dc154debf200ccdc0a6d39f6e0c82e Mon Sep 17 00:00:00 2001 From: sunlintong Date: Thu, 1 Jun 2023 16:58:06 +0800 Subject: [PATCH] fix(chown): use 'id' command to replace SUDO_UID, SUDO_GID env --- cmd/kk/pkg/filesystem/task.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/kk/pkg/filesystem/task.go b/cmd/kk/pkg/filesystem/task.go index b824e7825..922ea7c52 100644 --- a/cmd/kk/pkg/filesystem/task.go +++ b/cmd/kk/pkg/filesystem/task.go @@ -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) } }