Maybe this is related to the problem (a wild guess really - the first thing that jumped out at me as being wrong). There are checks for __FreeBSD__ relating to euid/egid, and they may also need to check for __FreeBSD_kernel__
It is not needed, we have wrapper in our glibc sysdeps: /* The FreeBSD kernel do not test file access correctly when the process' real user ID is superuser. In particular, they always return zero when testing execute permissions without regard to whether the file is executable. While this behaviour conforms to POSIX.1-2008, it is explicitely discouraged. This wrapper implements the recommended behaviour. */ These check fo __FreeBSD__ are unrelated to the original problem. Petr