diff options
author | Jeremie Le Hen <jlh@FreeBSD.org> | 2017-10-06 08:43:14 +0000 |
---|---|---|
committer | Jeremie Le Hen <jlh@FreeBSD.org> | 2017-10-06 08:43:14 +0000 |
commit | e415aa284663746c8babbba2d3871d26980a8b8a (patch) | |
tree | 99adf8549d7fb6aaa4ee39278ce7861a12002115 /usr.bin | |
parent | ac63ac6859873627940b3583904083f9716c564d (diff) | |
download | src-e415aa284663746c8babbba2d3871d26980a8b8a.tar.gz src-e415aa284663746c8babbba2d3871d26980a8b8a.zip |
Remove rcmds.
If they are still needed, you can find them in the net/bsdrcmds port.
This was proposed June, 20th and approved by various committers [1].
They have been marked as deprecated on CURRENT in r320644 [2] on July, 4th.
Both stable/11 and release/11.1 contain the deprecation notice (thanks to
allanjude@).
Note that ruptime(1)/rwho(1)/rwhod(8) were initially thought to be part of
rcmds but this was a mistake and those are therefore NOT removed.
[1] https://lists.freebsd.org/pipermail/freebsd-arch/2017-June/018239.html
[2] https://svnweb.freebsd.org/base?view=revision&revision=320644
Reviewed by: bapt, brooks
Differential Revision: https://reviews.freebsd.org/D12573
Notes
Notes:
svn path=/head/; revision=324351
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/Makefile | 2 | ||||
-rw-r--r-- | usr.bin/rlogin/Makefile | 11 | ||||
-rw-r--r-- | usr.bin/rlogin/Makefile.depend | 18 | ||||
-rw-r--r-- | usr.bin/rlogin/rlogin.1 | 167 | ||||
-rw-r--r-- | usr.bin/rlogin/rlogin.c | 722 | ||||
-rw-r--r-- | usr.bin/rsh/Makefile | 12 | ||||
-rw-r--r-- | usr.bin/rsh/Makefile.depend | 19 | ||||
-rw-r--r-- | usr.bin/rsh/rsh.1 | 191 | ||||
-rw-r--r-- | usr.bin/rsh/rsh.c | 381 |
9 files changed, 0 insertions, 1523 deletions
diff --git a/usr.bin/Makefile b/usr.bin/Makefile index 03c0d500a5eb..cad3d5c2bd4d 100644 --- a/usr.bin/Makefile +++ b/usr.bin/Makefile @@ -250,8 +250,6 @@ SUBDIR.${MK_OPENSSL}+= chkey SUBDIR.${MK_OPENSSL}+= dc SUBDIR.${MK_OPENSSL}+= newkey SUBDIR.${MK_QUOTAS}+= quota -SUBDIR.${MK_RCMDS}+= rlogin -SUBDIR.${MK_RCMDS}+= rsh SUBDIR.${MK_SENDMAIL}+= vacation SUBDIR.${MK_TALK}+= talk SUBDIR.${MK_TELNET}+= telnet diff --git a/usr.bin/rlogin/Makefile b/usr.bin/rlogin/Makefile deleted file mode 100644 index 74ab15bd2972..000000000000 --- a/usr.bin/rlogin/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -# @(#)Makefile 8.1 (Berkeley) 7/19/93 -# $FreeBSD$ - -PROG= rlogin - -PACKAGE=rcmds - -BINOWN= root -BINMODE=4555 - -.include <bsd.prog.mk> diff --git a/usr.bin/rlogin/Makefile.depend b/usr.bin/rlogin/Makefile.depend deleted file mode 100644 index 3646e2e2b1af..000000000000 --- a/usr.bin/rlogin/Makefile.depend +++ /dev/null @@ -1,18 +0,0 @@ -# $FreeBSD$ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - gnu/lib/libgcc \ - include \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - - -.include <dirdeps.mk> - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/usr.bin/rlogin/rlogin.1 b/usr.bin/rlogin/rlogin.1 deleted file mode 100644 index 5b974382cc5c..000000000000 --- a/usr.bin/rlogin/rlogin.1 +++ /dev/null @@ -1,167 +0,0 @@ -.\" Copyright (c) 1983, 1990, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)rlogin.1 8.1 (Berkeley) 6/6/93 -.\" $FreeBSD$ -.\" -.Dd July 3, 2017 -.Dt RLOGIN 1 -.Os -.Sh NAME -.Nm rlogin -.Nd remote login -.Sh SYNOPSIS -.Ar rlogin -.Op Fl 468DEd -.Op Fl e Ar char -.Op Fl i Ar localname -.Op Fl l Ar username -.Ar host -.Sh DEPRECATION NOTICE -.Nm -is deprecated and will be removed from future versions of the -.Fx -base system. -If -.Nm -is still required, it can be installed from ports or packages -(net/bsdrcmds). -.Sh DESCRIPTION -The -.Nm -utility starts a terminal session on a remote host -.Ar host . -.Pp -The standard Berkeley -.Pa rhosts -authorization mechanism is used. -.Pp -The following options are available: -.Bl -tag -width flag -.It Fl 4 -Use IPv4 addresses only. -.It Fl 6 -Use IPv6 addresses only. -.It Fl 8 -Allow an eight-bit input data path at all times; otherwise -parity bits are stripped except when the remote side's stop and start -characters are other than -^S/^Q. -.It Fl D -Set the TCP_NODELAY socket option which can improve interactive response -at the expense of increased network load. -.It Fl E -Stop any character from being recognized as an escape character. -When used with the -.Fl 8 -option, this provides a completely transparent connection. -.It Fl d -Turn on socket debugging (see -.Xr setsockopt 2 ) -on the TCP sockets used for communication with the remote host. -.It Fl e -Allow user specification of the escape character, which is -.Dq ~ -by default. -This specification may be as a literal character, or as an octal -value in the form \ennn. -.It Fl i -Allow the caller to specify a different local name to be used -for authentication. -This option is restricted to processes with uid 0. -.It Fl l -Specify a different -.Ar username -for the remote login. -If this option is not specified, your local username will be used. -.El -.Pp -A line of the form -.Dq Ao escape char Ac Ns \&. -disconnects from the remote host. -Similarly, the line -.Dq Ao escape char Ac Ns ^Z -will suspend the -.Nm -session, and -.Dq Ao escape\ char Ac Ns Ao delayed-suspend\ char Ac -suspends the -send portion of the -.Nm -session, but allows output from the remote system. -By default, the tilde -.Pq Dq ~ -character is the escape character, and -normally control-Y -.Pq Dq ^Y -is the delayed-suspend character. -.Pp -All echoing takes place at the remote site, so that (except for delays) -the -.Nm -is transparent. -Flow control via ^S/^Q and flushing of input and output on interrupts -are handled properly. -.Sh ENVIRONMENT -The following environment variable is utilized by -.Nm : -.Bl -tag -width TERM -.It Ev TERM -Determines the user's terminal type. -.El -.Sh FILES -.Bl -tag -width /etc/hosts -compact -.It Pa /etc/hosts -.It Pa /etc/hosts.equiv -.It Ev $HOME Ns Pa /.rhosts -.El -.Sh SEE ALSO -.Xr login 1 , -.Xr rsh 1 , -.Xr telnet 1 , -.Xr setsockopt 2 , -.Xr ruserok 3 , -.Xr tty 4 , -.Xr hosts 5 , -.Xr hosts.equiv 5 , -.Xr rlogind 8 , -.Xr rshd 8 -.Sh HISTORY -The -.Nm -command appeared in -.Bx 4.2 . -.Pp -IPv6 support was added by WIDE/KAME project. -.Sh BUGS -The -.Nm -utility will be replaced by -.Xr telnet 1 -in the near future. -.Pp -More of the environment should be propagated. diff --git a/usr.bin/rlogin/rlogin.c b/usr.bin/rlogin/rlogin.c deleted file mode 100644 index 26692554958c..000000000000 --- a/usr.bin/rlogin/rlogin.c +++ /dev/null @@ -1,722 +0,0 @@ -/* - * Copyright (c) 1983, 1990, 1993 - * The Regents of the University of California. All rights reserved. - * Copyright (c) 2002 Networks Associates Technology, Inc. - * All rights reserved. - * - * Portions of this software were developed for the FreeBSD Project by - * ThinkSec AS and NAI Labs, the Security Research Division of Network - * Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 - * ("CBOSS"), as part of the DARPA CHATS research program. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static const char copyright[] = -"@(#) Copyright (c) 1983, 1990, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#if 0 -#ifndef lint -static const char sccsid[] = "@(#)rlogin.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ -#endif - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -/* - * rlogin - remote login - */ - -#include <sys/param.h> -#include <sys/ioctl.h> -#include <sys/socket.h> -#include <sys/time.h> -#include <sys/resource.h> -#include <sys/wait.h> - -#include <netinet/in.h> -#include <netinet/in_systm.h> -#include <netinet/ip.h> -#include <netinet/tcp.h> - -#include <err.h> -#include <errno.h> -#include <fcntl.h> -#include <netdb.h> -#include <paths.h> -#include <pwd.h> -#include <setjmp.h> -#include <termios.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - -#ifndef TIOCPKT_WINDOW -#define TIOCPKT_WINDOW 0x80 -#endif - -/* concession to Sun */ -#ifndef SIGUSR1 -#define SIGUSR1 30 -#endif - -static int eight, rem; -static struct termios deftty; - -static int family = PF_UNSPEC; - -static int noescape; -static u_char escapechar = '~'; - -#define get_window_size(fd, wp) ioctl(fd, TIOCGWINSZ, wp) -static struct winsize winsize; - -static void catch_child(int); -static void copytochild(int); -static _Noreturn void doit(long); -static _Noreturn void done(int); -static void echo(char); -static u_int getescape(const char *); -static void lostpeer(int); -static void mode(int); -static void msg(const char *); -static void oob(int); -static int reader(int); -static void sendwindow(void); -static void setsignal(int); -static void sigwinch(int); -static void stop(char); -static _Noreturn void usage(void); -static void writer(void); -static void writeroob(int); - -int -main(int argc, char *argv[]) -{ - struct passwd *pw; - struct servent *sp; - struct termios tty; - long omask; - int argoff, ch, dflag, Dflag, one; - uid_t uid; - char *host, *localname, *p, *user, term[1024] = "network"; - speed_t ospeed; - struct sockaddr_storage ss; - socklen_t sslen; - size_t len, len2; - int i; - - argoff = dflag = Dflag = 0; - one = 1; - host = localname = user = NULL; - - if ((p = strrchr(argv[0], '/'))) - ++p; - else - p = argv[0]; - - if (strcmp(p, "rlogin")) - host = p; - - /* handle "rlogin host flags" */ - if (!host && argc > 2 && argv[1][0] != '-') { - host = argv[1]; - argoff = 1; - } - -#define OPTIONS "468DEde:i:l:" - while ((ch = getopt(argc - argoff, argv + argoff, OPTIONS)) != -1) - switch(ch) { - case '4': - family = PF_INET; - break; - - case '6': - family = PF_INET6; - break; - - case '8': - eight = 1; - break; - case 'D': - Dflag = 1; - break; - case 'E': - noescape = 1; - break; - case 'd': - dflag = 1; - break; - case 'e': - noescape = 0; - escapechar = getescape(optarg); - break; - case 'i': - if (getuid() != 0) - errx(1, "-i user: permission denied"); - localname = optarg; - break; - case 'l': - user = optarg; - break; - case '?': - default: - usage(); - } - optind += argoff; - - /* if haven't gotten a host yet, do so */ - if (!host && !(host = argv[optind++])) - usage(); - - if (argv[optind]) - usage(); - - if (!(pw = getpwuid(uid = getuid()))) - errx(1, "unknown user id"); - if (!user) - user = pw->pw_name; - if (!localname) - localname = pw->pw_name; - - sp = NULL; - sp = getservbyname("login", "tcp"); - if (sp == NULL) - errx(1, "login/tcp: unknown service"); - - if ((p = getenv("TERM")) != NULL) - (void)strlcpy(term, p, sizeof(term)); - len = strlen(term); - if (len < (sizeof(term) - 1) && tcgetattr(0, &tty) == 0) { - /* start at 2 to include the / */ - for (ospeed = i = cfgetospeed(&tty), len2 = 2; i > 9; len2++) - i /= 10; - if (len + len2 < sizeof(term)) - (void)snprintf(term + len, len2 + 1, "/%d", ospeed); - } - - (void)get_window_size(0, &winsize); - - (void)signal(SIGPIPE, lostpeer); - /* will use SIGUSR1 for window size hack, so hold it off */ - omask = sigblock(sigmask(SIGURG) | sigmask(SIGUSR1)); - /* - * We set SIGURG and SIGUSR1 below so that an - * incoming signal will be held pending rather than being - * discarded. Note that these routines will be ready to get - * a signal by the time that they are unblocked below. - */ - (void)signal(SIGURG, copytochild); - (void)signal(SIGUSR1, writeroob); - - rem = rcmd_af(&host, sp->s_port, localname, user, term, 0, family); - - if (rem < 0) - exit(1); - - if (dflag && - setsockopt(rem, SOL_SOCKET, SO_DEBUG, &one, sizeof(one)) < 0) - warn("setsockopt"); - if (Dflag && - setsockopt(rem, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one)) < 0) - warn("setsockopt NODELAY (ignored)"); - - sslen = sizeof(ss); - one = IPTOS_LOWDELAY; - if (getsockname(rem, (struct sockaddr *)&ss, &sslen) == 0 && - ss.ss_family == AF_INET) { - if (setsockopt(rem, IPPROTO_IP, IP_TOS, (char *)&one, - sizeof(int)) < 0) - warn("setsockopt TOS (ignored)"); - } else - if (ss.ss_family == AF_INET) - warn("setsockopt getsockname failed"); - - (void)setuid(uid); - doit(omask); - /*NOTREACHED*/ -} - -static int child; - -static void -doit(long omask) -{ - - (void)signal(SIGINT, SIG_IGN); - setsignal(SIGHUP); - setsignal(SIGQUIT); - mode(1); - child = fork(); - if (child == -1) { - warn("fork"); - done(1); - } - if (child == 0) { - if (reader(omask) == 0) { - msg("connection closed"); - exit(0); - } - sleep(1); - msg("\007connection closed"); - exit(1); - } - - /* - * We may still own the socket, and may have a pending SIGURG (or might - * receive one soon) that we really want to send to the reader. When - * one of these comes in, the trap copytochild simply copies such - * signals to the child. We can now unblock SIGURG and SIGUSR1 - * that were set above. - */ - (void)sigsetmask(omask); - (void)signal(SIGCHLD, catch_child); - writer(); - msg("closed connection"); - done(0); -} - -/* trap a signal, unless it is being ignored. */ -static void -setsignal(int sig) -{ - int omask = sigblock(sigmask(sig)); - - if (signal(sig, exit) == SIG_IGN) - (void)signal(sig, SIG_IGN); - (void)sigsetmask(omask); -} - -static void -done(int status) -{ - int w, wstatus; - - mode(0); - if (child > 0) { - /* make sure catch_child does not snap it up */ - (void)signal(SIGCHLD, SIG_DFL); - if (kill(child, SIGKILL) >= 0) - while ((w = wait(&wstatus)) > 0 && w != child); - } - exit(status); -} - -static int dosigwinch; - -/* - * This is called when the reader process gets the out-of-band (urgent) - * request to turn on the window-changing protocol. - */ -/* ARGSUSED */ -static void -writeroob(int signo __unused) -{ - if (dosigwinch == 0) { - sendwindow(); - (void)signal(SIGWINCH, sigwinch); - } - dosigwinch = 1; -} - -/* ARGSUSED */ -static void -catch_child(int signo __unused) -{ - pid_t pid; - int status; - - for (;;) { - pid = wait3(&status, WNOHANG|WUNTRACED, NULL); - if (pid == 0) - return; - /* if the child (reader) dies, just quit */ - if (pid < 0 || (pid == child && !WIFSTOPPED(status))) - done(WTERMSIG(status) | WEXITSTATUS(status)); - } - /* NOTREACHED */ -} - -/* - * writer: write to remote: 0 -> line. - * ~. terminate - * ~^Z suspend rlogin process. - * ~<delayed-suspend char> suspend rlogin process, but leave reader alone. - */ -static void -writer(void) -{ - int bol, local, n; - char c; - - bol = 1; /* beginning of line */ - local = 0; - for (;;) { - n = read(STDIN_FILENO, &c, 1); - if (n <= 0) { - if (n < 0 && errno == EINTR) - continue; - break; - } - /* - * If we're at the beginning of the line and recognize a - * command character, then we echo locally. Otherwise, - * characters are echo'd remotely. If the command character - * is doubled, this acts as a force and local echo is - * suppressed. - */ - if (bol) { - bol = 0; - if (!noescape && c == escapechar) { - local = 1; - continue; - } - } else if (local) { - local = 0; - if (c == '.' || CCEQ(deftty.c_cc[VEOF], c)) { - echo(c); - break; - } - if (CCEQ(deftty.c_cc[VSUSP], c) || - CCEQ(deftty.c_cc[VDSUSP], c)) { - bol = 1; - echo(c); - stop(c); - continue; - } - if (c != escapechar) - (void)write(rem, &escapechar, 1); - } - - if (write(rem, &c, 1) == 0) { - msg("line gone"); - break; - } - bol = CCEQ(deftty.c_cc[VKILL], c) || - CCEQ(deftty.c_cc[VEOF], c) || - CCEQ(deftty.c_cc[VINTR], c) || - CCEQ(deftty.c_cc[VSUSP], c) || - c == '\r' || c == '\n'; - } -} - -static void -echo(char c) -{ - char *p; - char buf[8]; - - p = buf; - c &= 0177; - *p++ = escapechar; - if (c < ' ') { - *p++ = '^'; - *p++ = c + '@'; - } else if (c == 0177) { - *p++ = '^'; - *p++ = '?'; - } else - *p++ = c; - *p++ = '\r'; - *p++ = '\n'; - (void)write(STDOUT_FILENO, buf, p - buf); -} - -static void -stop(char cmdc) -{ - mode(0); - (void)signal(SIGCHLD, SIG_IGN); - (void)kill(CCEQ(deftty.c_cc[VSUSP], cmdc) ? 0 : getpid(), SIGTSTP); - (void)signal(SIGCHLD, catch_child); - mode(1); - sigwinch(0); /* check for size changes */ -} - -/* ARGSUSED */ -static void -sigwinch(int signo __unused) -{ - struct winsize ws; - - if (dosigwinch && get_window_size(0, &ws) == 0 && - bcmp(&ws, &winsize, sizeof(ws))) { - winsize = ws; - sendwindow(); - } -} - -/* - * Send the window size to the server via the magic escape - */ -static void -sendwindow(void) -{ - struct winsize ws; - char obuf[4 + sizeof (struct winsize)]; - - obuf[0] = 0377; - obuf[1] = 0377; - obuf[2] = 's'; - obuf[3] = 's'; - ws.ws_row = htons(winsize.ws_row); - ws.ws_col = htons(winsize.ws_col); - ws.ws_xpixel = htons(winsize.ws_xpixel); - ws.ws_ypixel = htons(winsize.ws_ypixel); - bcopy(&ws, obuf + 4, sizeof(ws)); - - (void)write(rem, obuf, sizeof(obuf)); -} - -/* - * reader: read from remote: line -> 1 - */ -#define READING 1 -#define WRITING 2 - -static jmp_buf rcvtop; -static int rcvcnt, rcvstate; -static pid_t ppid; -static char rcvbuf[8 * 1024]; - -/* ARGSUSED */ -static void -oob(int signo __unused) -{ - struct termios tty; - int atmark, n, rcvd; - char waste[BUFSIZ], mark; - - rcvd = 0; - while (recv(rem, &mark, 1, MSG_OOB) < 0) { - switch (errno) { - case EWOULDBLOCK: - /* - * Urgent data not here yet. It may not be possible - * to send it yet if we are blocked for output and - * our input buffer is full. - */ - if (rcvcnt < (int)sizeof(rcvbuf)) { - n = read(rem, rcvbuf + rcvcnt, - sizeof(rcvbuf) - rcvcnt); - if (n <= 0) - return; - rcvd += n; - } else { - n = read(rem, waste, sizeof(waste)); - if (n <= 0) - return; - } - continue; - default: - return; - } - } - if (mark & TIOCPKT_WINDOW) { - /* Let server know about window size changes */ - (void)kill(ppid, SIGUSR1); - } - if (!eight && (mark & TIOCPKT_NOSTOP)) { - (void)tcgetattr(0, &tty); - tty.c_iflag &= ~IXON; - (void)tcsetattr(0, TCSANOW, &tty); - } - if (!eight && (mark & TIOCPKT_DOSTOP)) { - (void)tcgetattr(0, &tty); - tty.c_iflag |= (deftty.c_iflag & IXON); - (void)tcsetattr(0, TCSANOW, &tty); - } - if (mark & TIOCPKT_FLUSHWRITE) { - (void)tcflush(1, TCIOFLUSH); - for (;;) { - if (ioctl(rem, SIOCATMARK, &atmark) < 0) { - warn("ioctl"); - 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, - * don't want it to restart. If we were reading, restart - * anyway. - */ - rcvcnt = 0; - longjmp(rcvtop, 1); - } - - /* oob does not do FLUSHREAD (alas!) */ - - /* - * If we filled the receive buffer while a read was pending, longjmp - * to the top to restart appropriately. Don't abort a pending write, - * however, or we won't know how much was written. - */ - if (rcvd && rcvstate == READING) - longjmp(rcvtop, 1); -} - -/* reader: read from remote: line -> 1 */ -static int -reader(int omask) -{ - int n, remaining; - char *bufp; - pid_t pid; - - pid = getpid(); - (void)signal(SIGTTOU, SIG_IGN); - (void)signal(SIGURG, oob); - (void)signal(SIGUSR1, oob); /* When propogating SIGURG from parent */ - ppid = getppid(); - (void)fcntl(rem, F_SETOWN, pid); - (void)setjmp(rcvtop); - (void)sigsetmask(omask); - bufp = rcvbuf; - for (;;) { - while ((remaining = rcvcnt - (bufp - rcvbuf)) > 0) { - rcvstate = WRITING; - n = write(STDOUT_FILENO, bufp, remaining); - if (n < 0) { - if (errno != EINTR) - return (-1); - continue; - } - bufp += n; - } - bufp = rcvbuf; - rcvcnt = 0; - rcvstate = READING; - - rcvcnt = read(rem, rcvbuf, sizeof (rcvbuf)); - if (rcvcnt == 0) - return (0); - if (rcvcnt < 0) { - if (errno == EINTR) - continue; - warn("read"); - return (-1); - } - } -} - -static void -mode(int f) -{ - struct termios tty; - - switch (f) { - case 0: - (void)tcsetattr(0, TCSANOW, &deftty); - break; - case 1: - (void)tcgetattr(0, &deftty); - tty = deftty; - /* This is loosely derived from sys/kern/tty_compat.c. */ - tty.c_lflag &= ~(ECHO|ICANON|ISIG|IEXTEN); - tty.c_iflag &= ~ICRNL; - tty.c_oflag &= ~OPOST; - tty.c_cc[VMIN] = 1; - tty.c_cc[VTIME] = 0; - if (eight) { - tty.c_iflag &= IXOFF; - tty.c_cflag &= ~(CSIZE|PARENB); - tty.c_cflag |= CS8; - } - (void)tcsetattr(0, TCSANOW, &tty); - break; - default: - return; - } -} - -/* ARGSUSED */ -static void -lostpeer(int signo __unused) -{ - (void)signal(SIGPIPE, SIG_IGN); - msg("\007connection closed"); - done(1); -} - -/* copy SIGURGs to the child process via SIGUSR1. */ -/* ARGSUSED */ -static void -copytochild(int signo __unused) -{ - (void)kill(child, SIGUSR1); -} - -static void -msg(const char *str) -{ - (void)fprintf(stderr, "rlogin: %s\r\n", str); -} - -static void -usage(void) -{ - (void)fprintf(stderr, - "usage: rlogin [-46%s]%s[-e char] [-i localname] [-l username] host\n", - "8DEd", " "); - exit(1); -} - -static u_int -getescape(const char *p) -{ - long val; - size_t len; - - if ((len = strlen(p)) == 1) /* use any single char, including '\' */ - return ((u_int)*p); - /* otherwise, \nnn */ - if (*p == '\\' && len >= 2 && len <= 4) { - val = strtol(++p, NULL, 8); - for (;;) { - if (!*++p) - return ((u_int)val); - if (*p < '0' || *p > '8') - break; - } - } - msg("illegal option value -- e"); - usage(); - /* NOTREACHED */ -} diff --git a/usr.bin/rsh/Makefile b/usr.bin/rsh/Makefile deleted file mode 100644 index 6883c7dcbb13..000000000000 --- a/usr.bin/rsh/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# @(#)Makefile 8.1 (Berkeley) 7/19/93 -# $FreeBSD$ - -PROG= rsh -CFLAGS+=-I${SRCTOP}/libexec/rlogind - -PACKAGE=rcmds - -BINOWN= root -BINMODE=4555 - -.include <bsd.prog.mk> diff --git a/usr.bin/rsh/Makefile.depend b/usr.bin/rsh/Makefile.depend deleted file mode 100644 index 58f9a3347b00..000000000000 --- a/usr.bin/rsh/Makefile.depend +++ /dev/null @@ -1,19 +0,0 @@ -# $FreeBSD$ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - gnu/lib/libgcc \ - include \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - lib/libutil \ - - -.include <dirdeps.mk> - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/usr.bin/rsh/rsh.1 b/usr.bin/rsh/rsh.1 deleted file mode 100644 index 56077cb5afaa..000000000000 --- a/usr.bin/rsh/rsh.1 +++ /dev/null @@ -1,191 +0,0 @@ -.\" Copyright (c) 1983, 1990, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)rsh.1 8.1 (Berkeley) 6/6/93 -.\" $FreeBSD$ -.\" -.Dd July 3, 2017 -.Dt RSH 1 -.Os -.Sh NAME -.Nm rsh -.Nd remote shell -.Sh SYNOPSIS -.Nm -.Op Fl 46dnN -.Op Fl l Ar username -.Op Fl t Ar timeout -.Ar host -.Op command -.Sh DEPRECATION NOTICE -.Nm -is deprecated and will be removed from future versions of the -.Fx -base system. -If -.Nm -is still required, it can be installed from ports or packages -(net/bsdrcmds). -.Sh DESCRIPTION -The -.Nm -utility executes -.Ar command -on -.Ar host . -.Pp -The -.Nm -utility copies its standard input to the remote command, the standard -output of the remote command to its standard output, and the -standard error of the remote command to its standard error. -Interrupt, quit and terminate signals are propagated to the remote -command; -.Nm -normally terminates when the remote command does. -The options are as follows: -.Bl -tag -width flag -.It Fl 4 -Use IPv4 addresses only. -.It Fl 6 -Use IPv6 addresses only. -.It Fl d -Turn on socket debugging (using -.Xr setsockopt 2 ) -on the -.Tn TCP -sockets used for communication with the remote host. -.It Fl l Ar username -Allow the remote -.Ar username -to be specified. -By default, the remote username is the same as the local username. -Authorization is determined -as in -.Xr rlogin 1 . -.It Fl N -Opposite to -.Fl n -option: do not send the "end of file" (EOF) indication for input stream -to the remote host. This option makes the -.Nm -utility compatible with protocol implementations confused by receiving -EOF, like some Cisco IOS versions. Disables -.Fl n . -.It Fl n -Redirect input from the special device -.Pa /dev/null -(see the -.Sx BUGS -section of this manual page). Disables -.Fl N . -.It Fl t Ar timeout -Allow a -.Ar timeout -to be specified (in seconds). -If no -data is sent or received in this time, -.Nm -will exit. -.El -.Pp -If no -.Ar command -is specified, you will be logged in on the remote host using -.Xr rlogin 1 . -.Pp -Shell metacharacters which are not quoted are interpreted on local machine, -while quoted metacharacters are interpreted on the remote machine. -For example, the command -.Pp -.Dl rsh otherhost cat remotefile >> localfile -.Pp -appends the remote file -.Ar remotefile -to the local file -.Ar localfile , -while -.Pp -.Dl rsh otherhost cat remotefile \&">>\&" other_remotefile -.Pp -appends -.Ar remotefile -to -.Ar other_remotefile . -.\" .Pp -.\" Many sites specify a large number of host names as commands in the -.\" directory /usr/hosts. -.\" If this directory is included in your search path, you can use the -.\" shorthand ``host command'' for the longer form ``rsh host command''. -.Sh FILES -.Bl -tag -width /etc/hosts -compact -.It Pa /etc/hosts -.El -.Sh SEE ALSO -.Xr rlogin 1 , -.Xr setsockopt 2 , -.Xr rcmd 3 , -.Xr ruserok 3 , -.Xr hosts 5 , -.Xr hosts.equiv 5 , -.Xr rlogind 8 , -.Xr rshd 8 -.Sh HISTORY -The -.Nm -command appeared in -.Bx 4.2 . -.Sh BUGS -If you are using -.Xr csh 1 -and put a -.Nm -in the background without redirecting its input away from the terminal, -it will block even if no reads are posted by the remote command. -If no input is desired you should redirect the input of -.Nm -to -.Pa /dev/null -using the -.Fl n -option. -.Pp -You cannot run an interactive command -(like -.Xr ee 1 -or -.Xr vi 1 ) -using -.Nm ; -use -.Xr rlogin 1 -instead. -.Pp -Stop signals stop the local -.Nm -process only; this is arguably wrong, but currently hard to fix for reasons -too complicated to explain here. diff --git a/usr.bin/rsh/rsh.c b/usr.bin/rsh/rsh.c deleted file mode 100644 index 4a39ccdaedd9..000000000000 --- a/usr.bin/rsh/rsh.c +++ /dev/null @@ -1,381 +0,0 @@ -/*- - * Copyright (c) 1983, 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * Copyright (c) 2002 Networks Associates Technology, Inc. - * All rights reserved. - * - * Portions of this software were developed for the FreeBSD Project by - * ThinkSec AS and NAI Labs, the Security Research Division of Network - * Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 - * ("CBOSS"), as part of the DARPA CHATS research program. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static const char copyright[] = -"@(#) Copyright (c) 1983, 1990, 1993, 1994\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#if 0 -#ifndef lint -static const char sccsid[] = "From: @(#)rsh.c 8.3 (Berkeley) 4/6/94"; -#endif /* not lint */ -#endif - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/param.h> -#include <sys/signal.h> -#include <sys/socket.h> -#include <sys/ioctl.h> -#include <sys/file.h> -#include <sys/time.h> - -#include <netinet/in.h> -#include <netdb.h> - -#include <err.h> -#include <errno.h> -#include <libutil.h> -#include <paths.h> -#include <pwd.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - -/* - * rsh - remote shell - */ -static int rfd2; - -static int family = PF_UNSPEC; -static char rlogin[] = "rlogin"; - -void connect_timeout(int); -char *copyargs(char * const *); -void sendsig(int); -void talk(int, int, long, pid_t, int, int); -void usage(void); - -int -main(int argc, char *argv[]) -{ - struct passwd const *pw; - struct servent const *sp; - long omask; - int argoff, asrsh, ch, dflag, nflag, Nflag, one, rem; - pid_t pid = 0; - uid_t uid; - char *args, *host, *p, *user; - int timeout = 0; - - argoff = asrsh = dflag = nflag = Nflag = 0; - one = 1; - host = user = NULL; - - /* if called as something other than "rsh", use it as the host name */ - if ((p = strrchr(argv[0], '/'))) - ++p; - else - p = argv[0]; - if (strcmp(p, "rsh")) - host = p; - else - asrsh = 1; - - /* handle "rsh host flags" */ - if (!host && argc > 2 && argv[1][0] != '-') { - host = argv[1]; - argoff = 1; - } - -#define OPTIONS "468LNde:l:nt:w" - while ((ch = getopt(argc - argoff, argv + argoff, OPTIONS)) != -1) - switch(ch) { - case '4': - family = PF_INET; - break; - - case '6': - family = PF_INET6; - break; - - case 'N': - Nflag = 1; - nflag = 0; - break; - case 'L': /* -8Lew are ignored to allow rlogin aliases */ - case 'e': - case 'w': - case '8': - break; - case 'd': - dflag = 1; - break; - case 'l': - user = optarg; - break; - case 'n': - nflag = 1; - Nflag = 0; - break; - case 't': - timeout = atoi(optarg); - break; - case '?': - default: - usage(); - } - optind += argoff; - - /* if haven't gotten a host yet, do so */ - if (!host && !(host = argv[optind++])) - usage(); - - /* if no further arguments, must have been called as rlogin. */ - if (!argv[optind]) { - if (asrsh) - *argv = rlogin; - execv(_PATH_RLOGIN, argv); - err(1, "can't exec %s", _PATH_RLOGIN); - } - - argc -= optind; - argv += optind; - - if (!(pw = getpwuid(uid = getuid()))) - errx(1, "unknown user id"); - if (!user) - user = pw->pw_name; - - args = copyargs(argv); - - sp = NULL; - if (sp == NULL) - sp = getservbyname("shell", "tcp"); - if (sp == NULL) - errx(1, "shell/tcp: unknown service"); - - if (timeout) { - signal(SIGALRM, connect_timeout); - alarm(timeout); - } - rem = rcmd_af(&host, sp->s_port, pw->pw_name, user, args, &rfd2, - family); - if (timeout) { - signal(SIGALRM, SIG_DFL); - alarm(0); - } - - if (rem < 0) - exit(1); - - if (rfd2 < 0) - errx(1, "can't establish stderr"); - if (dflag) { - if (setsockopt(rem, SOL_SOCKET, SO_DEBUG, &one, - sizeof(one)) < 0) - warn("setsockopt"); - if (setsockopt(rfd2, SOL_SOCKET, SO_DEBUG, &one, - sizeof(one)) < 0) - warn("setsockopt"); - } - - (void)setuid(uid); - omask = sigblock(sigmask(SIGINT)|sigmask(SIGQUIT)|sigmask(SIGTERM)); - if (signal(SIGINT, SIG_IGN) != SIG_IGN) - (void)signal(SIGINT, sendsig); - if (signal(SIGQUIT, SIG_IGN) != SIG_IGN) - (void)signal(SIGQUIT, sendsig); - if (signal(SIGTERM, SIG_IGN) != SIG_IGN) - (void)signal(SIGTERM, sendsig); - - if (!nflag) { - pid = fork(); - if (pid < 0) - err(1, "fork"); - } - else - (void)shutdown(rem, SHUT_WR); - - (void)ioctl(rfd2, FIONBIO, &one); - (void)ioctl(rem, FIONBIO, &one); - - talk(nflag, Nflag, omask, pid, rem, timeout); - - if (!nflag) - (void)kill(pid, SIGKILL); - exit(0); -} - -void -talk(int nflag, int Nflag, long omask, pid_t pid, int rem, int timeout) -{ - int cc, wc; - fd_set readfrom, ready, rembits; - char buf[BUFSIZ]; - const char *bp; - struct timeval tvtimeout; - int nfds, srval; - - if (!nflag && pid == 0) { - (void)close(rfd2); - -reread: errno = 0; - if ((cc = read(0, buf, sizeof buf)) <= 0) - goto done; - bp = buf; - -rewrite: - if (rem >= FD_SETSIZE) - errx(1, "descriptor too big"); - FD_ZERO(&rembits); - FD_SET(rem, &rembits); - nfds = rem + 1; - if (select(nfds, 0, &rembits, 0, 0) < 0) { - if (errno != EINTR) - err(1, "select"); - goto rewrite; - } - if (!FD_ISSET(rem, &rembits)) - goto rewrite; - wc = write(rem, bp, cc); - if (wc < 0) { - if (errno == EWOULDBLOCK) - goto rewrite; - goto done; - } - bp += wc; - cc -= wc; - if (cc == 0) - goto reread; - goto rewrite; -done: if (!Nflag) - (void)shutdown(rem, SHUT_WR); - exit(0); - } - - tvtimeout.tv_sec = timeout; - tvtimeout.tv_usec = 0; - - (void)sigsetmask(omask); - if (rfd2 >= FD_SETSIZE || rem >= FD_SETSIZE) - errx(1, "descriptor too big"); - FD_ZERO(&readfrom); - FD_SET(rfd2, &readfrom); - FD_SET(rem, &readfrom); - nfds = MAX(rfd2+1, rem+1); - do { - ready = readfrom; - if (timeout) { - srval = select(nfds, &ready, 0, 0, &tvtimeout); - } else { - srval = select(nfds, &ready, 0, 0, 0); - } - - if (srval < 0) { - if (errno != EINTR) - err(1, "select"); - continue; - } - if (srval == 0) - errx(1, "timeout reached (%d seconds)", timeout); - if (FD_ISSET(rfd2, &ready)) { - errno = 0; - cc = read(rfd2, buf, sizeof buf); - if (cc <= 0) { - if (errno != EWOULDBLOCK) - FD_CLR(rfd2, &readfrom); - } else - (void)write(STDERR_FILENO, buf, cc); - } - if (FD_ISSET(rem, &ready)) { - errno = 0; - cc = read(rem, buf, sizeof buf); - if (cc <= 0) { - if (errno != EWOULDBLOCK) - FD_CLR(rem, &readfrom); - } else - (void)write(STDOUT_FILENO, buf, cc); - } - } while (FD_ISSET(rfd2, &readfrom) || FD_ISSET(rem, &readfrom)); -} - -void -connect_timeout(int sig __unused) -{ - char message[] = "timeout reached before connection completed.\n"; - - write(STDERR_FILENO, message, sizeof(message) - 1); - _exit(1); -} - -void -sendsig(int sig) -{ - char signo; - - signo = sig; - (void)write(rfd2, &signo, 1); -} - -char * -copyargs(char * const *argv) -{ - int cc; - char *args, *p; - char * const *ap; - - cc = 0; - for (ap = argv; *ap; ++ap) - cc += strlen(*ap) + 1; - if (!(args = malloc((u_int)cc))) - err(1, NULL); - for (p = args, ap = argv; *ap; ++ap) { - (void)strcpy(p, *ap); - for (p = strcpy(p, *ap); *p; ++p); - if (ap[1]) - *p++ = ' '; - } - return (args); -} - -void -usage(void) -{ - - (void)fprintf(stderr, - "usage: rsh [-46Ndn] [-l username] [-t timeout] host [command]\n"); - exit(1); -} |