chunked: return better error for Dup failures

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano 2024-06-07 11:25:37 +02:00
parent 915afd193d
commit 4955d9b3f1
No known key found for this signature in database
GPG Key ID: 67E38F7A8BA21772
1 changed files with 5 additions and 1 deletions

View File

@ -347,7 +347,11 @@ func openFileUnderRootRaw(dirfd int, name string, flags uint64, mode os.FileMode
var fd int
var err error
if name == "" {
return unix.Dup(dirfd)
fd, err := unix.Dup(dirfd)
if err != nil {
return -1, fmt.Errorf("failed to duplicate file descriptor %d: %w", dirfd, err)
}
return fd, nil
}
if atomic.LoadInt32(&skipOpenat2) > 0 {
fd, err = openFileUnderRootFallback(dirfd, name, flags, mode)