Perhaps some OSs accept and ignore attempts to send a SCM_CREDS
message on a non-Unix socket, but GNU/kFreeBSD doesn't (and presumably
FreeBSD doesn't either).
Based on a patch by Svante Signell.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69492
Tested-by: Svante Signell
Reviewed-by: Chengwei Yang <chengwei.yang@intel.com>
|MSG_NOSIGNAL
#endif
);
-#else
- bytes_written = send (server_fd, buf, 1, 0
-#if HAVE_DECL_MSG_NOSIGNAL
- |MSG_NOSIGNAL
+
+ /* If we HAVE_CMSGCRED, the OS still might not let us sendmsg()
+ * with a SOL_SOCKET/SCM_CREDS message - for instance, FreeBSD
+ * only allows that on AF_UNIX. Try just doing a send() instead. */
+ if (bytes_written < 0 && errno == EINVAL)
#endif
- );
+ {
+ bytes_written = send (server_fd, buf, 1, 0
+#if HAVE_DECL_MSG_NOSIGNAL
+ |MSG_NOSIGNAL
#endif
+ );
+ }
if (bytes_written < 0 && errno == EINTR)
goto again;