]> git.ipfire.org Git - thirdparty/rsync.git/commit
syscall: also use O_RESOLVE_BENEATH on FreeBSD and MacOS
authorAndrew Tridgell <andrew@tridgell.net>
Wed, 29 Apr 2026 22:44:11 +0000 (08:44 +1000)
committerAndrew Tridgell <andrew@tridgell.net>
Wed, 29 Apr 2026 23:30:31 +0000 (09:30 +1000)
commit7f60ec001a0be63b770707ec8b829524c3809a43
tree3fbec43006ce98cc0717204de3692fee0fa3e7c2
parent4fa7156ccdb2ad34b034d18fe2fd6cd79adef8a1
syscall: also use O_RESOLVE_BENEATH on FreeBSD and MacOS

FreeBSD and MacOS have O_RESOLVE_BENEATH as an openat() flag with the same
"must not escape dirfd" semantics as Linux's RESOLVE_BENEATH. The
kernel rejects ".." escapes, absolute symlinks, and symlinks whose
target lies outside dirfd, while still following symlinks that
resolve within it -- the same trade-off that fixes issue #715 on
Linux.

Add a parallel BSD path in secure_relative_open(), gated on
declared. Unlike Linux, BSD doesn't have the header/runtime split
where the symbol can exist without kernel support, so no runtime
fallback is needed: if the flag compiles in, the kernel honours it.

OpenBSD and NetBSD have no equivalent kernel primitive and continue
to use the existing per-component O_NOFOLLOW walk; issue #715
remains visible on those platforms (a userland resolver or
unveil(2)-based fence would be follow-up work).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
syscall.c