Skip to content

Commit 278a8cd

Browse files
committed
fix file permissions after sudo cp -a
1 parent 576f0c1 commit 278a8cd

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

pkg/minikube/command/exec_runner.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func (e *execRunner) Copy(f assets.CopyableFile) error {
116116

117117
switch runtime.GOOS {
118118
case "linux":
119-
// write to TMP location ...
119+
// write to temp location ...
120120
tmpfile, err := ioutil.TempFile("", "minikube")
121121
if err != nil {
122122
return errors.Wrapf(err, "error creating tempfile")
@@ -126,9 +126,15 @@ func (e *execRunner) Copy(f assets.CopyableFile) error {
126126
if err != nil {
127127
return errors.Wrapf(err, "error writing to tempfile %s", tmpfile.Name())
128128
}
129-
// ... then use SUDO to move to target
130-
// then sudo cp -a src dst
129+
130+
// ... then use sudo to move to target ...
131131
_, err = e.RunCmd(exec.Command("sudo", "cp", "-a", tmpfile.Name(), dst))
132+
if err != nil {
133+
return errors.Wrapf(err, "error copying tempfile %s to dst %s", tmpfile.Name(), dst)
134+
}
135+
136+
// ... then fix file permission that should have been fine because of "cp -a"
137+
err = os.Chmod(dst, os.FileMode(perms))
132138
return err
133139

134140
default:

0 commit comments

Comments
 (0)