diff --git a/pkg/minikube/command/exec_runner.go b/pkg/minikube/command/exec_runner.go index fa252036c3cb..66bd63591b65 100644 --- a/pkg/minikube/command/exec_runner.go +++ b/pkg/minikube/command/exec_runner.go @@ -116,7 +116,7 @@ func (e *execRunner) Copy(f assets.CopyableFile) error { switch runtime.GOOS { case "linux": - // write to TMP location ... + // write to temp location ... tmpfile, err := ioutil.TempFile("", "minikube") if err != nil { return errors.Wrapf(err, "error creating tempfile") @@ -126,9 +126,15 @@ func (e *execRunner) Copy(f assets.CopyableFile) error { if err != nil { return errors.Wrapf(err, "error writing to tempfile %s", tmpfile.Name()) } - // ... then use SUDO to move to target - // then sudo cp -a src dst + + // ... then use sudo to move to target ... _, err = e.RunCmd(exec.Command("sudo", "cp", "-a", tmpfile.Name(), dst)) + if err != nil { + return errors.Wrapf(err, "error copying tempfile %s to dst %s", tmpfile.Name(), dst) + } + + // ... then fix file permission that should have been fine because of "cp -a" + err = os.Chmod(dst, os.FileMode(perms)) return err default: