diff options
author | cvs2svn <admin@example.com> | 1999-03-26 18:24:03 +0000 |
---|---|---|
committer | cvs2svn <admin@example.com> | 1999-03-26 18:24:03 +0000 |
commit | 3fc228fb4c1a39aceaee3d7013365042a6077bd0 (patch) | |
tree | af769f6648929b3b2c1f9e053a3754fa989ce302 /src/lib/libc/net/rcmd.3 | |
parent | 536c76cbb863bab152f19842ab88772c01e922c7 (diff) | |
download | openbsd-OPENBSD_2_5.tar.gz openbsd-OPENBSD_2_5.tar.bz2 openbsd-OPENBSD_2_5.zip |
This commit was manufactured by cvs2git to create branch 'OPENBSD_2_5'.OPENBSD_2_5
Diffstat (limited to 'src/lib/libc/net/rcmd.3')
-rw-r--r-- | src/lib/libc/net/rcmd.3 | 227 |
1 files changed, 227 insertions, 0 deletions
diff --git a/src/lib/libc/net/rcmd.3 b/src/lib/libc/net/rcmd.3 new file mode 100644 index 0000000000..e69e822834 --- /dev/null +++ b/src/lib/libc/net/rcmd.3 | |||
@@ -0,0 +1,227 @@ | |||
1 | .\" $OpenBSD: rcmd.3,v 1.10 1997/09/29 18:25:47 deraadt Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1983, 1991, 1993 | ||
4 | .\" The Regents of the University of California. All rights reserved. | ||
5 | .\" | ||
6 | .\" Redistribution and use in source and binary forms, with or without | ||
7 | .\" modification, are permitted provided that the following conditions | ||
8 | .\" are met: | ||
9 | .\" 1. Redistributions of source code must retain the above copyright | ||
10 | .\" notice, this list of conditions and the following disclaimer. | ||
11 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
12 | .\" notice, this list of conditions and the following disclaimer in the | ||
13 | .\" documentation and/or other materials provided with the distribution. | ||
14 | .\" 3. All advertising materials mentioning features or use of this software | ||
15 | .\" must display the following acknowledgement: | ||
16 | .\" This product includes software developed by the University of | ||
17 | .\" California, Berkeley and its contributors. | ||
18 | .\" 4. Neither the name of the University nor the names of its contributors | ||
19 | .\" may be used to endorse or promote products derived from this software | ||
20 | .\" without specific prior written permission. | ||
21 | .\" | ||
22 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
23 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
24 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
25 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
26 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
27 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
28 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
29 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
30 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
31 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
32 | .\" SUCH DAMAGE. | ||
33 | .\" | ||
34 | .Dd June 4, 1993 | ||
35 | .Dt RCMD 3 | ||
36 | .Os BSD 4.2 | ||
37 | .Sh NAME | ||
38 | .Nm rcmd , | ||
39 | .Nm rresvport , | ||
40 | .Nm iruserok , | ||
41 | .Nm ruserok | ||
42 | .Nd routines for returning a stream to a remote command | ||
43 | .Sh SYNOPSIS | ||
44 | .Fd #include <unistd.h> | ||
45 | .Ft int | ||
46 | .Fn rcmd "char **ahost" "int inport" "const char *locuser" "const char *remuser" "const char *cmd" "int *fd2p" | ||
47 | .Ft int | ||
48 | .Fn rresvport "int *port" | ||
49 | .Ft int | ||
50 | .Fn iruserok "u_int32_t raddr" "int superuser" "const char *ruser" "const char *luser" | ||
51 | .Ft int | ||
52 | .Fn ruserok "const char *rhost" "int superuser" "const char *ruser" "const char *luser" | ||
53 | .Sh DESCRIPTION | ||
54 | The | ||
55 | .Fn rcmd | ||
56 | function | ||
57 | is used by the super-user to execute a command on a remote | ||
58 | machine using an authentication scheme based on reserved | ||
59 | port numbers. If the calling process is not setuid and the | ||
60 | .Li RSH | ||
61 | environment variable is set and | ||
62 | .Fa inport | ||
63 | is | ||
64 | .Li shell/tcp , | ||
65 | .Xr rcmdsh 3 | ||
66 | is called instead with the value of | ||
67 | .Li RSH . | ||
68 | Alternately, if the user is not the super-user, | ||
69 | .Fn rcmd | ||
70 | will invoke | ||
71 | .Xr rcmdsh 3 | ||
72 | to run the command via | ||
73 | .Xr rsh 1 . | ||
74 | The | ||
75 | .Fn rresvport | ||
76 | function | ||
77 | returns a descriptor to a socket | ||
78 | with an address in the privileged port space. | ||
79 | The | ||
80 | .Fn iruserok | ||
81 | and | ||
82 | .Fn ruserok | ||
83 | functions are used by servers | ||
84 | to authenticate clients requesting service with | ||
85 | .Fn rcmd . | ||
86 | All four functions are present in the same file and are used | ||
87 | by the | ||
88 | .Xr rshd 8 | ||
89 | server (among others). | ||
90 | .Pp | ||
91 | The | ||
92 | .Fn rcmd | ||
93 | function | ||
94 | looks up the host | ||
95 | .Fa *ahost | ||
96 | using | ||
97 | .Xr gethostbyname 3 , | ||
98 | returning \-1 if the host does not exist. | ||
99 | Otherwise | ||
100 | .Fa *ahost | ||
101 | is set to the standard name of the host | ||
102 | and a connection is established to a server | ||
103 | residing at the well-known Internet port | ||
104 | .Fa inport . | ||
105 | If the user is not the super-user, the only valid port is | ||
106 | .Li shell/tcp , | ||
107 | (usually port 514). | ||
108 | .Pp | ||
109 | If the connection succeeds, | ||
110 | a socket in the Internet domain of type | ||
111 | .Dv SOCK_STREAM | ||
112 | is returned to the caller, and given to the remote | ||
113 | command as | ||
114 | .Em stdin | ||
115 | and | ||
116 | .Em stdout . | ||
117 | If | ||
118 | .Fa fd2p | ||
119 | is non-zero, then an auxiliary channel to a control | ||
120 | process will be set up, and a descriptor for it will be placed | ||
121 | in | ||
122 | .Fa *fd2p . | ||
123 | The control process will return diagnostic | ||
124 | output from the command (unit 2) on this channel, and will also | ||
125 | accept bytes on this channel as being | ||
126 | .Tn UNIX | ||
127 | signal numbers, to be | ||
128 | forwarded to the process group of the command. | ||
129 | If | ||
130 | .Fa fd2p | ||
131 | is 0, then the | ||
132 | .Em stderr | ||
133 | (unit 2 of the remote | ||
134 | command) will be made the same as the | ||
135 | .Em stdout | ||
136 | and no | ||
137 | provision is made for sending arbitrary signals to the remote process, | ||
138 | although you may be able to get its attention by using out-of-band data. | ||
139 | Note that if the user is not the super-user, | ||
140 | .Fa fd2p | ||
141 | must be 0. | ||
142 | .Pp | ||
143 | The protocol is described in detail in | ||
144 | .Xr rshd 8 . | ||
145 | .Pp | ||
146 | The | ||
147 | .Fn rresvport | ||
148 | function is used to obtain a socket with a privileged | ||
149 | address bound to it. This socket is suitable for use | ||
150 | by | ||
151 | .Fn rcmd | ||
152 | and several other functions. Privileged Internet ports are those | ||
153 | in the range 0 to 1023. Only the super-user | ||
154 | is allowed to bind an address of this sort to a socket. | ||
155 | .Fn rresvport | ||
156 | needs to be seeded with a port number; if that port | ||
157 | is not available it will find another. | ||
158 | .Pp | ||
159 | The | ||
160 | .Fn iruserok | ||
161 | and | ||
162 | .Fn ruserok | ||
163 | functions take a remote host's IP address or name, respectively, | ||
164 | two user names and a flag indicating whether the local user's | ||
165 | name is that of the super-user. | ||
166 | Then, if the user is | ||
167 | .Em NOT | ||
168 | the super-user, it checks the | ||
169 | .Pa /etc/hosts.equiv | ||
170 | file. | ||
171 | If that lookup is not done, or is unsuccessful, the | ||
172 | .Pa .rhosts | ||
173 | in the local user's home directory is checked to see if the request for | ||
174 | service is allowed. | ||
175 | .Pp | ||
176 | If this file does not exist, is not a regular file, is owned by anyone | ||
177 | other than the user or the super-user, or is writeable by anyone other | ||
178 | than the owner, the check automatically fails. | ||
179 | Zero is returned if the machine name is listed in the | ||
180 | .Dq Pa hosts.equiv | ||
181 | file, or the host and remote user name are found in the | ||
182 | .Dq Pa .rhosts | ||
183 | file; otherwise | ||
184 | .Fn iruserok | ||
185 | and | ||
186 | .Fn ruserok | ||
187 | return \-1. | ||
188 | If the local domain (as obtained from | ||
189 | .Xr gethostname 3 ) | ||
190 | is the same as the remote domain, only the machine name need be specified. | ||
191 | .Pp | ||
192 | If the IP address of the remote host is known, | ||
193 | .Fn iruserok | ||
194 | should be used in preference to | ||
195 | .Fn ruserok , | ||
196 | as it does not require trusting the DNS server for the remote host's domain. | ||
197 | .Sh DIAGNOSTICS | ||
198 | The | ||
199 | .Fn rcmd | ||
200 | function | ||
201 | returns a valid socket descriptor on success. | ||
202 | It returns \-1 on error and prints a diagnostic message on the standard error. | ||
203 | .Pp | ||
204 | The | ||
205 | .Fn rresvport | ||
206 | function | ||
207 | returns a valid, bound socket descriptor on success. | ||
208 | It returns \-1 on error with the global value | ||
209 | .Va errno | ||
210 | set according to the reason for failure. | ||
211 | The error code | ||
212 | .Dv EAGAIN | ||
213 | is overloaded to mean ``All network ports in use.'' | ||
214 | .Sh SEE ALSO | ||
215 | .Xr rlogin 1 , | ||
216 | .Xr rsh 1 , | ||
217 | .Xr intro 2 , | ||
218 | .Xr rexec 3 , | ||
219 | .Xr rcmdsh 3 , | ||
220 | .Xr rexecd 8 , | ||
221 | .Xr rlogind 8 , | ||
222 | .Xr bindresvport 3 , | ||
223 | .Xr rshd 8 | ||
224 | .Sh HISTORY | ||
225 | These | ||
226 | functions appeared in | ||
227 | .Bx 4.2 . | ||