diff --git a/CHANGELOG.md b/CHANGELOG.md index d528cb5a..8d3b340c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Fix dhcp not passing asset tag or uuid to iPXE. #1110 - Restored previous static dhcp behavior. #1263 - Capture "broken" symlinks during container build. #1267 +- Fix the issue that removing lines during wwctl overlay edit didn't work. #1235 +- Fix the issue that new files created with wwctl overlay edit have 755 permissions. #1236 ## v4.5.4, 2024-06-12 diff --git a/internal/app/wwctl/overlay/edit/main.go b/internal/app/wwctl/overlay/edit/main.go index f6fbd2b3..07a41ce2 100644 --- a/internal/app/wwctl/overlay/edit/main.go +++ b/internal/app/wwctl/overlay/edit/main.go @@ -105,13 +105,6 @@ func CobraRunE(cmd *cobra.Command, args []string) error { os.Exit(1) } - tempFileReader, tempFileErr := os.Open(tempFile.Name()) - if tempFileErr != nil { - wwlog.Error("Unable to open %s: %s", tempFile.Name(), tempFileErr) - os.Exit(1) - } - defer tempFileReader.Close() - if fileInfo, err := os.Stat(tempFile.Name()); err != nil { wwlog.Error("Unable to stat %s: %s", tempFile.Name(), err) os.Exit(1) @@ -122,16 +115,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error { } } - destination, destinationErr := os.OpenFile(overlayFile, os.O_RDWR|os.O_CREATE, os.FileMode(PermMode)) - if destinationErr != nil { - wwlog.Error("Unable to update %s: %s", overlayFile, destinationErr) - os.Exit(1) - } - defer destination.Close() - - wwlog.Debug("Copy %s to %s", tempFileReader.Name(), destination.Name()) - if _, copyErr := io.Copy(destination, tempFileReader); copyErr != nil { - wwlog.Error("Unable to update %s: %s", destination.Name(), copyErr) + err := os.Rename(tempFile.Name(), overlayFile) + if err != nil { + wwlog.Error("Unable to update %s: %s", overlayFile, err) os.Exit(1) }