summaryrefslogtreecommitdiff
path: root/monitor_fdpass.c
diff options
context:
space:
mode:
Diffstat (limited to 'monitor_fdpass.c')
-rw-r--r--monitor_fdpass.c28
1 files changed, 3 insertions, 25 deletions
diff --git a/monitor_fdpass.c b/monitor_fdpass.c
index 3d3a78391..4b9a066bc 100644
--- a/monitor_fdpass.c
+++ b/monitor_fdpass.c
@@ -32,7 +32,6 @@
32#ifdef HAVE_SYS_UN_H 32#ifdef HAVE_SYS_UN_H
33#include <sys/un.h> 33#include <sys/un.h>
34#endif 34#endif
35#include <sys/utsname.h>
36 35
37#include <errno.h> 36#include <errno.h>
38#include <string.h> 37#include <string.h>
@@ -41,29 +40,6 @@
41#include "log.h" 40#include "log.h"
42#include "monitor_fdpass.h" 41#include "monitor_fdpass.h"
43 42
44static int
45cmsg_type_is_broken(void)
46{
47 static int broken_cmsg_type = -1;
48
49 if (broken_cmsg_type != -1)
50 return broken_cmsg_type;
51 else {
52 struct utsname uts;
53 /* If uname() fails, play safe and assume that cmsg_type
54 * isn't broken.
55 */
56 if (!uname(&uts) &&
57 strcmp(uts.sysname, "Linux") == 0 &&
58 strncmp(uts.release, "2.0.", 4) == 0)
59 broken_cmsg_type = 1;
60 else
61 broken_cmsg_type = 0;
62 }
63
64 return broken_cmsg_type;
65}
66
67int 43int
68mm_send_fd(int sock, int fd) 44mm_send_fd(int sock, int fd)
69{ 45{
@@ -176,11 +152,13 @@ mm_receive_fd(int sock)
176 return -1; 152 return -1;
177 } 153 }
178 154
179 if (!cmsg_type_is_broken() && cmsg->cmsg_type != SCM_RIGHTS) { 155#ifndef BROKEN_CMSG_TYPE
156 if (cmsg->cmsg_type != SCM_RIGHTS) {
180 error("%s: expected type %d got %d", __func__, 157 error("%s: expected type %d got %d", __func__,
181 SCM_RIGHTS, cmsg->cmsg_type); 158 SCM_RIGHTS, cmsg->cmsg_type);
182 return -1; 159 return -1;
183 } 160 }
161#endif
184 fd = (*(int *)CMSG_DATA(cmsg)); 162 fd = (*(int *)CMSG_DATA(cmsg));
185#endif 163#endif
186 return fd; 164 return fd;