From 33fa3493e5bc3dd14817bb34f5c9a3bbba4bc734 Mon Sep 17 00:00:00 2001 From: piaip Date: Tue, 9 Jun 2009 16:32:28 +0000 Subject: * sendmsg() with ancillary on Linux seems like requiring unix domain socket original path, even if the socket was already opened. git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4531 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- common/sys/net.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'common') diff --git a/common/sys/net.c b/common/sys/net.c index 883b4d48..232d5bb1 100644 --- a/common/sys/net.c +++ b/common/sys/net.c @@ -258,7 +258,7 @@ int send_remote_fd(int tunnel, int fd) } // return: remote fd (-1 if error) -int recv_remote_fd(int tunnel) +int recv_remote_fd(int tunnel, const char *tunnel_path) { struct msghdr msg; struct iovec iov; @@ -267,6 +267,7 @@ int recv_remote_fd(int tunnel) int connfd = -1; char ccmsg[CMSG_SPACE(sizeof(connfd))]; struct cmsghdr *cmsg; + struct sockaddr_un sun = {0}; iov.iov_base = &dummy; iov.iov_len = 1; @@ -274,6 +275,12 @@ int recv_remote_fd(int tunnel) msg.msg_iovlen = 1; msg.msg_control = ccmsg; msg.msg_controllen = sizeof(ccmsg); + // XXX assigning msg_name here again is stupid, + // but seems like Linux need it (while FreeBSD does not...) + msg.msg_name = &sun; + msg.msg_namelen = sizeof(sun); + sun.sun_family = AF_UNIX; + strlcpy(sun.sun_path, tunnel_path, sizeof(sun.sun_path)); do { // ignore EINTR -- cgit v1.2.3