Question regarding alignment patch

Darren Tucker dtucker at zip.com.au
Wed Jul 30 10:34:06 EST 2008


On Tue, Jul 29, 2008 at 04:53:38PM +0200, Dag-Erling Smørgrav wrote:
> Contrast
> 
> http://cvsweb.mindrot.org/index.cgi/openssh/monitor_fdpass.c?r1=1.23;r2=1.24
> with
> http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/monitor_fdpass.c.diff?r1=1.14&r2=1.15
> 
> The original replaces cmsgbuf.tmp with cmsgbuf.buf, while the -portable
> version *adds* cmsgbuf.buf but retains cmsgbuf.tmp.
> 
> I assume this was an oversight, and cmsgbuf.tmp should be removed?

Yes it certainly looks like an oversight.

On a somewhat related note, it seems that some platforms (NetBSD 1.6
at least) fail the recvmsg with EAGAIN making multiplexing fail with:

mm_receive_fd: recvmsg: Resource temporarily unavailable

Retrying on EAGAIN makes this work (well, pass the regress tests
anyway).

Index: monitor_fdpass.c
===================================================================
RCS file: /usr/local/src/security/openssh/cvs/openssh/monitor_fdpass.c,v
retrieving revision 1.26
diff -u -p -r1.26 monitor_fdpass.c
--- monitor_fdpass.c	27 Mar 2008 00:01:15 -0000	1.26
+++ monitor_fdpass.c	30 Jul 2008 00:31:16 -0000
@@ -51,7 +51,6 @@ mm_send_fd(int sock, int fd)
 #ifndef HAVE_ACCRIGHTS_IN_MSGHDR
 	union {
 		struct cmsghdr hdr;
-		char tmp[CMSG_SPACE(sizeof(int))];
 		char buf[CMSG_SPACE(sizeof(int))];
 	} cmsgbuf;
 	struct cmsghdr *cmsg;
@@ -76,7 +75,9 @@ mm_send_fd(int sock, int fd)
 	msg.msg_iov = &vec;
 	msg.msg_iovlen = 1;
 
-	if ((n = sendmsg(sock, &msg, 0)) == -1) {
+	while ((n = sendmsg(sock, &msg, 0)) == -1 && errno == EAGAIN)
+		;
+	if (n == -1) {
 		error("%s: sendmsg(%d): %s", __func__, fd,
 		    strerror(errno));
 		return -1;
@@ -124,7 +125,9 @@ mm_receive_fd(int sock)
 	msg.msg_controllen = sizeof(cmsgbuf.buf);
 #endif
 
-	if ((n = recvmsg(sock, &msg, 0)) == -1) {
+	while ((n = recvmsg(sock, &msg, 0)) == -1 && errno == EAGAIN)
+		;
+	if (n == -1) {
 		error("%s: recvmsg: %s", __func__, strerror(errno));
 		return -1;
 	}

-- 
Darren Tucker (dtucker at zip.com.au)
GPG key 8FF4FA69 / D9A3 86E9 7EEE AF4B B2D4  37C9 C982 80C7 8FF4 FA69
    Good judgement comes with experience. Unfortunately, the experience
usually comes from bad judgement.


More information about the openssh-unix-dev mailing list