fix return codes from ruserok
[unix-history] / usr / src / lib / libc / net / rcmd.3
CommitLineData
11a95b5f
KM
1.\" Copyright (c) 1983 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
4e102a5b 5.\" @(#)rcmd.3 6.3 (Berkeley) %G%
11a95b5f 6.\"
1173f46b 7.TH RCMD 3X ""
11a95b5f
KM
8.UC 5
9.SH NAME
10rcmd, rresvport, ruserok \- routines for returning a stream to a remote command
11.SH SYNOPSIS
12.nf
13.B "rem = rcmd(ahost, inport, locuser, remuser, cmd, fd2p);"
14.B char **ahost;
15.B u_short inport;
16.B "char *locuser, *remuser, *cmd;"
17.B int *fd2p;
18.PP
19.B s = rresvport(port);
20.B int *port;
21.PP
22.B "ruserok(rhost, superuser, ruser, luser);"
23.B char *rhost;
24.B int superuser;
25.B char *ruser, *luser;
26.fi
27.SH DESCRIPTION
28.I Rcmd
29is a routine used by the super-user to execute a command on
30a remote machine using an authentication scheme based
31on reserved port numbers.
32.I Rresvport
33is a routine which returns a descriptor to a socket
34with an address in the privileged port space.
35.I Ruserok
36is a routine used by servers
37to authenticate clients requesting service with
38.IR rcmd .
39All three functions are present in the same file and are used
40by the
41.IR rshd (8C)
42server (among others).
43.PP
44.I Rcmd
45looks up the host
46.I *ahost
47using
48.IR gethostbyname (3N),
49returning \-1 if the host does not exist.
50Otherwise
51.I *ahost
52is set to the standard name of the host
53and a connection is established to a server
54residing at the well-known Internet port
55.IR inport .
56.PP
57If the call succeeds, a socket of type SOCK_STREAM
58is returned to the caller, and given to the remote
59command as
60.B stdin
61and
62.BR stdout .
63If
64.I fd2p
65is non-zero, then an auxiliary channel to a control
66process will be set up, and a descriptor for it will be placed
67in
68.IR *fd2p .
69The control process will return diagnostic
70output from the command (unit 2) on this channel, and will also
71accept bytes on this channel as being UNIX signal numbers, to be
72forwarded to the process group of the command.
73If
74.I fd2p
75is 0, then the
76.B stderr
77(unit 2 of the remote
78command) will be made the same as the
79.B stdout
80and no
81provision is made for sending arbitrary signals to the remote process,
82although you may be able to get its attention by using out-of-band data.
83.PP
84The protocol is described in detail in
85.IR rshd (8C).
86.PP
87The
88.I rresvport
89routine is used to obtain a socket with a privileged
90address bound to it. This socket is suitable for use
91by
92.I rcmd
48270c22 93and several other routines. Privileged addresses consist
11a95b5f
KM
94of a port in the range 0 to 1023. Only the super-user
95is allowed to bind an address of this sort to a socket.
96.PP
97.I Ruserok
98takes a remote host's name, as returned by a
99.IR gethostent (3N)
100routine, two user names and a flag indicating if
101the local user's name is the super-user. It then
102checks the file
103.I /etc/hosts.equiv
104and, possibly,
105.I .rhosts
106in the current working directory (normally the local
107user's home directory) to see if the request for
4e102a5b 108service is allowed. A 0 is returned if the machine
11a95b5f
KM
109name is listed in the ``hosts.equiv'' file, or the
110host and remote user name are found in the ``.rhosts''
111file; otherwise
112.I ruserok
4e102a5b 113returns \-1. If the
11a95b5f
KM
114.I superuser
115flag is 1, the checking of the ``host.equiv'' file is
116bypassed.
117.SH SEE ALSO
118rlogin(1C),
119rsh(1C),
120rexec(3X),
121rexecd(8C),
122rlogind(8C),
123rshd(8C)
124.SH BUGS
125There is no way to specify options to the
126.I socket
127call
128which
129.I rcmd
130makes.