There seems to be a bug in our fstat() implementation when called on a socket.
The st_uid member always seems to be 0.
NetBSD seems to have a similar problem see
https://gnu.emacs.bug.narkive.com/cAVl8Cff/bug-43002-27-1-emacsclient-does-not-like-owner-of-socket-on-netbsd

--- emacs-30.1/lib-src/emacsclient.c.orig
+++ emacs-30.1/lib-src/emacsclient.c
@@ -1221,7 +1221,7 @@
       struct stat st;
       if (fstat (dirfd, &st) != 0)
 	return errno;
-      if (st.st_uid != uid || (st.st_mode & (S_IWGRP | S_IWOTH)))
+      if (st.st_uid != uid || (st.st_uid == (uid_t)0) || (st.st_mode & (S_IWGRP | S_IWOTH)))
 	return -1;
 
       if (wdfd == -1)