diff options
| author | Jakob Unterwurzacher | 2026-11-11 21:04:58 +0100 |
|---|---|---|
| committer | Jakob Unterwurzacher | 2026-11-11 21:04:58 +0100 |
| commit | 91ab90b988b890f5f6a65bc02e61e516ab9e2eff (patch) | |
| tree | 49bcd1861ab468b4aa52ca4e377ff6aaaa7c5d59 /internal | |
| parent | d61448ec88f064eba898b566f68324859df5f7ac (diff) | |
syscallcompat: FchmodatNofollow: use Openat() to get O_CLOEXEC
FchmodatNofollow called syscall.Openat directly, so the O_PATH fd lacked
O_CLOEXEC and could leak to child processes (logger(1)), which is exactly
what our Openat() wrapper prevents. Use the wrapper, which also retries
on EINTR.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/syscallcompat/sys_linux.go | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/internal/syscallcompat/sys_linux.go b/internal/syscallcompat/sys_linux.go index ffa5a97..91f865a 100644 --- a/internal/syscallcompat/sys_linux.go +++ b/internal/syscallcompat/sys_linux.go @@ -106,7 +106,8 @@ func Dup3(oldfd int, newfd int, flags int) (err error) { func FchmodatNofollow(dirfd int, path string, mode uint32) (err error) { // Open handle to the filename (but without opening the actual file). // This succeeds even when we don't have read permissions to the file. - fd, err := syscall.Openat(dirfd, path, syscall.O_NOFOLLOW|O_PATH, 0) + // Openat() adds O_CLOEXEC so the fd does not leak to child processes. + fd, err := Openat(dirfd, path, syscall.O_NOFOLLOW|O_PATH, 0) if err != nil { return err } |
