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