Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/rlogin revert rev 1.45:



details:   https://anonhg.NetBSD.org/src/rev/62f9bdb8854a
branches:  trunk
changeset: 985012:62f9bdb8854a
user:      chs <chs%NetBSD.org@localhost>
date:      Tue Aug 03 23:21:07 2021 +0000

description:
revert rev 1.45:
  "PR/54435: Adjust for new kernel behavior of soreceive(9) clearing MSG_OOB"

That change was trying to make rlogin work again after the SIOCATMARK ioctl
was broken, but that kernel bug has now been fixed, so the original rlogin code
now works again.  Further, the changed rlogin code actually did the wrong thing,
by treating reception of the MSG_OOB byte as meaning that we are now
"at the mark", but that is not true... we are "at the mark" only when
we have reached the point in the stream where the MSG_OOB byte was originally,
as indicated by SIOCATMARK.  So going back to the previous code seems best
all around.  ok'd by christos.

diffstat:

 usr.bin/rlogin/rlogin.c |  38 ++++++++++++++------------------------
 1 files changed, 14 insertions(+), 24 deletions(-)

diffs (82 lines):

diff -r 3bc7bc6cd068 -r 62f9bdb8854a usr.bin/rlogin/rlogin.c
--- a/usr.bin/rlogin/rlogin.c   Tue Aug 03 23:12:14 2021 +0000
+++ b/usr.bin/rlogin/rlogin.c   Tue Aug 03 23:21:07 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rlogin.c,v 1.47 2020/05/03 16:32:16 christos Exp $     */
+/*     $NetBSD: rlogin.c,v 1.48 2021/08/03 23:21:07 chs Exp $  */
 
 /*
  * Copyright (c) 1983, 1990, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)rlogin.c   8.4 (Berkeley) 4/29/95";
 #else
-__RCSID("$NetBSD: rlogin.c,v 1.47 2020/05/03 16:32:16 christos Exp $");
+__RCSID("$NetBSD: rlogin.c,v 1.48 2021/08/03 23:21:07 chs Exp $");
 #endif
 #endif /* not lint */
 
@@ -577,34 +577,16 @@
 static ssize_t rcvcnt, rcvstate;
 static char rcvbuf[8 * 1024];
 
-static int
-recvx(int fd, void *buf, size_t len, int flags, int *msgflags)
-{
-       struct msghdr msg;
-       struct iovec iov;
-       int error;
-
-       memset(&msg, 0, sizeof(msg));
-       msg.msg_iov = &iov;
-       iov.iov_base = buf;
-       iov.iov_len = len;
-       error = recvmsg(fd, &msg, flags);
-       if (error)
-               return error;
-       *msgflags = msg.msg_flags;
-       return 0;
-}
-
 static void
 oob(int signo)
 {
        struct termios tty;
-       int atmark = 0;
+       int atmark;
        ssize_t n, rcvd;
        char waste[BUFSIZ], mark;
 
        rcvd = 0;
-       while (recvx(rem, &mark, 1, MSG_OOB, &atmark) == -1) {
+       while (recv(rem, &mark, 1, MSG_OOB) == -1) {
                switch (errno) {
                case EWOULDBLOCK:
                        /*
@@ -628,7 +610,6 @@
                        return;
                }
        }
-       atmark &= MSG_OOB;
        if (mark & TIOCPKT_WINDOW) {
                /* Let server know about window size changes */
                (void)kill(ppid, SIGUSR1);
@@ -645,8 +626,17 @@
        }
        if (mark & TIOCPKT_FLUSHWRITE) {
                (void)tcflush(1, TCIOFLUSH);
-               if (!atmark)
+               for (;;) {
+                       if (ioctl(rem, SIOCATMARK, &atmark) < 0) {
+                               warn("ioctl SIOCATMARK (ignored)");
+                               break;
+                       }
+                       if (atmark)
+                               break;
                        n = read(rem, waste, sizeof (waste));
+                       if (n <= 0)
+                               break;
+               }
                /*
                 * Don't want any pending data to be output, so clear the recv
                 * buffer.  If we were hanging on a write when interrupted,



Home | Main Index | Thread Index | Old Index