diff options
author | Colin Watson <cjwatson@debian.org> | 2005-01-04 13:07:27 +0000 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2005-01-04 13:07:27 +0000 |
commit | fd0f611b70a83d80fe8793af785542ee5541b7cd (patch) | |
tree | bededd22bb7eeec52e20083237ab7e4113445a16 /monitor_fdpass.c | |
parent | c44fe9a5b9d3db96a7249b04d915f17e4a3a3b04 (diff) | |
parent | ebd2ce335af5861020c79fddb1ae35c03bf036cf (diff) |
Merge 3.9p1 to the trunk.
Diffstat (limited to 'monitor_fdpass.c')
-rw-r--r-- | monitor_fdpass.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/monitor_fdpass.c b/monitor_fdpass.c index 6508c9e47..f384c174c 100644 --- a/monitor_fdpass.c +++ b/monitor_fdpass.c | |||
@@ -24,7 +24,7 @@ | |||
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include "includes.h" | 26 | #include "includes.h" |
27 | RCSID("$OpenBSD: monitor_fdpass.c,v 1.4 2002/06/26 14:50:04 deraadt Exp $"); | 27 | RCSID("$OpenBSD: monitor_fdpass.c,v 1.6 2004/08/13 02:51:48 djm Exp $"); |
28 | 28 | ||
29 | #include <sys/uio.h> | 29 | #include <sys/uio.h> |
30 | #include <sys/utsname.h> | 30 | #include <sys/utsname.h> |
@@ -56,7 +56,7 @@ cmsg_type_is_broken(void) | |||
56 | } | 56 | } |
57 | 57 | ||
58 | void | 58 | void |
59 | mm_send_fd(int socket, int fd) | 59 | mm_send_fd(int sock, int fd) |
60 | { | 60 | { |
61 | #if defined(HAVE_SENDMSG) && (defined(HAVE_ACCRIGHTS_IN_MSGHDR) || defined(HAVE_CONTROL_IN_MSGHDR)) | 61 | #if defined(HAVE_SENDMSG) && (defined(HAVE_ACCRIGHTS_IN_MSGHDR) || defined(HAVE_CONTROL_IN_MSGHDR)) |
62 | struct msghdr msg; | 62 | struct msghdr msg; |
@@ -87,7 +87,7 @@ mm_send_fd(int socket, int fd) | |||
87 | msg.msg_iov = &vec; | 87 | msg.msg_iov = &vec; |
88 | msg.msg_iovlen = 1; | 88 | msg.msg_iovlen = 1; |
89 | 89 | ||
90 | if ((n = sendmsg(socket, &msg, 0)) == -1) | 90 | if ((n = sendmsg(sock, &msg, 0)) == -1) |
91 | fatal("%s: sendmsg(%d): %s", __func__, fd, | 91 | fatal("%s: sendmsg(%d): %s", __func__, fd, |
92 | strerror(errno)); | 92 | strerror(errno)); |
93 | if (n != 1) | 93 | if (n != 1) |
@@ -100,7 +100,7 @@ mm_send_fd(int socket, int fd) | |||
100 | } | 100 | } |
101 | 101 | ||
102 | int | 102 | int |
103 | mm_receive_fd(int socket) | 103 | mm_receive_fd(int sock) |
104 | { | 104 | { |
105 | #if defined(HAVE_RECVMSG) && (defined(HAVE_ACCRIGHTS_IN_MSGHDR) || defined(HAVE_CONTROL_IN_MSGHDR)) | 105 | #if defined(HAVE_RECVMSG) && (defined(HAVE_ACCRIGHTS_IN_MSGHDR) || defined(HAVE_CONTROL_IN_MSGHDR)) |
106 | struct msghdr msg; | 106 | struct msghdr msg; |
@@ -126,7 +126,7 @@ mm_receive_fd(int socket) | |||
126 | msg.msg_controllen = sizeof(tmp); | 126 | msg.msg_controllen = sizeof(tmp); |
127 | #endif | 127 | #endif |
128 | 128 | ||
129 | if ((n = recvmsg(socket, &msg, 0)) == -1) | 129 | if ((n = recvmsg(sock, &msg, 0)) == -1) |
130 | fatal("%s: recvmsg: %s", __func__, strerror(errno)); | 130 | fatal("%s: recvmsg: %s", __func__, strerror(errno)); |
131 | if (n != 1) | 131 | if (n != 1) |
132 | fatal("%s: recvmsg: expected received 1 got %ld", | 132 | fatal("%s: recvmsg: expected received 1 got %ld", |
@@ -137,6 +137,8 @@ mm_receive_fd(int socket) | |||
137 | fatal("%s: no fd", __func__); | 137 | fatal("%s: no fd", __func__); |
138 | #else | 138 | #else |
139 | cmsg = CMSG_FIRSTHDR(&msg); | 139 | cmsg = CMSG_FIRSTHDR(&msg); |
140 | if (cmsg == NULL) | ||
141 | fatal("%s: no message header", __func__); | ||
140 | if (!cmsg_type_is_broken() && cmsg->cmsg_type != SCM_RIGHTS) | 142 | if (!cmsg_type_is_broken() && cmsg->cmsg_type != SCM_RIGHTS) |
141 | fatal("%s: expected type %d got %d", __func__, | 143 | fatal("%s: expected type %d got %d", __func__, |
142 | SCM_RIGHTS, cmsg->cmsg_type); | 144 | SCM_RIGHTS, cmsg->cmsg_type); |