Make all bucket and overflow addresses unsigned
[unix-history] / usr / src / lib / libc / net / rcmd.3
CommitLineData
d20a1e6f
KB
1.\" Copyright (c) 1983 The Regents of the University of California.
2.\" All rights reserved.
11a95b5f 3.\"
91cff1e1 4.\" %sccs.include.redist.man%
d20a1e6f 5.\"
91cff1e1 6.\" @(#)rcmd.3 6.10 (Berkeley) %G%
11a95b5f 7.\"
0609943c 8.TH RCMD 3 ""
11a95b5f
KM
9.UC 5
10.SH NAME
11rcmd, rresvport, ruserok \- routines for returning a stream to a remote command
12.SH SYNOPSIS
13.nf
4fb1c171 14.PP
11a95b5f
KM
15.B "rem = rcmd(ahost, inport, locuser, remuser, cmd, fd2p);"
16.B char **ahost;
f3f0480d 17.B int inport;
11a95b5f
KM
18.B "char *locuser, *remuser, *cmd;"
19.B int *fd2p;
20.PP
21.B s = rresvport(port);
22.B int *port;
23.PP
24.B "ruserok(rhost, superuser, ruser, luser);"
25.B char *rhost;
26.B int superuser;
27.B char *ruser, *luser;
28.fi
29.SH DESCRIPTION
30.I Rcmd
31is a routine used by the super-user to execute a command on
32a remote machine using an authentication scheme based
33on reserved port numbers.
34.I Rresvport
35is a routine which returns a descriptor to a socket
36with an address in the privileged port space.
37.I Ruserok
38is a routine used by servers
39to authenticate clients requesting service with
40.IR rcmd .
41All three functions are present in the same file and are used
42by the
d20a1e6f 43.IR rshd (8)
11a95b5f
KM
44server (among others).
45.PP
46.I Rcmd
47looks up the host
48.I *ahost
49using
d20a1e6f 50.IR gethostbyname (3),
11a95b5f
KM
51returning \-1 if the host does not exist.
52Otherwise
53.I *ahost
54is set to the standard name of the host
55and a connection is established to a server
56residing at the well-known Internet port
57.IR inport .
58.PP
7faf4e1f
MK
59If the connection succeeds,
60a socket in the Internet domain of type SOCK_STREAM
11a95b5f
KM
61is returned to the caller, and given to the remote
62command as
63.B stdin
64and
65.BR stdout .
66If
67.I fd2p
68is non-zero, then an auxiliary channel to a control
69process will be set up, and a descriptor for it will be placed
70in
71.IR *fd2p .
72The control process will return diagnostic
73output from the command (unit 2) on this channel, and will also
74accept bytes on this channel as being UNIX signal numbers, to be
75forwarded to the process group of the command.
76If
77.I fd2p
78is 0, then the
79.B stderr
80(unit 2 of the remote
81command) will be made the same as the
82.B stdout
83and no
84provision is made for sending arbitrary signals to the remote process,
85although you may be able to get its attention by using out-of-band data.
86.PP
87The protocol is described in detail in
d20a1e6f 88.IR rshd (8).
11a95b5f
KM
89.PP
90The
91.I rresvport
92routine is used to obtain a socket with a privileged
93address bound to it. This socket is suitable for use
94by
95.I rcmd
7faf4e1f
MK
96and several other routines. Privileged Internet ports are those
97in the range 0 to 1023. Only the super-user
11a95b5f
KM
98is allowed to bind an address of this sort to a socket.
99.PP
100.I Ruserok
d20a1e6f
KB
101takes a remote host's name, as returned by the
102.IR gethostbyaddr (3)
7faf4e1f 103routine, two user names and a flag indicating whether
d20a1e6f
KB
104the local user's name is that of the super-user. Then,
105if the user is
106.B NOT
107the super-user, it checks the files
108.IR /etc/hosts.equiv .
109If that lookup is not done, or is unsuccessful, the
11a95b5f 110.I .rhosts
d20a1e6f
KB
111in the local user's home directory is checked to see if the request for
112service is allowed. If this file is owned by anyone other than the
113user or the super-user, or if it is writeable by anyone other than the
114owner, the check automatically fails. A 0 is returned if the machine
115name is listed in the ``hosts.equiv'' file, or the host and remote
116user name are found in the ``.rhosts'' file; otherwise
11a95b5f 117.I ruserok
d20a1e6f 118returns \-1.
0609943c
MK
119If the local domain (as obtained from \fIgethostname\fP\|(2))
120is the same as the remote domain, only the machine name need be specified.
11a95b5f 121.SH SEE ALSO
d20a1e6f 122rlogin(1), rsh(1), intro(2), rexec(3), rexecd(8), rlogind(8), rshd(8)
7faf4e1f
MK
123.SH DIAGNOSTICS
124.I Rcmd
125returns a valid socket descriptor on success.
126It returns -1 on error and prints a diagnostic message on the standard error.
127.PP
128.I Rresvport
129returns a valid, bound socket descriptor on success.
130It returns -1 on error with the global value
131.I errno
132set according to the reason for failure.
133The error code EAGAIN is overloaded to mean ``All network ports in use.''