Set execute permissions for intermediate directories

- Fixes: #1655

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
Jonathon Anderson
2025-02-05 20:03:38 -07:00
parent 36dca0dfa3
commit 6a250f3f96
3 changed files with 8 additions and 4 deletions

View File

@@ -51,11 +51,13 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) {
wwlog.Debug("Create dir: %s", parent)
srcInfo, err := os.Stat(source)
if err != nil {
return fmt.Errorf("could not retrieve the stat for file: %s", err)
return fmt.Errorf("could not retrieve the stat for file: %w", err)
}
err = os.MkdirAll(parent, srcInfo.Mode())
mode := srcInfo.Mode()
mode |= ((mode & 0444) >> 2) // add execute permission wherever srcInfo has read
err = os.MkdirAll(parent, mode)
if err != nil {
return fmt.Errorf("could not create parent dif: %s: %v", parent, err)
return fmt.Errorf("could not create parent dir: %s: %w", parent, err)
}
}
}