]> andersk Git - openssh.git/blobdiff - monitor_fdpass.c
- dtucker@cvs.openbsd.org 2004/02/27 22:44:56
[openssh.git] / monitor_fdpass.c
index 5401ea46656fce06a10c0ca45eb0bd982c1666ec..22b7882bd729f963f0df3c84dcdc2f93f4876c93 100644 (file)
@@ -24,7 +24,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: monitor_fdpass.c,v 1.2 2002/03/24 17:53:16 stevesk Exp $");
+RCSID("$OpenBSD: monitor_fdpass.c,v 1.4 2002/06/26 14:50:04 deraadt Exp $");
 
 #include <sys/uio.h>
 
@@ -38,7 +38,7 @@ mm_send_fd(int socket, int fd)
        struct msghdr msg;
        struct iovec vec;
        char ch = '\0';
-       int n;
+       ssize_t n;
 #ifndef HAVE_ACCRIGHTS_IN_MSGHDR
        char tmp[CMSG_SPACE(sizeof(int))];
        struct cmsghdr *cmsg;
@@ -64,14 +64,14 @@ mm_send_fd(int socket, int fd)
        msg.msg_iovlen = 1;
 
        if ((n = sendmsg(socket, &msg, 0)) == -1)
-               fatal("%s: sendmsg(%d): %s", __FUNCTION__, fd,
+               fatal("%s: sendmsg(%d): %s", __func__, fd,
                    strerror(errno));
        if (n != 1)
-               fatal("%s: sendmsg: expected sent 1 got %d",
-                   __FUNCTION__, n);
+               fatal("%s: sendmsg: expected sent 1 got %ld",
+                   __func__, (long)n);
 #else
        fatal("%s: UsePrivilegeSeparation=yes not supported",
-           __FUNCTION__);
+           __func__);
 #endif
 }
 
@@ -81,8 +81,9 @@ mm_receive_fd(int socket)
 #if defined(HAVE_RECVMSG) && (defined(HAVE_ACCRIGHTS_IN_MSGHDR) || defined(HAVE_CONTROL_IN_MSGHDR))
        struct msghdr msg;
        struct iovec vec;
+       ssize_t n;
        char ch;
-       int fd, n;
+       int fd;
 #ifndef HAVE_ACCRIGHTS_IN_MSGHDR
        char tmp[CMSG_SPACE(sizeof(int))];
        struct cmsghdr *cmsg;
@@ -102,24 +103,26 @@ mm_receive_fd(int socket)
 #endif
 
        if ((n = recvmsg(socket, &msg, 0)) == -1)
-               fatal("%s: recvmsg: %s", __FUNCTION__, strerror(errno));
+               fatal("%s: recvmsg: %s", __func__, strerror(errno));
        if (n != 1)
-               fatal("%s: recvmsg: expected received 1 got %d",
-                   __FUNCTION__, n);
+               fatal("%s: recvmsg: expected received 1 got %ld",
+                   __func__, (long)n);
 
 #ifdef HAVE_ACCRIGHTS_IN_MSGHDR
        if (msg.msg_accrightslen != sizeof(fd))
-               fatal("%s: no fd", __FUNCTION__);
+               fatal("%s: no fd", __func__);
 #else
        cmsg = CMSG_FIRSTHDR(&msg);
+#ifndef BROKEN_CMSG_TYPE
        if (cmsg->cmsg_type != SCM_RIGHTS)
-               fatal("%s: expected type %d got %d", __FUNCTION__,
+               fatal("%s: expected type %d got %d", __func__,
                    SCM_RIGHTS, cmsg->cmsg_type);
+#endif
        fd = (*(int *)CMSG_DATA(cmsg));
 #endif
        return fd;
 #else
        fatal("%s: UsePrivilegeSeparation=yes not supported",
-           __FUNCTION__);
+           __func__);
 #endif
 }
This page took 0.067995 seconds and 4 git commands to generate.