From: David van Moolenbroek Date: Tue, 14 Feb 2017 18:53:43 +0000 (+0000) Subject: Retire MINIX rget(1), rput(1) X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/doc/mandoc.1.ps?a=commitdiff_plain;h=47ebcd22bd20e7db1de163070e47167b13d69f54;p=minix.git Retire MINIX rget(1), rput(1) Change-Id: I70e3ec9281275730c589fb7683801dc1ca584cab --- diff --git a/distrib/sets/lists/minix-base/mi b/distrib/sets/lists/minix-base/mi index fb222e5bf..4f18697fe 100644 --- a/distrib/sets/lists/minix-base/mi +++ b/distrib/sets/lists/minix-base/mi @@ -492,11 +492,11 @@ ./usr/bin/repartition minix-base ./usr/bin/restore minix-base ./usr/bin/rev minix-base -./usr/bin/rget minix-base +./usr/bin/rget minix-base obsolete ./usr/bin/rlogin minix-base ./usr/bin/rmd160 minix-base ./usr/bin/rotate minix-base -./usr/bin/rput minix-base +./usr/bin/rput minix-base obsolete ./usr/bin/rsh minix-base ./usr/bin/rz minix-base ./usr/bin/screendump minix-base diff --git a/distrib/sets/lists/minix-debug/mi b/distrib/sets/lists/minix-debug/mi index 7cec8ea88..5b9adefcb 100644 --- a/distrib/sets/lists/minix-debug/mi +++ b/distrib/sets/lists/minix-debug/mi @@ -391,7 +391,7 @@ ./usr/libdata/debug/usr/bin/renice.debug minix-debug debug ./usr/libdata/debug/usr/bin/repartition.debug minix-debug debug ./usr/libdata/debug/usr/bin/rev.debug minix-debug debug -./usr/libdata/debug/usr/bin/rget.debug minix-debug debug +./usr/libdata/debug/usr/bin/rget.debug minix-debug debug,obsolete ./usr/libdata/debug/usr/bin/rlogin.debug minix-debug debug ./usr/libdata/debug/usr/bin/rsh.debug minix-debug debug ./usr/libdata/debug/usr/bin/rz.debug minix-debug debug diff --git a/distrib/sets/lists/minix-man/mi b/distrib/sets/lists/minix-man/mi index a179a81c8..453d78079 100644 --- a/distrib/sets/lists/minix-man/mi +++ b/distrib/sets/lists/minix-man/mi @@ -323,7 +323,7 @@ ./usr/man/man1/repeat.1 minix-man ./usr/man/man1/return.1 minix-man obsolete ./usr/man/man1/rev.1 minix-man -./usr/man/man1/rget.1 minix-man +./usr/man/man1/rget.1 minix-man obsolete ./usr/man/man1/rlogin.1 minix-man ./usr/man/man1/rm.1 minix-man ./usr/man/man1/rmd160.1 minix-man diff --git a/minix/commands/Makefile b/minix/commands/Makefile index a07ea26f4..a5c6b0cea 100644 --- a/minix/commands/Makefile +++ b/minix/commands/Makefile @@ -19,7 +19,7 @@ SUBDIR= at backup \ prep printroot \ profile progressbar \ ramdisk rawspeed readclock \ - remsync rget rlogin \ + remsync rlogin \ rotate setup \ slip spell sprofalyze sprofdiff srccrc \ svrctl swifi synctree sysenv \ diff --git a/minix/commands/rget/Makefile b/minix/commands/rget/Makefile deleted file mode 100644 index d29d927b7..000000000 --- a/minix/commands/rget/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -PROG= rget - -LINKS+= ${BINDIR}/rget ${BINDIR}/rput - -.include diff --git a/minix/commands/rget/rget.1 b/minix/commands/rget/rget.1 deleted file mode 100644 index e0b1c09d3..000000000 --- a/minix/commands/rget/rget.1 +++ /dev/null @@ -1,169 +0,0 @@ -.TH RGET 1 -.SH NAME -rget, rput \- network pipe -.SH SYNOPSIS -.B rget -.RB [ \-lcio ] -.RB [ \-h -.IR host ] -.I key -.RI [ command -.RI [ arg " ...]]" -.br -.B rput -.RB [ \-lcio ] -.RB [ \-h -.IR host ] -.I key -.RI [ command -.RI [ arg " ...]]" -.SH DESCRIPTION -.de SP -.if t .sp 0.4 -.if n .sp -.. -.de XS \" Example start -.SP -.in +4m -.nf -.. -.de XE \" Example end -.fi -.in -4m -.SP -.. -.B Rput -and -.B rget -set up a TCP/IP channel to connect two processes together. They can looked -upon as a remote pipe. Consider the well known method of copying a -directory tree with -.BR tar : -.XS -(cd src && tar cf \- .) | (cd dst && tar xfp \-) -.XE -If the directory tree is to be copied to another machine then one can -use the following command on the source machine: -.XS -cd src && rput foo tar cf \- . -.XE -And on the destination machine: -.XS -cd dst && rget \-h \fIsource-machine\fP foo tar xfp \- -.XE -The -.I key -is either a port number in C style decimal, octal or hex, or a random string -that is hashed to a port number. -.B Rput -uses this port number to open a TCP socket that -.B rget -using the same -.I key -can connect to. -It is customary to start -.B rput -first, although -.B rget -will retry for 2 minutes trying to connect to the remote -.BR rput. -.PP -After the connection is established either utility will execute -.I command -with the given arguments with the TCP channel as either standard output -(rput) or standard input (rget). -.B Rput -and -.B rget -do not stay around for the command to finish, they simply overlay themselves -with the command. If no command is given then they will themselves copy -standard input into the TCP channel (rput), or output from the TCP channel -to standard output (rget). So these two commands have the same effect: -.XS -rput foo tar cf \- . -tar cf \- . | rput foo -.XE -The second form has two processes copying data instead of just -.B tar -directly writing its output into the TCP channel. There is a better way to -waste processor cycles, namely to save bandwidth: -.XS -cd src && tar cf \- . | rput foo compress -.SP -cd dst && rget \-h \fIsource-machine\fP foo uncompress | tar xfp \- -.XE -.B Rput -and -.B rget -can be very useful in the windowed environments we use these days. The -.B rput -can be typed into the window that has a shell running on one machine, and -the -.B rget -is then typed into the window that has a shell running on another machine. -This is easier than one of the two well known forms that use -.BR rsh : -.XS -cd src && tar cf \- . | rsh dest-machine "cd dst && tar xfp \-" -.SP -cd dst && rsh source-machine "cd src && tar cf \- ." | tar xfp \- -.XE -Especially since these forms require that one must be able to use -.B rsh -without a password, which may not always be the case. -.PP -The -.I key -can be any string of characters of any length. If its a number then it is -used directly as the port number. Otherwise the characters binary values -are multiplied together, bit 15 is set and the result is truncated to 16 -bits to make it a port number in the anonymous port space (32768 \- 65535). -The port may be in-use on the source machine, but there is a small chance -of this happening, and if so simply choose another key. (So if you use -.B rput -and -.B rget -in an unattended script then you should reserve a port number, otherwise -a connection can't be guaranteed.) -.SH OPTIONS -.TP -.B \-lcio -These flags allow one to reverse the default connect/listen or input/output -direction of -.BR rput -and -.BR rget . -Reversing the connection may be necessary if one of the two systems filters -out connections to unknown ports. For example: -.XS -rput \-c \-h \fIdestination-machine\fP foo tar cf \- . -.SP -rget \-l foo tar xfp \- -.XE -The -.B \-io -options can be used to choose which of standard input or output should be -tied to the socket. It's even possible to tie both input and output to the -socket with -.BR \-io, -but only when executing a command. This is probably the only use for these -options, because one usually chooses the direction with the mnemonic put/get -names. -.TP -.BI \-h " host" -The name of the remote host that a connection must be made to. It must be -used with the program that is doing the connect, usually -.BR rget . -This option is currently mandatory. The author is planning to increase -ease of use by letting the programs find each other with UDP broadcasts -or multicasts. -.SH "SEE ALSO" -.BR rsh (1). -.SH DIAGNOSTICS -.TP 5 -rput: Address in use -If the port computed out of -.I key -is already in use. -.SH AUTHOR -Kees J. Bot diff --git a/minix/commands/rget/rget.c b/minix/commands/rget/rget.c deleted file mode 100644 index 0c35736b3..000000000 --- a/minix/commands/rget/rget.c +++ /dev/null @@ -1,290 +0,0 @@ -/* rget 2.6 - remote pipe Author: Kees J. Bot - * 20 Mar 1989 - * - * here$ ... | rput key there$ rget -h here key | ... - * here$ rput key command ... there$ rget -h here key command ... - * - * (Once my first try at network programming, completely reworked by now.) - */ -#define nil ((void*)0) -#include -#include -#include -#include -#include -#include -#include -#include -#if __minix -#include -#include -#include -#include -#include -#include -#include -#include -#include -#else -#include -#include -#include -#endif - -static char *name; -static int iflag, oflag, hflag, lflag, cflag; /* -iolch? */ -static char *host; /* Argument to -h. */ -static struct hostent *hent; /* gethostbyname(host) */ -static char *key; /* key (port) */ -static char **cmdv; /* command [arg ...] */ - -static void fatal(const char *label) -{ - int err= errno; - - fprintf(stderr, "%s: %s: %s\n", name, label, strerror(err)); - exit(1); -} - -static unsigned name2port(char *n) -{ - char *end; - unsigned port; - - port= strtoul(n, &end, 0); - if (end == n || *end != 0) { - port= 1; - while (*n != 0) port *= (*n++ & 0xFF); - port |= 0x8000; - } - return htons(port & 0xFFFF); -} - -static void usage(void) -{ - fprintf(stderr, - "Usage: %s [-lcio] [-h host] key [command [arg ...]]\n" - "\t-l: Open TCP socket and listen (default for rput)\n" - "\t-c: Connect to a remote TCP socket (default for rget)\n" - "\t-i: Tie standard input to the TCP stream (default for rget)\n" - "\t-o: Tie standard output to the TCP stream (default for rput)\n" - "\t-io: Bidirectional!\n" - "\tkey: A word to hash into a port number, or simply a port number\n", - name); - exit(1); -} - -int main(int argc, char **argv) -{ - int i, s; - - if ((name= strrchr(argv[0], '/')) == nil) name= argv[0]; else name++; - - if (strcmp(name, "rget") != 0 && strcmp(name, "rput") != 0) { - fprintf(stderr, "Don't know what to do if you call me '%s'\n", name); - exit(1); - } - - i= 1; - while (i < argc && argv[i][0] == '-') { - char *opt= argv[i++]+1; - - if (opt[0] == '-' && opt[1] == 0) break; /* -- */ - - while (*opt != 0) switch (*opt++) { - case 'l': lflag= 1; break; - case 'c': cflag= 1; break; - case 'i': iflag= 1; break; - case 'o': oflag= 1; break; - case 'h': - hflag= 1; - if (*opt == 0) { - if (i == argc) usage(); - opt= argv[i++]; - } - host= opt; - opt= ""; - break; - default: usage(); break; - } - } - - if (i == argc) usage(); - key= argv[i++]; - cmdv= argv + i; - - /* Defaults. */ - if (!lflag && !cflag) { - if (name[1] == 'p') lflag= 1; - if (name[1] == 'g') cflag= 1; - } - if (!iflag && !oflag) { - if (name[1] == 'g') iflag= 1; - if (name[1] == 'p') oflag= 1; - } - - /* Constraints. */ - if (lflag && cflag) { - fprintf(stderr, "%s: -c and -l don't mix\n", name); - usage(); - } - if (cflag && !hflag) { - fprintf(stderr, "%s: -c requires a host name given with -h\n", name); - usage(); - } - if (lflag && hflag) { - fprintf(stderr, "%s: -l does not require a host name given with -h\n", - name); - usage(); - } - if (iflag && oflag && cmdv[0] == nil) { - fprintf(stderr, "%s: -io requires that a command is given\n", name); - usage(); - } - - if (hflag) { - if ((hent= gethostbyname(host)) == nil) { - fprintf(stderr, "%s: %s: Name lookup failed\n", name, host); - exit(1); - } - } - - s= -1; - if (lflag) { - /* We need to listen and wait. (We're "rput", most likely.) */ -#if __minix - char *tcp_device; - struct nwio_tcpconf tcpconf; - struct nwio_tcpcl tcplistenopt; - - if ((tcp_device= getenv("TCP_DEVICE")) == nil) tcp_device= "/dev/tcp"; - if ((s= open(tcp_device, O_RDWR)) < 0) fatal(tcp_device); - - tcpconf.nwtc_flags= - NWTC_EXCL | NWTC_LP_SET | NWTC_UNSET_RA | NWTC_UNSET_RP; - tcpconf.nwtc_locport= name2port(key); - if (ioctl(s, NWIOSTCPCONF, &tcpconf) < 0) fatal("NWIOSTCPCONF"); - - tcplistenopt.nwtcl_flags= 0; - if (ioctl(s, NWIOTCPLISTEN, &tcplistenopt) < 0) fatal("NWIOTCPLISTEN"); -#else - int sa; - struct sockaddr_in channel; - static int on= 1; - - if ((s= socket(AF_INET, SOCK_STREAM, IPPROTO_TCP))<0) fatal("socket()"); - - (void) setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *) &on, - sizeof(on)); - memset(&channel, 0, sizeof(channel)); - channel.sin_family= AF_INET; - channel.sin_addr.s_addr= htonl(INADDR_ANY); - channel.sin_port= name2port(key); - if (bind(s, (struct sockaddr *) &channel, sizeof(channel)) < 0) - fatal("bind()"); - - if (listen(s, 0) < 0) fatal("listen()"); - - if ((sa= accept(s, nil, nil)) < 0) fatal("accept()"); - close(s); - s= sa; -#endif - } - - if (cflag) { - /* Connect to the remote end. (We're "rget", most likely.) */ -#if __minix - int n; - char *tcp_device; - nwio_tcpconf_t tcpconf; - nwio_tcpcl_t tcpconnopt; - - if ((tcp_device= getenv("TCP_DEVICE")) == nil) tcp_device= "/dev/tcp"; - - n=60; - for (;;) { - if ((s= open(tcp_device, O_RDWR)) < 0) fatal(tcp_device); - - tcpconf.nwtc_flags= NWTC_LP_SEL | NWTC_SET_RA | NWTC_SET_RP; - memcpy(&tcpconf.nwtc_remaddr, hent->h_addr, - sizeof(tcpconf.nwtc_remaddr)); - tcpconf.nwtc_remport= name2port(key); - if (ioctl(s, NWIOSTCPCONF, &tcpconf) < 0) fatal("NWIOSTCPCONF"); - - tcpconnopt.nwtcl_flags= 0; - if (ioctl(s, NWIOTCPCONN, &tcpconnopt) == 0) break; - - if (--n > 0) sleep(2); else fatal("NWIOTCPCONN"); - close(s); - } -#else - int n; - struct sockaddr_in channel; - - n=60; - for (;;) { - if ((s= socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) - fatal("socket()"); - - memset(&channel, 0, sizeof(channel)); - channel.sin_family= AF_INET; - memcpy(&channel.sin_addr.s_addr, hent->h_addr, - sizeof(channel.sin_addr.s_addr)); - channel.sin_port= name2port(key); - if (connect(s, (struct sockaddr *) &channel, - sizeof(channel)) >= 0) break; - - if (--n > 0) sleep(2); else fatal("connect()"); - close(s); - } -#endif - } - - if (cmdv[0] != nil) { - /* A command is given, so execute it with standard input (rget), - * standard output (rput) or both (-io) tied to the TCP stream. - */ - if (iflag) dup2(s, 0); - if (oflag) dup2(s, 1); - close(s); - - execvp(cmdv[0], cmdv); - fatal(cmdv[0]); - } else { - /* Without a command we have to copy bytes ourselves, probably to or - * from a command that is connected to us with a pipe. (The original - * function of rput/rget, a remote pipe.) - */ - int fi, fo; - int n; - char buf[8192]; - - if (iflag) { - fi= s; - fo= 1; - } else { - fi= 0; - fo= s; - } - - while ((n= read(fi, buf, sizeof(buf))) > 0) { - char *bp= buf; - - while (n > 0) { - int r; - - if ((r= write(fo, bp, n)) <= 0) { - if (r == 0) { - fprintf(stderr, "%s: write(): Unexpected EOF\n", name); - exit(1); - } - fatal("write()"); - } - bp+= r; - n-= r; - } - } - if (n < 0) fatal("read()"); - } - return 0; -}