diff --git a/CHANGELOG.md b/CHANGELOG.md index 8bbb41ad..2c6a5829 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Fixed sleep/rebooting on error during GRUB boot. #1894 - Fixed IPMI VLAN configuration. #1892 - Fixed `wwctl image shell --help` to fit properly within 80 columns. +- Preserve existing permissions during `wwctl overlay edit`. #1886 ### Changed diff --git a/internal/app/wwctl/overlay/edit/main.go b/internal/app/wwctl/overlay/edit/main.go index 65c930ca..4100c191 100644 --- a/internal/app/wwctl/overlay/edit/main.go +++ b/internal/app/wwctl/overlay/edit/main.go @@ -111,16 +111,10 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) { } } - // try renaming the tempfile to overlayfile first - err = os.Rename(tempFile.Name(), overlayFile) - if err != nil { - // if it fails, which probably means that they exists on different partitions - // fallback to data copy - wwlog.Debug("Unable to rename temp file: %s to overlay file: %s, try copying the data", tempFile.Name(), overlayFile) - cerr := util.CopyFile(tempFile.Name(), overlayFile) - if cerr != nil { - return fmt.Errorf("unable to copy data from temp file: %s to target file: %s, err: %s", tempFile.Name(), overlayFile, err) - } + // using CopyFile preserves target file permissions + cerr := util.CopyFile(tempFile.Name(), overlayFile) + if cerr != nil { + return fmt.Errorf("unable to copy data from temp file: %s to target file: %s, err: %s", tempFile.Name(), overlayFile, err) } return nil