Thanks for fixing all that. However, I'm not seeing the
fchownat+AT_SYMLINK_NOFOLLOW bug on cfarm220, which runs OpenBSD 7.7. I
can verify this even though I'm in only one group, as I can run the test
in /tmp where symlinks are in group wheel by default; see transcript below.
Do you see different behavior on OpenBSD 7.6? If not, evidently I
misunderstand the bug and it'd be helpful to fix Gnulib's documentation
to clear it up.
But if if the kernel is fixed in OpenBSD 7.7 I'd like to improve the
performance of Gnulib fchownat so it doesn't need to do the
fork/chdir/lchown dance on OpenBSD 7.7. Perhaps this could be done by
using /tmp in gnulib/m4/fchownat.m4's runtime test.
The whole thing is puzzling because I thought OpenBSD's fchownat (and
fchmodat) AT_SYMLINK_NOFOLLOW bug was fixed in OpenBSD 5.0 (2011), here:
https://github.com/openbsd/src/commit/a783d9412d72cac7ef5cf4b0e1d287ffc857ffef
and I don't see any changes between OpenBSD 7.6 and 7.7 that would
explain why fchownat+AT_SYMLINK_NOFOLLOW works for me on cfarm220 but
not for you on your OpenBSD 7.6 platform.
cfarm220$ cd /tmp
cfarm220$ cat u.c
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
int
main ()
{
return (fchownat (AT_FDCWD, "dangling", (uid_t)(-1), getgid (),
AT_SYMLINK_NOFOLLOW) != 0
&& errno == ENOENT);
}
cfarm220$ ln -s nowhere dangling
cfarm220$ cc u.c
cfarm220$ ls -l dangling
lrwxr-xr-x 1 eggert wheel 7 Sep 22 18:56 dangling -> nowhere
cfarm220$ ./a.out
cfarm220$ echo $?
0
cfarm220$ ls -l dangling
lrwxr-xr-x 1 eggert eggert 7 Sep 22 18:56 dangling -> nowhere
cfarm220$ uname -a
OpenBSD cfarm220.cfarm.net 7.7 GENERIC.MP#625 amd64