version 1, including all changes.
.
Rev |
Author |
# |
Line |
1 |
perry |
1 |
---- |
|
|
2 |
__NAME__ |
|
|
3 |
|
|
|
4 |
|
|
|
5 |
rcmd, rresvport, iruserok, ruserok - routines for returning |
|
|
6 |
a stream to a remote command |
|
|
7 |
__SYNOPSIS__ |
|
|
8 |
|
|
|
9 |
|
|
|
10 |
#include |
|
|
11 |
|
|
|
12 |
|
|
|
13 |
int |
|
|
14 |
|
|
|
15 |
|
|
|
16 |
rcmd(char ahost, int inport, const char locuser, const char |
|
|
17 |
remuser, const char cmd, int fd2p); |
|
|
18 |
|
|
|
19 |
|
|
|
20 |
int |
|
|
21 |
|
|
|
22 |
|
|
|
23 |
rresvport(int port); |
|
|
24 |
|
|
|
25 |
|
|
|
26 |
int |
|
|
27 |
|
|
|
28 |
|
|
|
29 |
iruserok(u_int32_t raddr, int superuser, const char ruser, |
|
|
30 |
const char luser); |
|
|
31 |
|
|
|
32 |
|
|
|
33 |
int |
|
|
34 |
|
|
|
35 |
|
|
|
36 |
ruserok(const char rhost, int superuser, const char ruser, |
|
|
37 |
const char luser); |
|
|
38 |
__DESCRIPTION__ |
|
|
39 |
|
|
|
40 |
|
|
|
41 |
The rcmd() function is used by the super-user to execute a |
|
|
42 |
command on a remote machine using an authentication scheme |
|
|
43 |
based on reserved port numbers. The rresvport() function |
|
|
44 |
returns a descriptor to a socket with an address in the |
|
|
45 |
privileged port space. The iruserok() and ruserok() func- |
|
|
46 |
tions are used by servers to authenticate clients requesting |
|
|
47 |
service with rcmd(). All four functions are present in the |
|
|
48 |
same file and are used by the rshd(8) server (among |
|
|
49 |
others). |
|
|
50 |
|
|
|
51 |
|
|
|
52 |
The rcmd() function looks up the host ahost using gethostbyname(3), returning -1 if the host does not exist. Otherwise ahost is set to the standard name of the host and a connection is established to a server residing at the well-known Internet port inport. |
|
|
53 |
|
|
|
54 |
|
|
|
55 |
If the connection succeeds, a socket in the Internet domain |
|
|
56 |
of type SOCK_STREAM is returned to the caller, and |
|
|
57 |
given to the remote command as ''stdin'' and |
|
|
58 |
''stdout''. If fd2p is non-zero, then an auxiliary |
|
|
59 |
channel to a control process will be set up, and a |
|
|
60 |
descriptor for it will be placed in fd2p. The control |
|
|
61 |
process will return diagnostic output from the command (unit |
|
|
62 |
2) on this channel, and will also accept bytes on this |
|
|
63 |
channel as being UNIX signal numbers, to be |
|
|
64 |
forwarded to the process group of the command. If fd2p is 0, |
|
|
65 |
then the ''stderr'' (unit 2 of the remote command) will |
|
|
66 |
be made the same as the ''stdout'' and no provision is |
|
|
67 |
made for sending arbitrary signals to the remote process, |
|
|
68 |
although you may be able to get its attention by using |
|
|
69 |
out-of-band data. |
|
|
70 |
|
|
|
71 |
|
|
|
72 |
The protocol is described in detail in |
|
|
73 |
rshd(8). |
|
|
74 |
|
|
|
75 |
|
|
|
76 |
The rresvport() function is used to obtain a socket with a |
|
|
77 |
privileged address bound to it. This socket is suitable for |
|
|
78 |
use by rcmd() and several other functions. Privileged |
|
|
79 |
Internet ports are those in the range 0 to 1023. Only the |
|
|
80 |
super-user is allowed to bind an address of this sort to a |
|
|
81 |
socket. |
|
|
82 |
|
|
|
83 |
|
|
|
84 |
The iruserok() and ruserok() functions take a remote host's |
|
|
85 |
IP address or name, respectively, two user names and a flag |
|
|
86 |
indicating whether the local user's name is that of the |
|
|
87 |
super-user. Then, if the user is ''NOT'' the super-user, |
|
|
88 |
it checks the /etc/hosts.equiv file. If that lookup |
|
|
89 |
is not done, or is unsuccessful, the .rhosts in the |
|
|
90 |
local user's home directory is checked to see if the request |
|
|
91 |
for service is allowed. |
|
|
92 |
|
|
|
93 |
|
|
|
94 |
If this file does not exist, is not a regular file, is owned |
|
|
95 |
by anyone other than the user or the super-user, or is |
|
|
96 |
writeable by anyone other than the owner, the check automat- |
|
|
97 |
ically fails. Zero is returned if the machine name is listed |
|
|
98 |
in the ``hosts.equiv'' file, or the host and remote |
|
|
99 |
user name are found in the ``.rhosts'' file; |
|
|
100 |
otherwise iruserok() and ruserok() return -1. If the local |
|
|
101 |
domain (as obtained from gethostname(2)) is the |
|
|
102 |
same as the remote domain, only the machine name need be |
|
|
103 |
specified. |
|
|
104 |
|
|
|
105 |
|
|
|
106 |
If the IP address of the remote host is known, iruserok() |
|
|
107 |
should be used in preference to ruserok(), as it does not |
|
|
108 |
require trusting the DNS server for the remote host's |
|
|
109 |
domain. |
|
|
110 |
__DIAGNOSTICS__ |
|
|
111 |
|
|
|
112 |
|
|
|
113 |
The rcmd() function returns a valid socket descriptor on |
|
|
114 |
success. It returns -1 on error and prints a diagnostic |
|
|
115 |
message on the standard error. |
|
|
116 |
|
|
|
117 |
|
|
|
118 |
The rresvport() function returns a valid, bound socket descriptor on success. It returns -1 on error with the global value ''errno'' set according to the reason for failure. The error code EAGAIN is overloaded to mean ``All network ports in use.'' |
|
|
119 |
__SEE ALSO__ |
|
|
120 |
|
|
|
121 |
|
|
|
122 |
rlogin(1), rsh(1), intro(2), |
|
|
123 |
rexec(3), rexecd(8), rlogind(8), |
|
|
124 |
rshd(8) |
|
|
125 |
__HISTORY__ |
|
|
126 |
|
|
|
127 |
|
|
|
128 |
These functions appeared in 4.2 BSD |
|
|
129 |
. |
|
|
130 |
|
|
|
131 |
|
|
|
132 |
4.2 Berkeley Distribution June 4, 1993 1 |
|
|
133 |
---- |