Merge pull request #1238 from JasonYangShadow/issue/1235

fix the issue that new files created via wwctl overlay edit have permission 755 && removing lines during wwctl overlay edit didn't work
This commit is contained in:
Jonathon Anderson
2024-07-03 18:08:47 -06:00
committed by GitHub
2 changed files with 5 additions and 17 deletions

View File

@@ -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

View File

@@ -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)
}