BSD 4_3 release
[unix-history] / usr / src / ucb / rsh.c
index fa22c72..3c84d7b 100644 (file)
@@ -1,6 +1,18 @@
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)rsh.c      4.8 83/06/10";
-#endif
+char copyright[] =
+"@(#) Copyright (c) 1983 Regents of the University of California.\n\
+ All rights reserved.\n";
+#endif not lint
+
+#ifndef lint
+static char sccsid[] = "@(#)rsh.c      5.4 (Berkeley) 8/28/85";
+#endif not lint
 
 #include <sys/types.h>
 #include <sys/socket.h>
 
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -74,13 +86,27 @@ another:
                goto another;
        }
        /*
                goto another;
        }
        /*
-        * Ignore the -e flag to allow aliases with rlogin
+        * Ignore the -L, -w, -e and -8 flags to allow aliases with rlogin
         * to work
         * to work
+        *
+        * There must be a better way to do this! -jmb
         */
         */
+       if (argc > 0 && !strncmp(*argv, "-L", 2)) {
+               argv++, argc--;
+               goto another;
+       }
+       if (argc > 0 && !strncmp(*argv, "-w", 2)) {
+               argv++, argc--;
+               goto another;
+       }
        if (argc > 0 && !strncmp(*argv, "-e", 2)) {
                argv++, argc--;
                goto another;
        }
        if (argc > 0 && !strncmp(*argv, "-e", 2)) {
                argv++, argc--;
                goto another;
        }
+       if (argc > 0 && !strncmp(*argv, "-8", 2)) {
+               argv++, argc--;
+               goto another;
+       }
        if (host == 0)
                goto usage;
        if (argv[0] == 0) {
        if (host == 0)
                goto usage;
        if (argv[0] == 0) {
@@ -120,16 +146,19 @@ another:
                exit(2);
        }
        if (options & SO_DEBUG) {
                exit(2);
        }
        if (options & SO_DEBUG) {
-               if (setsockopt(rem, SOL_SOCKET, SO_DEBUG, 0, 0) < 0)
+               if (setsockopt(rem, SOL_SOCKET, SO_DEBUG, &one, sizeof (one)) < 0)
                        perror("setsockopt (stdin)");
                        perror("setsockopt (stdin)");
-               if (setsockopt(rfd2, SOL_SOCKET, SO_DEBUG, 0, 0) < 0)
+               if (setsockopt(rfd2, SOL_SOCKET, SO_DEBUG, &one, sizeof (one)) < 0)
                        perror("setsockopt (stderr)");
        }
        (void) setuid(getuid());
        omask = sigblock(mask(SIGINT)|mask(SIGQUIT)|mask(SIGTERM));
                        perror("setsockopt (stderr)");
        }
        (void) setuid(getuid());
        omask = sigblock(mask(SIGINT)|mask(SIGQUIT)|mask(SIGTERM));
-       signal(SIGINT, sendsig);
-       signal(SIGQUIT, sendsig);
-       signal(SIGTERM, sendsig);
+       if (signal(SIGINT, SIG_IGN) != SIG_IGN)
+               signal(SIGINT, sendsig);
+       if (signal(SIGQUIT, SIG_IGN) != SIG_IGN)
+               signal(SIGQUIT, sendsig);
+       if (signal(SIGTERM, SIG_IGN) != SIG_IGN)
+               signal(SIGTERM, sendsig);
         pid = fork();
         if (pid < 0) {
                perror("fork");
         pid = fork();
         if (pid < 0) {
                perror("fork");
@@ -205,13 +234,13 @@ another:
        exit(0);
 usage:
        fprintf(stderr,
        exit(0);
 usage:
        fprintf(stderr,
-           "usage: rsh host [ -l login ] [ -p passwd ] command\n");
+           "usage: rsh host [ -l login ] [ -n ] command\n");
        exit(1);
 }
 
 sendsig(signo)
        exit(1);
 }
 
 sendsig(signo)
-       int signo;
+       char signo;
 {
 
 {
 
-       (void) write(rfd2, (char *)&signo, 1);
+       (void) write(rfd2, &signo, 1);
 }
 }