sysdeps-unix: use MSG_NOSIGNAL when sending creds
authorScott James Remnant <scott@netsplit.com>
Thu, 16 Dec 2010 11:11:44 +0000 (11:11 +0000)
committerWill Thompson <will.thompson@collabora.co.uk>
Thu, 16 Dec 2010 11:12:44 +0000 (11:12 +0000)
Since SIGPIPE is no longer touched by default when MSG_NOSIGNAL is
available, it's extra-critical that all socket writes actually pass
that flag.

Signed-off-by: Will Thompson <will.thompson@collabora.co.uk>
dbus/dbus-sysdeps-unix.c

index 97a6a4a..8688ca2 100644 (file)
@@ -1493,9 +1493,17 @@ write_credentials_byte (int             server_fd,
  again:
 
 #if defined(HAVE_CMSGCRED)
-  bytes_written = sendmsg (server_fd, &msg, 0);
+  bytes_written = sendmsg (server_fd, &msg, 0
+#ifdef MSG_NOSIGNAL
+                           |MSG_NOSIGNAL
+#endif
+                           );
 #else
-  bytes_written = write (server_fd, buf, 1);
+  bytes_written = send (server_fd, buf, 1, 0
+#ifdef MSG_NOSIGNAL
+                        |MSG_NOSIGNAL
+#endif
+                        );
 #endif
 
   if (bytes_written < 0 && errno == EINTR)