]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/rcmd.3
proc.5: Note kernel version for /proc/PID/smaps VmFlags "wf" flag
[thirdparty/man-pages.git] / man3 / rcmd.3
1 .\" $NetBSD: rcmd.3,v 1.9 1996/05/28 02:07:39 mrg Exp $
2 .\"
3 .\" Copyright (c) 1983, 1991, 1993
4 .\" The Regents of the University of California. All rights reserved.
5 .\"
6 .\" %%%LICENSE_START(BSD_4_CLAUSE_UCB)
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
9 .\" are met:
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\" notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\" notice, this list of conditions and the following disclaimer in the
14 .\" documentation and/or other materials provided with the distribution.
15 .\" 3. All advertising materials mentioning features or use of this software
16 .\" must display the following acknowledgement:
17 .\" This product includes software developed by the University of
18 .\" California, Berkeley and its contributors.
19 .\" 4. Neither the name of the University nor the names of its contributors
20 .\" may be used to endorse or promote products derived from this software
21 .\" without specific prior written permission.
22 .\"
23 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 .\" SUCH DAMAGE.
34 .\" %%%LICENSE_END
35 .\"
36 .\" @(#)rcmd.3 8.1 (Berkeley) 6/4/93
37 .\"
38 .\" Contributed as Linux man page by David A. Holland, 970908
39 .\" I have not checked whether the Linux situation is exactly the same.
40 .\"
41 .\" 2007-12-08, mtk, Converted from mdoc to man macros
42 .\"
43 .TH RCMD 3 2017-09-15 "Linux" "Linux Programmer's Manual"
44 .SH NAME
45 rcmd, rresvport, iruserok, ruserok, rcmd_af,
46 rresvport_af, iruserok_af, ruserok_af \- routines for returning a
47 stream to a remote command
48 .SH SYNOPSIS
49 .nf
50 .B #include <netdb.h> \ \ \fP/* Or <unistd.h> on some systems */
51 .PP
52 .BI "int rcmd(char **" ahost ", unsigned short " inport ", const char *" locuser ", "
53 .BI " const char *" remuser ", const char *" cmd ", int *" fd2p );
54 .PP
55 .BI "int rresvport(int *" port );
56 .PP
57 .BI "int iruserok(uint32_t " raddr ", int " superuser ", "
58 .BI " const char *" ruser ", const char *" luser );
59 .PP
60 .BI "int ruserok(const char *" rhost ", int " superuser ", "
61 .BI " const char *" ruser ", const char *" luser );
62 .PP
63 .BI "int rcmd_af(char **" ahost ", unsigned short " inport ", const char *" locuser ", "
64 .BI " const char *" remuser ", const char *" cmd ", int *" fd2p ,
65 .BI " sa_family_t " af );
66 .PP
67 .BI "int rresvport_af(int *" port ", sa_family_t " af );
68 .PP
69 .BI "int iruserok_af(const void *" raddr ", int " superuser ", "
70 .BI " const char *" ruser ", const char *" luser \
71 ", sa_family_t " af );
72 .PP
73 .BI "int ruserok_af(const char *" rhost ", int " superuser ", "
74 .BI " const char *" ruser ", const char *" luser \
75 ", sa_family_t " af );
76 .fi
77 .PP
78 .in -4n
79 Feature Test Macro Requirements for glibc (see
80 .BR feature_test_macros (7)):
81 .in
82 .PP
83 .BR rcmd (),
84 .BR rcmd_af (),
85 .BR rresvport (),
86 .BR rresvport_af (),
87 .BR iruserok (),
88 .BR iruserok_af (),
89 .BR ruserok (),
90 .BR ruserok_af ():
91 Since glibc 2.19:
92 _DEFAULT_SOURCE
93 Glibc 2.19 and earlier:
94 _BSD_SOURCE
95 .SH DESCRIPTION
96 The
97 .BR rcmd ()
98 function is used by the superuser to execute a command on
99 a remote machine using an authentication scheme based
100 on privileged port numbers.
101 The
102 .BR rresvport ()
103 function
104 returns a file descriptor to a socket
105 with an address in the privileged port space.
106 The
107 .BR iruserok ()
108 and
109 .BR ruserok ()
110 functions are used by servers
111 to authenticate clients requesting service with
112 .BR rcmd ().
113 All four functions are used by the
114 .BR rshd (8)
115 server (among others).
116 .SS rcmd()
117 .PP
118 The
119 .BR rcmd ()
120 function
121 looks up the host
122 .I *ahost
123 using
124 .BR gethostbyname (3),
125 returning \-1 if the host does not exist.
126 Otherwise,
127 .I *ahost
128 is set to the standard name of the host
129 and a connection is established to a server
130 residing at the well-known Internet port
131 .IR inport .
132 .PP
133 If the connection succeeds,
134 a socket in the Internet domain of type
135 .BR SOCK_STREAM
136 is returned to the caller, and given to the remote
137 command as
138 .IR stdin
139 and
140 .IR stdout .
141 If
142 .I fd2p
143 is nonzero, then an auxiliary channel to a control
144 process will be set up, and a file descriptor for it will be placed
145 in
146 .IR *fd2p .
147 The control process will return diagnostic
148 output from the command (unit 2) on this channel, and will also
149 accept bytes on this channel as being UNIX signal numbers, to be
150 forwarded to the process group of the command.
151 If
152 .I fd2p
153 is 0, then the
154 .IR stderr
155 (unit 2 of the remote
156 command) will be made the same as the
157 .IR stdout
158 and no
159 provision is made for sending arbitrary signals to the remote process,
160 although you may be able to get its attention by using out-of-band data.
161 .PP
162 The protocol is described in detail in
163 .BR rshd (8).
164 .SS rresvport()
165 .PP
166 The
167 .BR rresvport ()
168 function is used to obtain a socket with a privileged
169 port bound to it.
170 This socket is suitable for use by
171 .BR rcmd ()
172 and several other functions.
173 Privileged ports are those in the range 0 to 1023.
174 Only a privileged process
175 (on Linux: a process that has the
176 .B CAP_NET_BIND_SERVICE
177 capability in the user namespace governing its network namespace).
178 is allowed to bind to a privileged port.
179 In the glibc implementation,
180 this function restricts its search to the ports from 512 to 1023.
181 The
182 .I port
183 argument is value-result:
184 the value it supplies to the call is used as the starting point
185 for a circular search of the port range;
186 on (successful) return, it contains the port number that was bound to.
187 .\"
188 .SS iruserok() and ruserok()
189 .PP
190 The
191 .BR iruserok ()
192 and
193 .BR ruserok ()
194 functions take a remote host's IP address or name, respectively,
195 two usernames and a flag indicating whether the local user's
196 name is that of the superuser.
197 Then, if the user is
198 .I not
199 the superuser, it checks the
200 .IR /etc/hosts.equiv
201 file.
202 If that lookup is not done, or is unsuccessful, the
203 .IR .rhosts
204 in the local user's home directory is checked to see if the request for
205 service is allowed.
206 .PP
207 If this file does not exist, is not a regular file, is owned by anyone
208 other than the user or the superuser, is writable by anyone other
209 than the owner, or is hardlinked anywhere, the check automatically fails.
210 Zero is returned if the machine name is listed in the
211 .IR hosts.equiv
212 file, or the host and remote username are found in the
213 .IR .rhosts
214 file; otherwise
215 .BR iruserok ()
216 and
217 .BR ruserok ()
218 return \-1.
219 If the local domain (as obtained from
220 .BR gethostname (2))
221 is the same as the remote domain, only the machine name need be specified.
222 .PP
223 If the IP address of the remote host is known,
224 .BR iruserok ()
225 should be used in preference to
226 .BR ruserok (),
227 as it does not require trusting the DNS server for the remote host's domain.
228 .SS *_af() variants
229 All of the functions described above work with IPv4
230 .RB ( AF_INET )
231 sockets.
232 The "_af" variants take an extra argument that allows the
233 socket address family to be specified.
234 For these functions, the
235 .I af
236 argument can be specified as
237 .BR AF_INET
238 or
239 .BR AF_INET6 .
240 In addition,
241 .BR rcmd_af ()
242 supports the use of
243 .BR AF_UNSPEC .
244 .SH RETURN VALUE
245 The
246 .BR rcmd ()
247 function
248 returns a valid socket descriptor on success.
249 It returns \-1 on error and prints a diagnostic message on the standard error.
250 .PP
251 The
252 .BR rresvport ()
253 function
254 returns a valid, bound socket descriptor on success.
255 It returns \-1 on error with the global value
256 .I errno
257 set according to the reason for failure.
258 The error code
259 .BR EAGAIN
260 is overloaded to mean "All network ports in use."
261 .PP
262 For information on the return from
263 .BR ruserok ()
264 and
265 .BR iruserok (),
266 see above.
267 .SH VERSIONS
268 The functions
269 .BR iruserok_af (),
270 .BR rcmd_af (),
271 .BR rresvport_af (),
272 and
273 .BR ruserok_af ()
274 functions are provide in glibc since version 2.2.
275 .SH ATTRIBUTES
276 For an explanation of the terms used in this section, see
277 .BR attributes (7).
278 .TS
279 allbox;
280 lbw27 lb lb
281 l l l.
282 Interface Attribute Value
283 T{
284 .BR rcmd (),
285 .BR rcmd_af ()
286 T} Thread safety MT-Unsafe
287 T{
288 .BR rresvport (),
289 .BR rresvport_af ()
290 T} Thread safety MT-Safe
291 T{
292 .BR iruserok (),
293 .BR ruserok (),
294 .br
295 .BR iruserok_af (),
296 .BR ruserok_af ()
297 T} Thread safety MT-Safe locale
298 .TE
299 .sp 1
300 .SH CONFORMING TO
301 Not in POSIX.1.
302 Present on the BSDs, Solaris, and many other systems.
303 These
304 functions appeared in
305 4.2BSD.
306 The "_af" variants are more recent additions,
307 and are not present on as wide a range of systems.
308 .SH BUGS
309 .BR iruserok ()
310 and
311 .BR iruserok_af ()
312 are declared in glibc headers only since version 2.12.
313 .\" Bug filed 25 Nov 2007:
314 .\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=5399
315 .SH SEE ALSO
316 .BR rlogin (1),
317 .BR rsh (1),
318 .BR intro (2),
319 .BR rexec (3),
320 .BR rexecd (8),
321 .BR rlogind (8),
322 .BR rshd (8)