source: trunk/minix/man/man3/rcmd.3@ 22

Last change on this file since 22 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 3.8 KB
Line 
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.\"
5.\" @(#)rcmd.3 6.7 (Berkeley) 5/14/86
6.\"
7.TH RCMD 3 "May 14, 1986"
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 "#include <sys/types.h>"
14.B "#include <net/netlib.h>"
15.PP
16.B "rem = rcmd(ahost, inport, locuser, remuser, cmd, fd2p);"
17.B char **ahost;
18.B int inport;
19.B "char *locuser, *remuser, *cmd;"
20.B int *fd2p;
21.PP
22.B s = rresvport(port);
23.B int *port;
24.PP
25.B "ruserok(rhost, superuser, ruser, luser);"
26.B char *rhost;
27.B int superuser;
28.B char *ruser, *luser;
29.fi
30.SH DESCRIPTION
31.I Rcmd
32is a routine used by the super-user to execute a command on
33a remote machine using an authentication scheme based
34on reserved port numbers.
35.I Rresvport
36is a routine which returns a descriptor to a socket
37with an address in the privileged port space.
38.I Ruserok
39is a routine used by servers
40to authenticate clients requesting service with
41.IR rcmd .
42All three functions are present in the same file and are used
43by the
44.IR rshd (8)
45server (among others).
46.PP
47.I Rcmd
48looks up the host
49.I *ahost
50using
51.IR gethostbyname (3),
52returning \-1 if the host does not exist.
53Otherwise
54.I *ahost
55is set to the standard name of the host
56and a connection is established to a server
57residing at the well-known Internet port
58.IR inport .
59.PP
60If the connection succeeds,
61a socket in the Internet domain of type SOCK_STREAM
62is returned to the caller, and given to the remote
63command as
64.B stdin
65and
66.BR stdout .
67If
68.I fd2p
69is non-zero, then an auxiliary channel to a control
70process will be set up, and a descriptor for it will be placed
71in
72.IR *fd2p .
73The control process will return diagnostic
74output from the command (unit 2) on this channel, and will also
75accept bytes on this channel as being UNIX signal numbers, to be
76forwarded to the process group of the command.
77If
78.I fd2p
79is 0, then the
80.B stderr
81(unit 2 of the remote
82command) will be made the same as the
83.B stdout
84and no
85provision is made for sending arbitrary signals to the remote process,
86although you may be able to get its attention by using out-of-band data.
87.PP
88The protocol is described in detail in
89.IR rshd (8).
90.PP
91The
92.I rresvport
93routine is used to obtain a socket with a privileged
94address bound to it. This socket is suitable for use
95by
96.I rcmd
97and several other routines. Privileged Internet ports are those
98in the range 0 to 1023. Only the super-user
99is allowed to bind an address of this sort to a socket.
100.PP
101.I Ruserok
102takes a remote host's name, as returned by a
103.IR gethostbyaddr (3)
104routine, two user names and a flag indicating whether
105the local user's name is that of the super-user. It then
106checks the files
107.I /etc/hosts.equiv
108and, possibly,
109.I .rhosts
110in the current working directory (normally the local
111user's home directory) to see if the request for
112service is allowed. A 0 is returned if the machine
113name is listed in the ``hosts.equiv'' file, or the
114host and remote user name are found in the ``.rhosts''
115file; otherwise
116.I ruserok
117returns \-1. If the
118.I superuser
119flag is 1, the checking of the ``host.equiv'' file is
120bypassed.
121If the local domain (as obtained from \fIgethostname\fP\|(3))
122is the same as the remote domain, only the machine name need be specified.
123.SH SEE ALSO
124rlogin(1),
125rsh(1),
126intro(2),
127rexec(3),
128rexecd(8),
129rlogind(8),
130rshd(8)
131.SH DIAGNOSTICS
132.I Rcmd
133returns a valid socket descriptor on success.
134It returns -1 on error and prints a diagnostic message on the standard error.
135.PP
136.I Rresvport
137returns a valid, bound socket descriptor on success.
138It returns -1 on error with the global value
139.I errno
140set according to the reason for failure.
141The error code EAGAIN is overloaded to mean ``All network ports in use.''
Note: See TracBrowser for help on using the repository browser.