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.\" 325900c007SGarrett Wollman.\" From: @(#)rcmd.3 8.1 (Berkeley) 6/4/93 337f3dea24SPeter Wemm.\" $FreeBSD$ 3458f0484fSRodney W. Grimes.\" 355900c007SGarrett Wollman.Dd February 15, 1996 3658f0484fSRodney W. Grimes.Dt RCMD 3 3758f0484fSRodney W. Grimes.Os BSD 4.2 3858f0484fSRodney W. Grimes.Sh NAME 3958f0484fSRodney W. Grimes.Nm rcmd , 4058f0484fSRodney W. Grimes.Nm rresvport , 413573df98SRodney W. Grimes.Nm iruserok , 4242b4f28eSYoshinobu Inoue.Nm ruserok , 4342b4f28eSYoshinobu Inoue.Nm rresvport_af , 4442b4f28eSYoshinobu Inoue.Nm iruserok_af , 4542b4f28eSYoshinobu Inoue.Nm ruserok_af 4658f0484fSRodney W. Grimes.Nd routines for returning a stream to a remote command 4758f0484fSRodney W. Grimes.Sh SYNOPSIS 4858f0484fSRodney W. Grimes.Fd #include <unistd.h> 4958f0484fSRodney W. Grimes.Ft int 5058f0484fSRodney W. Grimes.Fn rcmd "char **ahost" "int inport" "const char *locuser" "const char *remuser" "const char *cmd" "int *fd2p" 5158f0484fSRodney W. Grimes.Ft int 5258f0484fSRodney W. Grimes.Fn rresvport "int *port" 5358f0484fSRodney W. Grimes.Ft int 5458f0484fSRodney W. Grimes.Fn iruserok "u_long raddr" "int superuser" "const char *ruser" "const char *luser" 5558f0484fSRodney W. Grimes.Ft int 5658f0484fSRodney W. Grimes.Fn ruserok "const char *rhost" "int superuser" "const char *ruser" "const char *luser" 5742b4f28eSYoshinobu Inoue.Ft int 5842b4f28eSYoshinobu Inoue.Fn rresvport_af "int *port" "int family" 5942b4f28eSYoshinobu Inoue.Ft int 6042b4f28eSYoshinobu Inoue.Fn iruserok_af "void *raddr" "int superuser" "const char *ruser" "const char *luser" "int af" 6142b4f28eSYoshinobu Inoue.Ft int 6242b4f28eSYoshinobu Inoue.Fn ruserok_af "const char *rhost" "int superuser" "const char *ruser" "const char *luser" "int af" 6358f0484fSRodney W. Grimes.Sh DESCRIPTION 6458f0484fSRodney W. GrimesThe 6558f0484fSRodney W. Grimes.Fn rcmd 6658f0484fSRodney W. Grimesfunction 6758f0484fSRodney W. Grimesis used by the super-user to execute a command on 6858f0484fSRodney W. Grimesa remote machine using an authentication scheme based 6958f0484fSRodney W. Grimeson reserved port numbers. 7058f0484fSRodney W. GrimesThe 7158f0484fSRodney W. Grimes.Fn rresvport 7258f0484fSRodney W. Grimesfunction 7358f0484fSRodney W. Grimesreturns a descriptor to a socket 7458f0484fSRodney W. Grimeswith an address in the privileged port space. 7558f0484fSRodney W. GrimesThe 7658f0484fSRodney W. Grimes.Fn ruserok 7758f0484fSRodney W. Grimesfunction 7858f0484fSRodney W. Grimesis used by servers 7958f0484fSRodney W. Grimesto authenticate clients requesting service with 8058f0484fSRodney W. Grimes.Fn rcmd . 8158f0484fSRodney W. GrimesAll three functions are present in the same file and are used 8258f0484fSRodney W. Grimesby the 8358f0484fSRodney W. Grimes.Xr rshd 8 8458f0484fSRodney W. Grimesserver (among others). 8558f0484fSRodney W. Grimes.Pp 8658f0484fSRodney W. GrimesThe 8758f0484fSRodney W. Grimes.Fn rcmd 8858f0484fSRodney W. Grimesfunction 8958f0484fSRodney W. Grimeslooks up the host 9058f0484fSRodney W. Grimes.Fa *ahost 9158f0484fSRodney W. Grimesusing 9258f0484fSRodney W. Grimes.Xr gethostbyname 3 , 9358f0484fSRodney W. Grimesreturning \-1 if the host does not exist. 9458f0484fSRodney W. GrimesOtherwise 9558f0484fSRodney W. Grimes.Fa *ahost 9658f0484fSRodney W. Grimesis set to the standard name of the host 9758f0484fSRodney W. Grimesand a connection is established to a server 9858f0484fSRodney W. Grimesresiding at the well-known Internet port 9958f0484fSRodney W. Grimes.Fa inport . 10058f0484fSRodney W. Grimes.Pp 10158f0484fSRodney W. GrimesIf the connection succeeds, 10258f0484fSRodney W. Grimesa socket in the Internet domain of type 10358f0484fSRodney W. Grimes.Dv SOCK_STREAM 10458f0484fSRodney W. Grimesis returned to the caller, and given to the remote 10558f0484fSRodney W. Grimescommand as 10658f0484fSRodney W. Grimes.Em stdin 10758f0484fSRodney W. Grimesand 10858f0484fSRodney W. Grimes.Em stdout . 10958f0484fSRodney W. GrimesIf 11058f0484fSRodney W. Grimes.Fa fd2p 11158f0484fSRodney W. Grimesis non-zero, then an auxiliary channel to a control 11258f0484fSRodney W. Grimesprocess will be set up, and a descriptor for it will be placed 11358f0484fSRodney W. Grimesin 11458f0484fSRodney W. Grimes.Fa *fd2p . 11558f0484fSRodney W. GrimesThe control process will return diagnostic 11658f0484fSRodney W. Grimesoutput from the command (unit 2) on this channel, and will also 11758f0484fSRodney W. Grimesaccept bytes on this channel as being 11858f0484fSRodney W. Grimes.Tn UNIX 11958f0484fSRodney W. Grimessignal numbers, to be 12058f0484fSRodney W. Grimesforwarded to the process group of the command. 12158f0484fSRodney W. GrimesIf 12258f0484fSRodney W. Grimes.Fa fd2p 12358f0484fSRodney W. Grimesis 0, then the 12458f0484fSRodney W. Grimes.Em stderr 12558f0484fSRodney W. Grimes(unit 2 of the remote 12658f0484fSRodney W. Grimescommand) will be made the same as the 12758f0484fSRodney W. Grimes.Em stdout 12858f0484fSRodney W. Grimesand no 12958f0484fSRodney W. Grimesprovision is made for sending arbitrary signals to the remote process, 13058f0484fSRodney W. Grimesalthough you may be able to get its attention by using out-of-band data. 13158f0484fSRodney W. Grimes.Pp 13258f0484fSRodney W. GrimesThe protocol is described in detail in 13358f0484fSRodney W. Grimes.Xr rshd 8 . 13458f0484fSRodney W. Grimes.Pp 13558f0484fSRodney W. GrimesThe 13658f0484fSRodney W. Grimes.Fn rresvport 13758f0484fSRodney W. Grimesfunction is used to obtain a socket with a privileged 13858f0484fSRodney W. Grimesaddress bound to it. This socket is suitable for use 13958f0484fSRodney W. Grimesby 14058f0484fSRodney W. Grimes.Fn rcmd 14158f0484fSRodney W. Grimesand several other functions. Privileged Internet ports are those 14258f0484fSRodney W. Grimesin the range 0 to 1023. Only the super-user 14358f0484fSRodney W. Grimesis allowed to bind an address of this sort to a socket. 14458f0484fSRodney W. Grimes.Pp 14558f0484fSRodney W. GrimesThe 14658f0484fSRodney W. Grimes.Fn iruserok 14758f0484fSRodney W. Grimesand 14858f0484fSRodney W. Grimes.Fn ruserok 14958f0484fSRodney W. Grimesfunctions take a remote host's IP address or name, as returned by the 15058f0484fSRodney W. Grimes.Xr gethostbyname 3 15158f0484fSRodney W. Grimesroutines, two user names and a flag indicating whether the local user's 15258f0484fSRodney W. Grimesname is that of the super-user. 15358f0484fSRodney W. GrimesThen, if the user is 15458f0484fSRodney W. Grimes.Em NOT 15558f0484fSRodney W. Grimesthe super-user, it checks the 15658f0484fSRodney W. Grimes.Pa /etc/hosts.equiv 15758f0484fSRodney W. Grimesfile. 15858f0484fSRodney W. GrimesIf that lookup is not done, or is unsuccessful, the 15958f0484fSRodney W. Grimes.Pa .rhosts 16058f0484fSRodney W. Grimesin the local user's home directory is checked to see if the request for 16158f0484fSRodney W. Grimesservice is allowed. 16258f0484fSRodney W. Grimes.Pp 16358f0484fSRodney W. GrimesIf this file does not exist, is not a regular file, is owned by anyone 164a5ed710cSMike Pritchardother than the user or the super-user, or is writable by anyone other 16558f0484fSRodney W. Grimesthan the owner, the check automatically fails. 16658f0484fSRodney W. GrimesZero is returned if the machine name is listed in the 16758f0484fSRodney W. Grimes.Dq Pa hosts.equiv 16858f0484fSRodney W. Grimesfile, or the host and remote user name are found in the 16958f0484fSRodney W. Grimes.Dq Pa .rhosts 17058f0484fSRodney W. Grimesfile; otherwise 17158f0484fSRodney W. Grimes.Fn iruserok 17258f0484fSRodney W. Grimesand 17358f0484fSRodney W. Grimes.Fn ruserok 17458f0484fSRodney W. Grimesreturn \-1. 17558f0484fSRodney W. GrimesIf the local domain (as obtained from 176e1f4e80cSMike Pritchard.Xr gethostname 3 ) 17758f0484fSRodney W. Grimesis the same as the remote domain, only the machine name need be specified. 17858f0484fSRodney W. Grimes.Pp 17958f0484fSRodney W. GrimesThe 18058f0484fSRodney W. Grimes.Fn iruserok 18158f0484fSRodney W. Grimesfunction is strongly preferred for security reasons. 18258f0484fSRodney W. GrimesIt requires trusting the local DNS at most, while the 18358f0484fSRodney W. Grimes.Fn ruserok 18458f0484fSRodney W. Grimesfunction requires trusting the entire DNS, which can be spoofed. 18542b4f28eSYoshinobu Inoue.Pp 18642b4f28eSYoshinobu InoueFunctions with ``_af'' suffix, i.e. 18742b4f28eSYoshinobu Inoue.Fn rresvport_af , 18842b4f28eSYoshinobu Inoue.Fn iruserok_af and 18942b4f28eSYoshinobu Inoue.Fn ruserok_af , 19042b4f28eSYoshinobu Inoueworks just as same as functions without ``_af'', and is capable of 19142b4f28eSYoshinobu Inouehandling both IPv6 port and IPv4 port. 19242b4f28eSYoshinobu InoueTo switch address family, 19342b4f28eSYoshinobu Inoue.Fa af 19442b4f28eSYoshinobu Inoueargument must be filled with 19542b4f28eSYoshinobu Inoue.Dv AF_INET 19642b4f28eSYoshinobu Inoueor 19742b4f28eSYoshinobu Inoue.Dv AF_INET6 . 19858f0484fSRodney W. Grimes.Sh DIAGNOSTICS 19958f0484fSRodney W. GrimesThe 20058f0484fSRodney W. Grimes.Fn rcmd 20158f0484fSRodney W. Grimesfunction 20258f0484fSRodney W. Grimesreturns a valid socket descriptor on success. 20358f0484fSRodney W. GrimesIt returns \-1 on error and prints a diagnostic message on the standard error. 20458f0484fSRodney W. Grimes.Pp 20558f0484fSRodney W. GrimesThe 20658f0484fSRodney W. Grimes.Fn rresvport 20758f0484fSRodney W. Grimesfunction 20858f0484fSRodney W. Grimesreturns a valid, bound socket descriptor on success. 20958f0484fSRodney W. GrimesIt returns \-1 on error with the global value 21058f0484fSRodney W. Grimes.Va errno 21158f0484fSRodney W. Grimesset according to the reason for failure. 21258f0484fSRodney W. GrimesThe error code 21358f0484fSRodney W. Grimes.Dv EAGAIN 21458f0484fSRodney W. Grimesis overloaded to mean ``All network ports in use.'' 21558f0484fSRodney W. Grimes.Sh SEE ALSO 21658f0484fSRodney W. Grimes.Xr rlogin 1 , 21758f0484fSRodney W. Grimes.Xr rsh 1 , 21858f0484fSRodney W. Grimes.Xr intro 2 , 21958f0484fSRodney W. Grimes.Xr rexec 3 , 22058f0484fSRodney W. Grimes.Xr rexecd 8 , 22158f0484fSRodney W. Grimes.Xr rlogind 8 , 22258f0484fSRodney W. Grimes.Xr rshd 8 22342b4f28eSYoshinobu Inoue.Pp 22442b4f28eSYoshinobu InoueW. Stevens and M. Thomas, ``Advanced Socket API for IPv6,'' 22542b4f28eSYoshinobu InoueRFC2292. 22658f0484fSRodney W. Grimes.Sh HISTORY 22758f0484fSRodney W. GrimesThese 22858f0484fSRodney W. Grimesfunctions appeared in 22958f0484fSRodney W. Grimes.Bx 4.2 . 23042b4f28eSYoshinobu Inoue.Fn rresvport_af 23142b4f28eSYoshinobu Inoueappeared in RFC2292, and implemented by WIDE project 23242b4f28eSYoshinobu Inouefor Hydrangea IPv6 protocol stack kit. 23342b4f28eSYoshinobu Inoue.Fn iruserok_af 23442b4f28eSYoshinobu Inoueand 23542b4f28eSYoshinobu Inoue.Fn rusreok_af 23642b4f28eSYoshinobu Inoueare proposed and implemented by WIDE project 23742b4f28eSYoshinobu Inouefor Hydrangea IPv6 protocol stack kit. 238