Merge pull request #1932 from anderbubble/1886-preserve-overlay-edit-permissions
Preserve file permissions during wwctl overlay edit
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user