From 104839b2139c4c7822b307cf5b574df2250a8f31 Mon Sep 17 00:00:00 2001 From: Allen Zhong Date: Wed, 26 Aug 2020 11:43:11 +0800 Subject: [PATCH] cluster: set owner to current user when decompressing tarballs (#713) --- components/dm/spec/grafana.go | 2 +- components/dm/spec/prometheus.go | 2 +- pkg/cluster/operation/telemetry.go | 2 +- pkg/cluster/task/install_package.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/dm/spec/grafana.go b/components/dm/spec/grafana.go index 7d321ee6b8..c944a74ba6 100644 --- a/components/dm/spec/grafana.go +++ b/components/dm/spec/grafana.go @@ -187,7 +187,7 @@ func (i *GrafanaInstance) Deploy(t *task.Builder, srcPath string, deployDir stri return errors.AddStack(err) } - cmd := fmt.Sprintf(`tar -xzf %s -C %s && rm %s`, dstPath, tmp, dstPath) + cmd := fmt.Sprintf(`tar --no-same-owner -zxf %s -C %s && rm %s`, dstPath, tmp, dstPath) _, stderr, err = e.Execute(cmd, false) if err != nil { return errors.Annotatef(err, "stderr: %s", string(stderr)) diff --git a/components/dm/spec/prometheus.go b/components/dm/spec/prometheus.go index 92c800f126..f5ae3778ef 100644 --- a/components/dm/spec/prometheus.go +++ b/components/dm/spec/prometheus.go @@ -165,7 +165,7 @@ func (i *MonitorInstance) Deploy(t *task.Builder, srcPath string, deployDir stri return errors.AddStack(err) } - cmd := fmt.Sprintf(`tar -xzf %s -C %s && rm %s`, dstPath, tmp, dstPath) + cmd := fmt.Sprintf(`tar --no-same-owner -zxf %s -C %s && rm %s`, dstPath, tmp, dstPath) _, stderr, err = e.Execute(cmd, false) if err != nil { return errors.Annotatef(err, "stderr: %s", string(stderr)) diff --git a/pkg/cluster/operation/telemetry.go b/pkg/cluster/operation/telemetry.go index 3baf594452..ff298c4330 100644 --- a/pkg/cluster/operation/telemetry.go +++ b/pkg/cluster/operation/telemetry.go @@ -89,7 +89,7 @@ func GetNodeInfo( } // get node info by exec _telemetry node_info at remote instance. - cmd := fmt.Sprintf(`tar -xzf %s -C %s && rm %s`, dstPath, dstDir, dstPath) + cmd := fmt.Sprintf(`tar --no-same-owner -zxf %s -C %s && rm %s`, dstPath, dstDir, dstPath) _, stderr, err := exec.Execute(cmd, false) if err != nil { return errors.Annotatef(err, "stderr: %s", string(stderr)) diff --git a/pkg/cluster/task/install_package.go b/pkg/cluster/task/install_package.go index b808a19943..1cf1c0cced 100644 --- a/pkg/cluster/task/install_package.go +++ b/pkg/cluster/task/install_package.go @@ -45,7 +45,7 @@ func (c *InstallPackage) Execute(ctx *Context) error { return errors.Annotatef(err, "failed to scp %s to %s:%s", c.srcPath, c.host, dstPath) } - cmd := fmt.Sprintf(`tar -xzf %s -C %s && rm %s`, dstPath, dstDir, dstPath) + cmd := fmt.Sprintf(`tar --no-same-owner -zxf %s -C %s && rm %s`, dstPath, dstDir, dstPath) _, stderr, err := exec.Execute(cmd, false) if err != nil {