Skip to content

Commit

Permalink
fix file permissions after sudo cp -a
Browse files Browse the repository at this point in the history
  • Loading branch information
Git-Jiro committed Oct 14, 2020
1 parent 576f0c1 commit 278a8cd
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pkg/minikube/command/exec_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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:
Expand Down

0 comments on commit 278a8cd

Please sign in to comment.