summaryrefslogtreecommitdiff
path: root/monitor_fdpass.c
diff options
context:
space:
mode:
Diffstat (limited to 'monitor_fdpass.c')
-rw-r--r--monitor_fdpass.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/monitor_fdpass.c b/monitor_fdpass.c
index 641ce721e..6508c9e47 100644
--- a/monitor_fdpass.c
+++ b/monitor_fdpass.c
@@ -27,10 +27,34 @@
27RCSID("$OpenBSD: monitor_fdpass.c,v 1.4 2002/06/26 14:50:04 deraadt Exp $"); 27RCSID("$OpenBSD: monitor_fdpass.c,v 1.4 2002/06/26 14:50:04 deraadt Exp $");
28 28
29#include <sys/uio.h> 29#include <sys/uio.h>
30#include <sys/utsname.h>
30 31
31#include "log.h" 32#include "log.h"
32#include "monitor_fdpass.h" 33#include "monitor_fdpass.h"
33 34
35static int
36cmsg_type_is_broken(void)
37{
38 static int broken_cmsg_type = -1;
39
40 if (broken_cmsg_type != -1)
41 return broken_cmsg_type;
42 else {
43 struct utsname uts;
44 /* If uname() fails, play safe and assume that cmsg_type
45 * isn't broken.
46 */
47 if (!uname(&uts) &&
48 strcmp(uts.sysname, "Linux") == 0 &&
49 strncmp(uts.release, "2.0.", 4) == 0)
50 broken_cmsg_type = 1;
51 else
52 broken_cmsg_type = 0;
53 }
54
55 return broken_cmsg_type;
56}
57
34void 58void
35mm_send_fd(int socket, int fd) 59mm_send_fd(int socket, int fd)
36{ 60{
@@ -113,7 +137,7 @@ mm_receive_fd(int socket)
113 fatal("%s: no fd", __func__); 137 fatal("%s: no fd", __func__);
114#else 138#else
115 cmsg = CMSG_FIRSTHDR(&msg); 139 cmsg = CMSG_FIRSTHDR(&msg);
116 if (cmsg->cmsg_type != SCM_RIGHTS) 140 if (!cmsg_type_is_broken() && cmsg->cmsg_type != SCM_RIGHTS)
117 fatal("%s: expected type %d got %d", __func__, 141 fatal("%s: expected type %d got %d", __func__,
118 SCM_RIGHTS, cmsg->cmsg_type); 142 SCM_RIGHTS, cmsg->cmsg_type);
119 fd = (*(int *)CMSG_DATA(cmsg)); 143 fd = (*(int *)CMSG_DATA(cmsg));