1RCMD(3)                    Library Functions Manual                    RCMD(3)
2
3
4

NAME

6       rcmd,  rresvport, ruserok - routines for returning a stream to a remote
7       command
8

SYNOPSIS

10       rem = rcmd(ahost, inport, locuser, remuser, cmd, fd2p);
11       char **ahost;
12       int inport;
13       char *locuser, *remuser, *cmd;
14       int *fd2p;
15
16       s = rresvport(port);
17       int *port;
18
19       ruserok(rhost, superuser, ruser, luser);
20       char *rhost;
21       int superuser;
22       char *ruser, *luser;
23

DESCRIPTION

25       Rcmd is a routine used by the super-user to  execute  a  command  on  a
26       remote  machine  using  an authentication scheme based on reserved port
27       numbers.  Rresvport is a routine which returns a descriptor to a socket
28       with  an  address  in  the privileged port space.  Ruserok is a routine
29       used by servers to authenticate clients requesting service  with  rcmd.
30       All  three  functions  are present in the same file and are used by the
31       rshd(8C) server (among others).
32
33       Rcmd looks up the host *ahost using gethostbyname(3N), returning -1  if
34       the  host does not exist.  Otherwise *ahost is set to the standard name
35       of the host and a connection is established to a server residing at the
36       well-known Internet port inport.
37
38       If  the  connection  succeeds,  a socket in the Internet domain of type
39       SOCK_STREAM is returned to the caller, and given to the remote  command
40       as stdin and stdout.  If fd2p is non-zero, then an auxiliary channel to
41       a control process will be set up, and  a  descriptor  for  it  will  be
42       placed  in  *fd2p.   The  control process will return diagnostic output
43       from the command (unit 2) on this channel, and will also  accept  bytes
44       on  this  channel  as being UNIX signal numbers, to be forwarded to the
45       process group of the command.  If fd2p is 0, then the stderr (unit 2 of
46       the  remote  command) will be made the same as the stdout and no provi‐
47       sion is made for sending  arbitrary  signals  to  the  remote  process,
48       although  you  may  be  able  to get its attention by using out-of-band
49       data.
50
51       The protocol is described in detail in rshd(8C).
52
53       The rresvport routine is used to obtain  a  socket  with  a  privileged
54       address  bound to it.  This socket is suitable for use by rcmd and sev‐
55       eral other routines.  Privileged Internet ports are those in the  range
56       0  to  1023.  Only the super-user is allowed to bind an address of this
57       sort to a socket.
58
59       Ruserok takes a remote host's name, as returned by a  gethostbyaddr(3N)
60       routine,  two user names and a flag indicating whether the local user's
61       name  is  that  of  the  super-user.   It   then   checks   the   files
62       /etc/hosts.equiv  and,  possibly, .rhosts in the current working direc‐
63       tory (normally the local user's home directory) to see if  the  request
64       for  service is allowed.  A 0 is returned if the machine name is listed
65       in the ``hosts.equiv'' file, or the host and remote user name are found
66       in  the  ``.rhosts''  file; otherwise ruserok returns -1.  If the supe‐
67       ruser flag is 1, the checking of the ``host.equiv'' file  is  bypassed.
68       If  the  local  domain (as obtained from gethostname(2)) is the same as
69       the remote domain, only the machine name need be specified.
70

SEE ALSO

72       rlogin(1C),  rsh(1C),  intro(2),  rexec(3),  rexecd(8C),   rlogind(8C),
73       rshd(8C)
74

DIAGNOSTICS

76       Rcmd  returns  a  valid socket descriptor on success.  It returns -1 on
77       error and prints a diagnostic message on the standard error.
78
79       Rresvport returns a valid, bound  socket  descriptor  on  success.   It
80       returns  -1  on  error with the global value errno set according to the
81       reason for failure.  The error code EAGAIN is overloaded to mean  ``All
82       network ports in use.''
83
84
85
864.2 Berkeley Distribution        May 14, 1986                          RCMD(3)
Impressum