Source-Changes-HG archive

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

[src/netbsd-7]: src Pull up following revision(s) (requested by enami in tick...



details:   https://anonhg.NetBSD.org/src/rev/75d1ebf55cd3
branches:  netbsd-7
changeset: 798651:75d1ebf55cd3
user:      martin <martin%NetBSD.org@localhost>
date:      Mon Dec 01 13:43:13 2014 +0000

description:
Pull up following revision(s) (requested by enami in ticket #286):
        usr.bin/rsh/rsh.c: revision 1.38
        lib/libc/net/rcmd.c: revision 1.71
Changes done in rsh.c rev. 1.36 was incomplete.  As chuq pointed
in private mail, it broke rcp(1).
To achieve the documented behavior and to fix long standing incorrect
rsh(1) behavior which I've tried to fix in rev. 1.36, rcmd(1) should have
two operation mode; whether it should relay signal information on
auxiliary channel or not, depending on the argument `fd2p' passed to rcmd(3).
So, make rcmd(1) behave differntly depending on the environment variable and
set it when necessary in rcmd(3) according to how auxiliary channel
is set up by rcmd(3).

diffstat:

 lib/libc/net/rcmd.c |   7 ++++-
 usr.bin/rsh/rsh.c   |  54 +++++++++++++++++++++++++++-------------------------
 2 files changed, 33 insertions(+), 28 deletions(-)

diffs (173 lines):

diff -r 05c9d6238fc5 -r 75d1ebf55cd3 lib/libc/net/rcmd.c
--- a/lib/libc/net/rcmd.c       Mon Dec 01 13:30:37 2014 +0000
+++ b/lib/libc/net/rcmd.c       Mon Dec 01 13:43:13 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rcmd.c,v 1.69 2014/05/28 14:39:02 christos Exp $       */
+/*     $NetBSD: rcmd.c,v 1.69.2.1 2014/12/01 13:43:14 martin Exp $     */
 
 /*
  * Copyright (c) 1983, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)rcmd.c     8.3 (Berkeley) 3/26/94";
 #else
-__RCSID("$NetBSD: rcmd.c,v 1.69 2014/05/28 14:39:02 christos Exp $");
+__RCSID("$NetBSD: rcmd.c,v 1.69.2.1 2014/12/01 13:43:14 martin Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -464,6 +464,9 @@
                        const char *program;
                        program = strrchr(rshcmd, '/');
                        program = program ? program + 1 : rshcmd;
+                       if (fd2p)
+                               /* ask rcmd to relay signal information */
+                               setenv("RCMD_RELAY_SIGNAL", "YES", 1);
                        switch (af) {
                        case AF_INET:
                                execlp(rshcmd, program, "-4", "-l", remuser,
diff -r 05c9d6238fc5 -r 75d1ebf55cd3 usr.bin/rsh/rsh.c
--- a/usr.bin/rsh/rsh.c Mon Dec 01 13:30:37 2014 +0000
+++ b/usr.bin/rsh/rsh.c Mon Dec 01 13:43:13 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rsh.c,v 1.36 2014/06/08 02:44:15 enami Exp $   */
+/*     $NetBSD: rsh.c,v 1.36.2.1 2014/12/01 13:43:13 martin Exp $      */
 
 /*-
  * Copyright (c) 1983, 1990, 1993, 1994
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)rsh.c      8.4 (Berkeley) 4/29/95";
 #else
-__RCSID("$NetBSD: rsh.c,v 1.36 2014/06/08 02:44:15 enami Exp $");
+__RCSID("$NetBSD: rsh.c,v 1.36.2.1 2014/12/01 13:43:13 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -76,9 +76,7 @@
 static int sigs[] = { SIGINT, SIGTERM, SIGQUIT };
 
 static char   *copyargs(char **);
-#ifndef IN_RCMD
 static void    sendsig(int);
-#endif
 static int     checkfd(struct pollfd *, int);
 static void    talk(int, sigset_t *, pid_t, int);
 __dead static void     usage(void);
@@ -87,6 +85,7 @@
     const char *, const char *, int *);
 int     orcmd_af(char **, int, const char *,
     const char *, const char *, int *, int);
+static int     relay_signal;
 #endif
 
 int
@@ -98,7 +97,7 @@
        struct protoent *proto;
 
 #ifdef IN_RCMD
-       char    *locuser = 0, *loop;
+       char    *locuser = 0, *loop, *relay;
 #endif /* IN_RCMD */
        int argoff, asrsh, ch, dflag, nflag, one, rem;
        size_t i;
@@ -133,6 +132,8 @@
        }
 
 #ifdef IN_RCMD
+       if ((relay = getenv("RCMD_RELAY_SIGNAL")) && strcmp(relay, "YES") == 0)
+               relay_signal = 1;
        if ((loop = getenv("RCMD_LOOP")) && strcmp(loop, "YES") == 0)
                warnx("rcmd appears to be looping!");
 
@@ -152,7 +153,7 @@
        if ((name = strdup(pw->pw_name)) == NULL)
                err(1, "malloc");
        while ((ch = getopt(argc - argoff, argv + argoff, OPTIONS)) != -1)
-               switch(ch) {
+               switch (ch) {
                case '4':
                        family = AF_INET;
                        break;
@@ -267,16 +268,17 @@
 
        (void)sigprocmask(SIG_BLOCK, &nset, &oset);
 
-#ifndef IN_RCMD
-       for (i = 0; i < sizeof(sigs) / sizeof(sigs[0]); i++) {
-               struct sigaction sa;
+#ifdef IN_RCMD
+       if (!relay_signal)
+#endif
+               for (i = 0; i < sizeof(sigs) / sizeof(sigs[0]); i++) {
+                       struct sigaction sa;
 
-               if (sa.sa_handler != SIG_IGN) {
-                       sa.sa_handler = sendsig;
-                       (void)sigaction(sigs[i], &sa, NULL);
+                       if (sa.sa_handler != SIG_IGN) {
+                               sa.sa_handler = sendsig;
+                               (void)sigaction(sigs[i], &sa, NULL);
+                       }
                }
-       }
-#endif
 
        if (!nflag) {
                pid = fork();
@@ -389,17 +391,18 @@
                exit(0);
        }
 
-#ifdef IN_RCMD
-       fdp = &fds[0];
-       nfds = 3;
-       fds[0].events = POLLIN|POLLNVAL|POLLERR|POLLHUP;
-       fds[0].fd = 2;
-#else
-       (void)sigprocmask(SIG_SETMASK, oset, NULL);
        fdp = &fds[1];
        nfds = 2;
        fds[0].events = 0;
+#ifdef IN_RCMD
+       if (relay_signal) {
+               fdp = &fds[0];
+               nfds = 3;
+               fds[0].events = POLLIN|POLLNVAL|POLLERR|POLLHUP;
+               fds[0].fd = 2;
+       } else
 #endif
+               (void)sigprocmask(SIG_SETMASK, oset, NULL);
        fds[1].events = fds[2].events = POLLIN|POLLNVAL|POLLERR|POLLHUP;
        fds[1].fd = remerr;
        fds[2].fd = rem;
@@ -417,8 +420,10 @@
                        nfds--;
                        fds[1].events = 0;
 #ifdef IN_RCMD
-                       nfds--;
-                       fds[0].events = 0;
+                       if (relay_signal) {
+                               nfds--;
+                               fds[0].events = 0;
+                       }
 #endif
                        fdp = &fds[2];
                }
@@ -430,7 +435,6 @@
        while (nfds);
 }
 
-#ifndef IN_RCMD
 static void
 sendsig(int sig)
 {
@@ -439,8 +443,6 @@
        signo = sig;
        (void)write(remerr, &signo, 1);
 }
-#endif
-
 
 static char *
 copyargs(char **argv)



Home | Main Index | Thread Index | Old Index