Make prompt debug creation concurrency safe

This commit is contained in:
2026-08-02 13:11:41 +00:00
parent e0229d9c90
commit 1716702c99
4 changed files with 453 additions and 740 deletions

View File

@@ -269,7 +269,23 @@ func ensureSecureDirectory(path string) error {
info, err := os.Lstat(current)
if os.IsNotExist(err) {
if err := os.Mkdir(current, debugDirectoryMode); err != nil {
return err
if !os.IsExist(err) {
return err
}
info, err = os.Lstat(current)
if err != nil {
return err
}
if info.Mode()&os.ModeSymlink != 0 {
return fmt.Errorf("directory component %q must not be a symlink", current)
}
if !info.IsDir() {
return fmt.Errorf("directory component %q is not a directory", current)
}
if err := os.Chmod(current, debugDirectoryMode); err != nil {
return err
}
continue
}
if err := os.Chmod(current, debugDirectoryMode); err != nil {
return err