158f0484fSRodney W. Grimes.\" Copyright (c) 1983, 1991, 1993 258f0484fSRodney W. Grimes.\" The Regents of the University of California. All rights reserved. 358f0484fSRodney W. Grimes.\" 458f0484fSRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without 558f0484fSRodney W. Grimes.\" modification, are permitted provided that the following conditions 658f0484fSRodney W. Grimes.\" are met: 758f0484fSRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright 858f0484fSRodney W. Grimes.\" notice, this list of conditions and the following disclaimer. 958f0484fSRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright 1058f0484fSRodney W. Grimes.\" notice, this list of conditions and the following disclaimer in the 1158f0484fSRodney W. Grimes.\" documentation and/or other materials provided with the distribution. 1258f0484fSRodney W. Grimes.\" 3. All advertising materials mentioning features or use of this software 1358f0484fSRodney W. Grimes.\" must display the following acknowledgement: 1458f0484fSRodney W. Grimes.\" This product includes software developed by the University of 1558f0484fSRodney W. Grimes.\" California, Berkeley and its contributors. 1658f0484fSRodney W. Grimes.\" 4. Neither the name of the University nor the names of its contributors 1758f0484fSRodney W. Grimes.\" may be used to endorse or promote products derived from this software 1858f0484fSRodney W. Grimes.\" without specific prior written permission. 1958f0484fSRodney W. Grimes.\" 2058f0484fSRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2158f0484fSRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2258f0484fSRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2358f0484fSRodney W. Grimes.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2458f0484fSRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2558f0484fSRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2658f0484fSRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2758f0484fSRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2858f0484fSRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2958f0484fSRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3058f0484fSRodney W. Grimes.\" SUCH DAMAGE. 3158f0484fSRodney W. Grimes.\" 3258f0484fSRodney W. Grimes.\" @(#)rcmd.3 8.1 (Berkeley) 6/4/93 3358f0484fSRodney W. Grimes.\" 3458f0484fSRodney W. Grimes.Dd June 4, 1993 3558f0484fSRodney W. Grimes.Dt RCMD 3 3658f0484fSRodney W. Grimes.Os BSD 4.2 3758f0484fSRodney W. Grimes.Sh NAME 3858f0484fSRodney W. Grimes.Nm rcmd , 3958f0484fSRodney W. Grimes.Nm rresvport , 403573df98SRodney W. Grimes.Nm iruserok , 4158f0484fSRodney W. Grimes.Nm ruserok 4258f0484fSRodney W. Grimes.Nd routines for returning a stream to a remote command 4358f0484fSRodney W. Grimes.Sh SYNOPSIS 4458f0484fSRodney W. Grimes.Fd #include <unistd.h> 4558f0484fSRodney W. Grimes.Ft int 4658f0484fSRodney W. Grimes.Fn rcmd "char **ahost" "int inport" "const char *locuser" "const char *remuser" "const char *cmd" "int *fd2p" 4758f0484fSRodney W. Grimes.Ft int 4858f0484fSRodney W. Grimes.Fn rresvport "int *port" 4958f0484fSRodney W. Grimes.Ft int 5058f0484fSRodney W. Grimes.Fn iruserok "u_long raddr" "int superuser" "const char *ruser" "const char *luser" 5158f0484fSRodney W. Grimes.Ft int 5258f0484fSRodney W. Grimes.Fn ruserok "const char *rhost" "int superuser" "const char *ruser" "const char *luser" 5358f0484fSRodney W. Grimes.Sh DESCRIPTION 5458f0484fSRodney W. GrimesThe 5558f0484fSRodney W. Grimes.Fn rcmd 5658f0484fSRodney W. Grimesfunction 5758f0484fSRodney W. Grimesis used by the super-user to execute a command on 5858f0484fSRodney W. Grimesa remote machine using an authentication scheme based 5958f0484fSRodney W. Grimeson reserved port numbers. 6058f0484fSRodney W. GrimesThe 6158f0484fSRodney W. Grimes.Fn rresvport 6258f0484fSRodney W. Grimesfunction 6358f0484fSRodney W. Grimesreturns a descriptor to a socket 6458f0484fSRodney W. Grimeswith an address in the privileged port space. 6558f0484fSRodney W. GrimesThe 6658f0484fSRodney W. Grimes.Fn ruserok 6758f0484fSRodney W. Grimesfunction 6858f0484fSRodney W. Grimesis used by servers 6958f0484fSRodney W. Grimesto authenticate clients requesting service with 7058f0484fSRodney W. Grimes.Fn rcmd . 7158f0484fSRodney W. GrimesAll three functions are present in the same file and are used 7258f0484fSRodney W. Grimesby the 7358f0484fSRodney W. Grimes.Xr rshd 8 7458f0484fSRodney W. Grimesserver (among others). 7558f0484fSRodney W. Grimes.Pp 7658f0484fSRodney W. GrimesThe 7758f0484fSRodney W. Grimes.Fn rcmd 7858f0484fSRodney W. Grimesfunction 7958f0484fSRodney W. Grimeslooks up the host 8058f0484fSRodney W. Grimes.Fa *ahost 8158f0484fSRodney W. Grimesusing 8258f0484fSRodney W. Grimes.Xr gethostbyname 3 , 8358f0484fSRodney W. Grimesreturning \-1 if the host does not exist. 8458f0484fSRodney W. GrimesOtherwise 8558f0484fSRodney W. Grimes.Fa *ahost 8658f0484fSRodney W. Grimesis set to the standard name of the host 8758f0484fSRodney W. Grimesand a connection is established to a server 8858f0484fSRodney W. Grimesresiding at the well-known Internet port 8958f0484fSRodney W. Grimes.Fa inport . 9058f0484fSRodney W. Grimes.Pp 9158f0484fSRodney W. GrimesIf the connection succeeds, 9258f0484fSRodney W. Grimesa socket in the Internet domain of type 9358f0484fSRodney W. Grimes.Dv SOCK_STREAM 9458f0484fSRodney W. Grimesis returned to the caller, and given to the remote 9558f0484fSRodney W. Grimescommand as 9658f0484fSRodney W. Grimes.Em stdin 9758f0484fSRodney W. Grimesand 9858f0484fSRodney W. Grimes.Em stdout . 9958f0484fSRodney W. GrimesIf 10058f0484fSRodney W. Grimes.Fa fd2p 10158f0484fSRodney W. Grimesis non-zero, then an auxiliary channel to a control 10258f0484fSRodney W. Grimesprocess will be set up, and a descriptor for it will be placed 10358f0484fSRodney W. Grimesin 10458f0484fSRodney W. Grimes.Fa *fd2p . 10558f0484fSRodney W. GrimesThe control process will return diagnostic 10658f0484fSRodney W. Grimesoutput from the command (unit 2) on this channel, and will also 10758f0484fSRodney W. Grimesaccept bytes on this channel as being 10858f0484fSRodney W. Grimes.Tn UNIX 10958f0484fSRodney W. Grimessignal numbers, to be 11058f0484fSRodney W. Grimesforwarded to the process group of the command. 11158f0484fSRodney W. GrimesIf 11258f0484fSRodney W. Grimes.Fa fd2p 11358f0484fSRodney W. Grimesis 0, then the 11458f0484fSRodney W. Grimes.Em stderr 11558f0484fSRodney W. Grimes(unit 2 of the remote 11658f0484fSRodney W. Grimescommand) will be made the same as the 11758f0484fSRodney W. Grimes.Em stdout 11858f0484fSRodney W. Grimesand no 11958f0484fSRodney W. Grimesprovision is made for sending arbitrary signals to the remote process, 12058f0484fSRodney W. Grimesalthough you may be able to get its attention by using out-of-band data. 12158f0484fSRodney W. Grimes.Pp 12258f0484fSRodney W. GrimesThe protocol is described in detail in 12358f0484fSRodney W. Grimes.Xr rshd 8 . 12458f0484fSRodney W. Grimes.Pp 12558f0484fSRodney W. GrimesThe 12658f0484fSRodney W. Grimes.Fn rresvport 12758f0484fSRodney W. Grimesfunction is used to obtain a socket with a privileged 12858f0484fSRodney W. Grimesaddress bound to it. This socket is suitable for use 12958f0484fSRodney W. Grimesby 13058f0484fSRodney W. Grimes.Fn rcmd 13158f0484fSRodney W. Grimesand several other functions. Privileged Internet ports are those 13258f0484fSRodney W. Grimesin the range 0 to 1023. Only the super-user 13358f0484fSRodney W. Grimesis allowed to bind an address of this sort to a socket. 13458f0484fSRodney W. Grimes.Pp 13558f0484fSRodney W. GrimesThe 13658f0484fSRodney W. Grimes.Fn iruserok 13758f0484fSRodney W. Grimesand 13858f0484fSRodney W. Grimes.Fn ruserok 13958f0484fSRodney W. Grimesfunctions take a remote host's IP address or name, as returned by the 14058f0484fSRodney W. Grimes.Xr gethostbyname 3 14158f0484fSRodney W. Grimesroutines, two user names and a flag indicating whether the local user's 14258f0484fSRodney W. Grimesname is that of the super-user. 14358f0484fSRodney W. GrimesThen, if the user is 14458f0484fSRodney W. Grimes.Em NOT 14558f0484fSRodney W. Grimesthe super-user, it checks the 14658f0484fSRodney W. Grimes.Pa /etc/hosts.equiv 14758f0484fSRodney W. Grimesfile. 14858f0484fSRodney W. GrimesIf that lookup is not done, or is unsuccessful, the 14958f0484fSRodney W. Grimes.Pa .rhosts 15058f0484fSRodney W. Grimesin the local user's home directory is checked to see if the request for 15158f0484fSRodney W. Grimesservice is allowed. 15258f0484fSRodney W. Grimes.Pp 15358f0484fSRodney W. GrimesIf this file does not exist, is not a regular file, is owned by anyone 15458f0484fSRodney W. Grimesother than the user or the super-user, or is writeable by anyone other 15558f0484fSRodney W. Grimesthan the owner, the check automatically fails. 15658f0484fSRodney W. GrimesZero is returned if the machine name is listed in the 15758f0484fSRodney W. Grimes.Dq Pa hosts.equiv 15858f0484fSRodney W. Grimesfile, or the host and remote user name are found in the 15958f0484fSRodney W. Grimes.Dq Pa .rhosts 16058f0484fSRodney W. Grimesfile; otherwise 16158f0484fSRodney W. Grimes.Fn iruserok 16258f0484fSRodney W. Grimesand 16358f0484fSRodney W. Grimes.Fn ruserok 16458f0484fSRodney W. Grimesreturn \-1. 16558f0484fSRodney W. GrimesIf the local domain (as obtained from 16658f0484fSRodney W. Grimes.Xr gethostname 2 ) 16758f0484fSRodney W. Grimesis the same as the remote domain, only the machine name need be specified. 16858f0484fSRodney W. Grimes.Pp 16958f0484fSRodney W. GrimesThe 17058f0484fSRodney W. Grimes.Fn iruserok 17158f0484fSRodney W. Grimesfunction is strongly preferred for security reasons. 17258f0484fSRodney W. GrimesIt requires trusting the local DNS at most, while the 17358f0484fSRodney W. Grimes.Fn ruserok 17458f0484fSRodney W. Grimesfunction requires trusting the entire DNS, which can be spoofed. 17558f0484fSRodney W. Grimes.Sh DIAGNOSTICS 17658f0484fSRodney W. GrimesThe 17758f0484fSRodney W. Grimes.Fn rcmd 17858f0484fSRodney W. Grimesfunction 17958f0484fSRodney W. Grimesreturns a valid socket descriptor on success. 18058f0484fSRodney W. GrimesIt returns \-1 on error and prints a diagnostic message on the standard error. 18158f0484fSRodney W. Grimes.Pp 18258f0484fSRodney W. GrimesThe 18358f0484fSRodney W. Grimes.Fn rresvport 18458f0484fSRodney W. Grimesfunction 18558f0484fSRodney W. Grimesreturns a valid, bound socket descriptor on success. 18658f0484fSRodney W. GrimesIt returns \-1 on error with the global value 18758f0484fSRodney W. Grimes.Va errno 18858f0484fSRodney W. Grimesset according to the reason for failure. 18958f0484fSRodney W. GrimesThe error code 19058f0484fSRodney W. Grimes.Dv EAGAIN 19158f0484fSRodney W. Grimesis overloaded to mean ``All network ports in use.'' 19258f0484fSRodney W. Grimes.Sh SEE ALSO 19358f0484fSRodney W. Grimes.Xr rlogin 1 , 19458f0484fSRodney W. Grimes.Xr rsh 1 , 19558f0484fSRodney W. Grimes.Xr intro 2 , 19658f0484fSRodney W. Grimes.Xr rexec 3 , 19758f0484fSRodney W. Grimes.Xr rexecd 8 , 19858f0484fSRodney W. Grimes.Xr rlogind 8 , 19958f0484fSRodney W. Grimes.Xr rshd 8 20058f0484fSRodney W. Grimes.Sh HISTORY 20158f0484fSRodney W. GrimesThese 20258f0484fSRodney W. Grimesfunctions appeared in 20358f0484fSRodney W. Grimes.Bx 4.2 . 204