Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pkg/fsutil/fsutil_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package fsutil

import (
"errors"
"fmt"
"io/fs"
"os"
Expand All @@ -15,6 +16,11 @@ func chown(path string, stat fs.FileInfo) error {
gid := stat.Sys().(*syscall.Stat_t).Gid
err := os.Chown(path, int(uid), int(gid))
if err != nil {
// Permission denied is expected for non-root users
// The file is still created with correct permissions for the current user
if errors.Is(err, syscall.EPERM) || errors.Is(err, os.ErrPermission) {
return nil
}
return fmt.Errorf("failed to chown '%s' back to owner (%d, %d): %w", path, uid, gid, err)
}
return nil
Expand Down