mirror of
git://anongit.mindrot.org/openssh.git
synced 2025-04-11 03:51:57 +00:00
- stevesk@cvs.openbsd.org 2002/03/24 17:53:16
[monitor_fdpass.c] minor cleanup and more error checking; ok markus@
This commit is contained in:
parent
fcad1c92c9
commit
31ee7aeb15
@ -13,6 +13,9 @@
|
|||||||
- stevesk@cvs.openbsd.org 2002/03/24 17:27:03
|
- stevesk@cvs.openbsd.org 2002/03/24 17:27:03
|
||||||
[kexgex.c]
|
[kexgex.c]
|
||||||
typo; ok markus@
|
typo; ok markus@
|
||||||
|
- stevesk@cvs.openbsd.org 2002/03/24 17:53:16
|
||||||
|
[monitor_fdpass.c]
|
||||||
|
minor cleanup and more error checking; ok markus@
|
||||||
|
|
||||||
20020324
|
20020324
|
||||||
- (stevesk) [session.c] disable LOGIN_NEEDS_TERM until we are sure
|
- (stevesk) [session.c] disable LOGIN_NEEDS_TERM until we are sure
|
||||||
@ -8027,4 +8030,4 @@
|
|||||||
- Wrote replacements for strlcpy and mkdtemp
|
- Wrote replacements for strlcpy and mkdtemp
|
||||||
- Released 1.0pre1
|
- Released 1.0pre1
|
||||||
|
|
||||||
$Id: ChangeLog,v 1.1981 2002/03/26 02:20:06 mouring Exp $
|
$Id: ChangeLog,v 1.1982 2002/03/26 02:36:29 mouring Exp $
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
RCSID("$OpenBSD: monitor_fdpass.c,v 1.1 2002/03/18 17:27:22 provos Exp $");
|
RCSID("$OpenBSD: monitor_fdpass.c,v 1.2 2002/03/24 17:53:16 stevesk Exp $");
|
||||||
|
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
|
|
||||||
@ -36,7 +36,8 @@ mm_send_fd(int socket, int fd)
|
|||||||
{
|
{
|
||||||
struct msghdr msg;
|
struct msghdr msg;
|
||||||
struct iovec vec;
|
struct iovec vec;
|
||||||
char ch;
|
char ch = '\0';
|
||||||
|
int n;
|
||||||
#ifndef HAVE_ACCRIGHTS_IN_MSGHDR
|
#ifndef HAVE_ACCRIGHTS_IN_MSGHDR
|
||||||
char tmp[CMSG_SPACE(sizeof(int))];
|
char tmp[CMSG_SPACE(sizeof(int))];
|
||||||
struct cmsghdr *cmsg;
|
struct cmsghdr *cmsg;
|
||||||
@ -61,8 +62,12 @@ mm_send_fd(int socket, int fd)
|
|||||||
msg.msg_iov = &vec;
|
msg.msg_iov = &vec;
|
||||||
msg.msg_iovlen = 1;
|
msg.msg_iovlen = 1;
|
||||||
|
|
||||||
if (sendmsg(socket, &msg, 0) == -1)
|
if ((n = sendmsg(socket, &msg, 0)) == -1)
|
||||||
fatal("%s: sendmsg(%d)", __FUNCTION__, fd);
|
fatal("%s: sendmsg(%d): %s", __FUNCTION__, fd,
|
||||||
|
strerror(errno));
|
||||||
|
if (n != 1)
|
||||||
|
fatal("%s: sendmsg: expected sent 1 got %d",
|
||||||
|
__FUNCTION__, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -71,11 +76,10 @@ mm_receive_fd(int socket)
|
|||||||
struct msghdr msg;
|
struct msghdr msg;
|
||||||
struct iovec vec;
|
struct iovec vec;
|
||||||
char ch;
|
char ch;
|
||||||
|
int fd, n;
|
||||||
#ifndef HAVE_ACCRIGHTS_IN_MSGHDR
|
#ifndef HAVE_ACCRIGHTS_IN_MSGHDR
|
||||||
char tmp[CMSG_SPACE(sizeof(int))];
|
char tmp[CMSG_SPACE(sizeof(int))];
|
||||||
struct cmsghdr *cmsg;
|
struct cmsghdr *cmsg;
|
||||||
#else
|
|
||||||
int fd;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
memset(&msg, 0, sizeof(msg));
|
memset(&msg, 0, sizeof(msg));
|
||||||
@ -91,18 +95,21 @@ mm_receive_fd(int socket)
|
|||||||
msg.msg_controllen = sizeof(tmp);
|
msg.msg_controllen = sizeof(tmp);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (recvmsg(socket, &msg, 0) == -1)
|
if ((n = recvmsg(socket, &msg, 0)) == -1)
|
||||||
fatal("%s: recvmsg", __FUNCTION__);
|
fatal("%s: recvmsg: %s", __FUNCTION__, strerror(errno));
|
||||||
|
if (n != 1)
|
||||||
|
fatal("%s: recvmsg: expected received 1 got %d",
|
||||||
|
__FUNCTION__, n);
|
||||||
|
|
||||||
#ifdef HAVE_ACCRIGHTS_IN_MSGHDR
|
#ifdef HAVE_ACCRIGHTS_IN_MSGHDR
|
||||||
if (msg.msg_accrightslen != sizeof(fd))
|
if (msg.msg_accrightslen != sizeof(fd))
|
||||||
fatal("%s: no fd", __FUNCTION__);
|
fatal("%s: no fd", __FUNCTION__);
|
||||||
return fd;
|
|
||||||
#else
|
#else
|
||||||
cmsg = CMSG_FIRSTHDR(&msg);
|
cmsg = CMSG_FIRSTHDR(&msg);
|
||||||
if (cmsg->cmsg_type != SCM_RIGHTS)
|
if (cmsg->cmsg_type != SCM_RIGHTS)
|
||||||
fatal("%s: expected type %d got %d", __FUNCTION__,
|
fatal("%s: expected type %d got %d", __FUNCTION__,
|
||||||
SCM_RIGHTS, cmsg->cmsg_type);
|
SCM_RIGHTS, cmsg->cmsg_type);
|
||||||
return (*(int *)CMSG_DATA(cmsg));
|
fd = (*(int *)CMSG_DATA(cmsg));
|
||||||
#endif
|
#endif
|
||||||
|
return fd;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user