Commit | Line | Data |
---|---|---|
af359dea | 1 | .\" Copyright (c) 1983, 1991 The Regents of the University of California. |
d20a1e6f | 2 | .\" All rights reserved. |
11a95b5f | 3 | .\" |
af359dea C |
4 | .\" Redistribution and use in source and binary forms, with or without |
5 | .\" modification, are permitted provided that the following conditions | |
6 | .\" are met: | |
7 | .\" 1. Redistributions of source code must retain the above copyright | |
8 | .\" notice, this list of conditions and the following disclaimer. | |
9 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
10 | .\" notice, this list of conditions and the following disclaimer in the | |
11 | .\" documentation and/or other materials provided with the distribution. | |
12 | .\" 3. All advertising materials mentioning features or use of this software | |
13 | .\" must display the following acknowledgement: | |
14 | .\" This product includes software developed by the University of | |
15 | .\" California, Berkeley and its contributors. | |
16 | .\" 4. Neither the name of the University nor the names of its contributors | |
17 | .\" may be used to endorse or promote products derived from this software | |
18 | .\" without specific prior written permission. | |
d20a1e6f | 19 | .\" |
af359dea C |
20 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
21 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
22 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
23 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
24 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
25 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
26 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
27 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
28 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
29 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
30 | .\" SUCH DAMAGE. | |
11a95b5f | 31 | .\" |
af359dea C |
32 | .\" @(#)rcmd.3 6.11 (Berkeley) 4/19/91 |
33 | .\" | |
34 | .Dd April 19, 1991 | |
35 | .Dt RCMD 3 | |
36 | .Os BSD 4.2 | |
37 | .Sh NAME | |
38 | .Nm rcmd , | |
39 | .Nm rresvport , | |
40 | .Nm ruserok | |
41 | .Nd routines for returning a stream to a remote command | |
42 | .Sh SYNOPSIS | |
43 | .Fd #include <unistd.h> | |
44 | .Ft int | |
45 | .Fn rcmd "char **ahost" "int inport" "const char *locuser" "const char *remuser" "const char *cmd" "int *fd2p" | |
46 | .Ft int | |
47 | .Fn rresvport "int *port" | |
48 | .Ft int | |
49 | .Fn ruserok "const char *rhost" "int superuser" "const char *ruser" "const char *luser" | |
50 | .Sh DESCRIPTION | |
51 | The | |
52 | .Fn rcmd | |
53 | function | |
54 | is used by the super-user to execute a command on | |
11a95b5f KM |
55 | a remote machine using an authentication scheme based |
56 | on reserved port numbers. | |
af359dea C |
57 | The |
58 | .Fn rresvport | |
59 | function | |
60 | returns a descriptor to a socket | |
11a95b5f | 61 | with an address in the privileged port space. |
af359dea C |
62 | The |
63 | .Fn ruserok | |
64 | function | |
65 | is used by servers | |
11a95b5f | 66 | to authenticate clients requesting service with |
af359dea | 67 | .Fn rcmd . |
11a95b5f KM |
68 | All three functions are present in the same file and are used |
69 | by the | |
af359dea | 70 | .Xr rshd 8 |
11a95b5f | 71 | server (among others). |
af359dea C |
72 | .Pp |
73 | The | |
74 | .Fn rcmd | |
75 | function | |
11a95b5f | 76 | looks up the host |
af359dea | 77 | .Fa *ahost |
11a95b5f | 78 | using |
af359dea | 79 | .Xr gethostbyname 3 , |
11a95b5f KM |
80 | returning \-1 if the host does not exist. |
81 | Otherwise | |
af359dea | 82 | .Fa *ahost |
11a95b5f KM |
83 | is set to the standard name of the host |
84 | and a connection is established to a server | |
85 | residing at the well-known Internet port | |
af359dea C |
86 | .Fa inport . |
87 | .Pp | |
7faf4e1f | 88 | If the connection succeeds, |
af359dea C |
89 | a socket in the Internet domain of type |
90 | .Dv SOCK_STREAM | |
11a95b5f KM |
91 | is returned to the caller, and given to the remote |
92 | command as | |
af359dea | 93 | .Em stdin |
11a95b5f | 94 | and |
af359dea | 95 | .Em stdout . |
11a95b5f | 96 | If |
af359dea | 97 | .Fa fd2p |
11a95b5f KM |
98 | is non-zero, then an auxiliary channel to a control |
99 | process will be set up, and a descriptor for it will be placed | |
100 | in | |
af359dea | 101 | .Fa *fd2p . |
11a95b5f KM |
102 | The control process will return diagnostic |
103 | output from the command (unit 2) on this channel, and will also | |
af359dea C |
104 | accept bytes on this channel as being |
105 | .Tn UNIX | |
106 | signal numbers, to be | |
11a95b5f KM |
107 | forwarded to the process group of the command. |
108 | If | |
af359dea | 109 | .Fa fd2p |
11a95b5f | 110 | is 0, then the |
af359dea | 111 | .Em stderr |
11a95b5f KM |
112 | (unit 2 of the remote |
113 | command) will be made the same as the | |
af359dea | 114 | .Em stdout |
11a95b5f KM |
115 | and no |
116 | provision is made for sending arbitrary signals to the remote process, | |
117 | although you may be able to get its attention by using out-of-band data. | |
af359dea | 118 | .Pp |
11a95b5f | 119 | The protocol is described in detail in |
af359dea C |
120 | .Xr rshd 8 . |
121 | .Pp | |
11a95b5f | 122 | The |
af359dea C |
123 | .Fn rresvport |
124 | function is used to obtain a socket with a privileged | |
11a95b5f KM |
125 | address bound to it. This socket is suitable for use |
126 | by | |
af359dea C |
127 | .Fn rcmd |
128 | and several other functions. Privileged Internet ports are those | |
7faf4e1f | 129 | in the range 0 to 1023. Only the super-user |
11a95b5f | 130 | is allowed to bind an address of this sort to a socket. |
af359dea C |
131 | .Pp |
132 | The | |
133 | .Fn ruserok | |
134 | argument | |
d20a1e6f | 135 | takes a remote host's name, as returned by the |
af359dea | 136 | .Xr gethostbyaddr 3 |
7faf4e1f | 137 | routine, two user names and a flag indicating whether |
d20a1e6f KB |
138 | the local user's name is that of the super-user. Then, |
139 | if the user is | |
af359dea | 140 | .Em NOT |
d20a1e6f | 141 | the super-user, it checks the files |
af359dea | 142 | .Pa /etc/hosts.equiv . |
d20a1e6f | 143 | If that lookup is not done, or is unsuccessful, the |
af359dea | 144 | .Pa .rhosts |
d20a1e6f KB |
145 | in the local user's home directory is checked to see if the request for |
146 | service is allowed. If this file is owned by anyone other than the | |
147 | user or the super-user, or if it is writeable by anyone other than the | |
148 | owner, the check automatically fails. A 0 is returned if the machine | |
af359dea C |
149 | name is listed in the |
150 | .Dq Pa hosts.equiv | |
151 | file, or the host and remote | |
152 | user name are found in the | |
153 | .Dq Pa .rhosts | |
154 | file; otherwise | |
155 | .Fn ruserok | |
d20a1e6f | 156 | returns \-1. |
af359dea C |
157 | If the local domain (as obtained from |
158 | .Xr gethostname 2 ) | |
0609943c | 159 | is the same as the remote domain, only the machine name need be specified. |
af359dea C |
160 | .Sh DIAGNOSTICS |
161 | The | |
162 | .Fn rcmd | |
163 | function | |
7faf4e1f | 164 | returns a valid socket descriptor on success. |
af359dea C |
165 | It returns \-1 on error and prints a diagnostic message on the standard error. |
166 | .Pp | |
167 | The | |
168 | .Fn rresvport | |
169 | function | |
7faf4e1f | 170 | returns a valid, bound socket descriptor on success. |
af359dea C |
171 | It returns \-1 on error with the global value |
172 | .Va errno | |
7faf4e1f | 173 | set according to the reason for failure. |
af359dea C |
174 | The error code |
175 | .Dv EAGAIN | |
176 | is overloaded to mean ``All network ports in use.'' | |
177 | .Sh SEE ALSO | |
178 | .Xr rlogin 1 , | |
179 | .Xr rsh 1 , | |
180 | .Xr intro 2 , | |
181 | .Xr rexec 3 , | |
182 | .Xr rexecd 8 , | |
183 | .Xr rlogind 8 , | |
184 | .Xr rshd 8 | |
185 | .Sh HISTORY | |
186 | These | |
187 | functions appeared in | |
188 | .Bx 4.2 . |