diff --git a/internal/pkg/util/copyfile.go b/internal/pkg/util/copyfile.go index 51b1adc1..0807b509 100644 --- a/internal/pkg/util/copyfile.go +++ b/internal/pkg/util/copyfile.go @@ -21,14 +21,13 @@ func CopyFile(src string, dst string) error { } defer srcFD.Close() - // Confirm source file structure is readable - _, err = srcFD.Stat() + srcInfo, err := srcFD.Stat() if err != nil { wwlog.Printf(wwlog.ERROR, "Could not stat source file %s: %s\n", src, err) return err } - dstFD, err := os.Create(dst) + dstFD, err := os.OpenFile(dst, os.O_RDWR|os.O_CREATE, srcInfo.Mode()) if err != nil { wwlog.Printf(wwlog.ERROR, "Could not create destination file %s: %s\n", dst, err) return err