]> andersk Git - openssh.git/blobdiff - monitor_fdpass.c
- (tim) [defines.h] Fix regression in long password support on OpenServer 6.
[openssh.git] / monitor_fdpass.c
index 9d319ac1aa92406a7d2d723734b089cd1eeede23..a572302e89b1f48c44c461fd19b1d618cce1cfb2 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: monitor_fdpass.c,v 1.10 2006/07/11 20:07:25 stevesk Exp $ */
+/* $OpenBSD: monitor_fdpass.c,v 1.13 2007/09/04 03:21:03 djm Exp $ */
 /*
  * Copyright 2001 Niels Provos <provos@citi.umich.edu>
  * All rights reserved.
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/uio.h>
+#ifdef HAVE_SYS_UN_H
+#include <sys/un.h>
+#endif
 
 #include <errno.h>
+#include <string.h>
+#include <stdarg.h>
 
 #include "log.h"
 #include "monitor_fdpass.h"
 
-void
+int
 mm_send_fd(int sock, int fd)
 {
 #if defined(HAVE_SENDMSG) && (defined(HAVE_ACCRIGHTS_IN_MSGHDR) || defined(HAVE_CONTROL_IN_MSGHDR))
@@ -67,15 +72,21 @@ mm_send_fd(int sock, int fd)
        msg.msg_iov = &vec;
        msg.msg_iovlen = 1;
 
-       if ((n = sendmsg(sock, &msg, 0)) == -1)
-               fatal("%s: sendmsg(%d): %s", __func__, fd,
+       if ((n = sendmsg(sock, &msg, 0)) == -1) {
+               error("%s: sendmsg(%d): %s", __func__, fd,
                    strerror(errno));
-       if (n != 1)
-               fatal("%s: sendmsg: expected sent 1 got %ld",
+               return -1;
+       }
+
+       if (n != 1) {
+               error("%s: sendmsg: expected sent 1 got %ld",
                    __func__, (long)n);
+               return -1;
+       }
+       return 0;
 #else
-       fatal("%s: UsePrivilegeSeparation=yes not supported",
-           __func__);
+       error("%s: file descriptor passing not supported", __func__);
+       return -1;
 #endif
 }
 
@@ -106,29 +117,39 @@ mm_receive_fd(int sock)
        msg.msg_controllen = sizeof(tmp);
 #endif
 
-       if ((n = recvmsg(sock, &msg, 0)) == -1)
-               fatal("%s: recvmsg: %s", __func__, strerror(errno));
-       if (n != 1)
-               fatal("%s: recvmsg: expected received 1 got %ld",
+       if ((n = recvmsg(sock, &msg, 0)) == -1) {
+               error("%s: recvmsg: %s", __func__, strerror(errno));
+               return -1;
+       }
+       if (n != 1) {
+               error("%s: recvmsg: expected received 1 got %ld",
                    __func__, (long)n);
+               return -1;
+       }
 
 #ifdef HAVE_ACCRIGHTS_IN_MSGHDR
-       if (msg.msg_accrightslen != sizeof(fd))
-               fatal("%s: no fd", __func__);
+       if (msg.msg_accrightslen != sizeof(fd)) {
+               error("%s: no fd", __func__);
+               return -1;
+       }
 #else
        cmsg = CMSG_FIRSTHDR(&msg);
-       if (cmsg == NULL)
-               fatal("%s: no message header", __func__);
+       if (cmsg == NULL) {
+               error("%s: no message header", __func__);
+               return -1;
+       }
 #ifndef BROKEN_CMSG_TYPE
-       if (cmsg->cmsg_type != SCM_RIGHTS)
-               fatal("%s: expected type %d got %d", __func__,
+       if (cmsg->cmsg_type != SCM_RIGHTS) {
+               error("%s: expected type %d got %d", __func__,
                    SCM_RIGHTS, cmsg->cmsg_type);
+               return -1;
+       }
 #endif
        fd = (*(int *)CMSG_DATA(cmsg));
 #endif
        return fd;
 #else
-       fatal("%s: UsePrivilegeSeparation=yes not supported",
-           __func__);
+       error("%s: file descriptor passing not supported", __func__);
+       return -1;
 #endif
 }
This page took 0.098683 seconds and 4 git commands to generate.