summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2013-09-18 17:51:53 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2014-01-06 15:49:41 +0000
commit3ca8a53e336a1a829bae93c70fe617af6493201a (patch)
tree502273f4dd0ba5f4b4eceb250703109d9edc950e
parent4e8032be4e6608163757b2ab926e44e5f784807d (diff)
downloaddbus-3ca8a53e336a1a829bae93c70fe617af6493201a.tar.gz
If sendmsg() with SCM_CREDS fails with EINVAL, retry with send()
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>
-rw-r--r--dbus/dbus-sysdeps-unix.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c
index 19f5ea30..c12f294e 100644
--- a/dbus/dbus-sysdeps-unix.c
+++ b/dbus/dbus-sysdeps-unix.c
@@ -1572,13 +1572,19 @@ write_credentials_byte (int server_fd,
|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;