summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
Diffstat (limited to 'sbin')
-rw-r--r--sbin/isakmpd/monitor.h4
-rw-r--r--sbin/isakmpd/monitor_fdpass.c31
2 files changed, 26 insertions, 9 deletions
diff --git a/sbin/isakmpd/monitor.h b/sbin/isakmpd/monitor.h
index ef67672af20..358b3ba54b0 100644
--- a/sbin/isakmpd/monitor.h
+++ b/sbin/isakmpd/monitor.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: monitor.h,v 1.1 2003/05/15 00:28:53 ho Exp $ */
+/* $OpenBSD: monitor.h,v 1.2 2003/05/17 17:39:26 ho Exp $ */
/*
* Copyright (c) 2003 Håkan Olsson. All rights reserved.
@@ -45,7 +45,7 @@ enum monitor_reqtypes
pid_t monitor_init (void);
void monitor_loop (int);
-void mm_send_fd (int, int);
+int mm_send_fd (int, int);
int mm_receive_fd (int);
struct stat;
diff --git a/sbin/isakmpd/monitor_fdpass.c b/sbin/isakmpd/monitor_fdpass.c
index 264a80a3944..6a5cfff228f 100644
--- a/sbin/isakmpd/monitor_fdpass.c
+++ b/sbin/isakmpd/monitor_fdpass.c
@@ -31,7 +31,7 @@
#include "log.h"
#include "monitor.h"
-void
+int
mm_send_fd (int socket, int fd)
{
struct msghdr msg;
@@ -56,9 +56,16 @@ mm_send_fd (int socket, int fd)
msg.msg_iovlen = 1;
if ((n = sendmsg (socket, &msg, 0)) == -1)
- log_error ("%s: sendmsg(%d)", __func__, fd);
+ {
+ log_error ("%s: sendmsg(%d)", __func__, fd);
+ return -1;
+ }
if (n != 1)
- log_error ("%s: sendmsg: expected sent 1 got %ld", __func__, (long)n);
+ {
+ log_error ("%s: sendmsg: expected sent 1 got %ld", __func__, (long)n);
+ return -1;
+ }
+ return 0;
}
int
@@ -81,14 +88,24 @@ mm_receive_fd (int socket)
msg.msg_controllen = sizeof tmp;
if ((n = recvmsg(socket, &msg, 0)) == -1)
- log_error ("%s: recvmsg", __func__);
+ {
+ log_error ("%s: recvmsg", __func__);
+ return -1;
+ }
if (n != 1)
- log_error ("%s: recvmsg: expected received 1 got %ld", __func__, (long)n);
+ {
+ log_error ("%s: recvmsg: expected received 1 got %ld", __func__,
+ (long)n);
+ return -1;
+ }
cmsg = CMSG_FIRSTHDR (&msg);
if (cmsg->cmsg_type != SCM_RIGHTS)
- log_error ("%s: expected type %d got %d", __func__, SCM_RIGHTS,
- cmsg->cmsg_type);
+ {
+ log_error ("%s: expected type %d got %d", __func__, SCM_RIGHTS,
+ cmsg->cmsg_type);
+ return -1;
+ }
fd = (*(int *)CMSG_DATA (cmsg));
return fd;
}