1 .\" Copyright (c) 1983, 1991, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
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. Neither the name of the University nor the names of its contributors
13 .\" may be used to endorse or promote products derived from this software
14 .\" without specific prior written permission.
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 .\" From: @(#)rcmd.3 8.1 (Berkeley) 6/4/93
29 .\" $FreeBSD: src/lib/libc/net/rcmd.3,v 1.27 2008/12/14 22:48:48 murray Exp $
30 .\" $DragonFly: src/lib/libc/net/rcmd.3,v 1.4 2007/11/23 23:16:36 swildner Exp $
43 .Nd routines for returning a stream to a remote command
49 .Fn rcmd "char **ahost" "int inport" "const char *locuser" "const char *remuser" "const char *cmd" "int *fd2p"
51 .Fn rresvport "int *port"
53 .Fn iruserok "u_long raddr" "int superuser" "const char *ruser" "const char *luser"
55 .Fn ruserok "const char *rhost" "int superuser" "const char *ruser" "const char *luser"
57 .Fn rcmd_af "char **ahost" "int inport" "const char *locuser" "const char *remuser" "const char *cmd" "int *fd2p" "int af"
59 .Fn rresvport_af "int *port" "int af"
61 .Fn iruserok_sa "const void *addr" "int addrlen" "int superuser" "const char *ruser" "const char *luser"
66 is used by the super-user to execute a command on
67 a remote machine using an authentication scheme based
68 on reserved port numbers.
72 returns a descriptor to a socket
73 with an address in the privileged port space.
78 to authenticate clients requesting service with
80 All three functions are present in the same file and are used
83 server (among others).
92 returning -1 if the host does not exist.
95 is set to the standard name of the host
96 and a connection is established to a server
97 residing at the well-known Internet port
100 If the connection succeeds,
101 a socket in the Internet domain of type
103 is returned to the caller, and given to the remote
110 is non-zero, then an auxiliary channel to a control
111 process will be set up, and a descriptor for it will be placed
114 The control process will return diagnostic
115 output from the command (unit 2) on this channel, and will also
116 accept bytes on this channel as being
118 signal numbers, to be
119 forwarded to the process group of the command.
124 (unit 2 of the remote
125 command) will be made the same as the
128 provision is made for sending arbitrary signals to the remote process,
129 although you may be able to get its attention by using out-of-band data.
131 The protocol is described in detail in
136 function is used to obtain a socket to which an address with a Privileged
137 Internet port is bound.
138 This socket is suitable for use by
140 and several other functions.
141 Privileged Internet ports are those in the range 0 to 1023.
142 Only the super-user is allowed to bind an address of this sort
149 functions take a remote host's IP address or name, as returned by the
151 routines, two user names and a flag indicating whether the local user's
152 name is that of the super-user.
155 the super-user, it checks the
158 If that lookup is not done, or is unsuccessful, the
160 in the local user's home directory is checked to see if the request for
163 If this file does not exist, is not a regular file, is owned by anyone
164 other than the user or the super-user, or is writable by anyone other
165 than the owner, the check automatically fails.
166 Zero is returned if the machine name is listed in the
168 file, or the host and remote user name are found in the
175 If the local domain (as obtained from
177 is the same as the remote domain, only the machine name need be specified.
181 function is strongly preferred for security reasons.
182 It requires trusting the local DNS at most, while the
184 function requires trusting the entire DNS, which can be spoofed.
186 The functions with an
195 work the same as the corresponding functions without a
196 suffix, except that they are capable of handling both IPv6 and IPv4 ports.
200 suffix means that the function has an additional
202 argument which is used to specify the address family,
206 argument extension is implemented for functions
207 that have no binary address argument.
210 argument specifies which address family is desired.
214 suffix means that the function has general socket address and
216 As the socket address is a protocol independent data structure,
217 IPv4 and IPv6 socket address can be passed as desired.
220 argument extension is implemented for functions
221 that pass a protocol dependent binary address argument.
222 The argument needs to be replaced with a more general address structure
223 to support multiple address families in a general way.
225 The functions with neither an
229 suffix work for IPv4 only, except for
231 which can handle both IPv6 and IPv4.
232 To switch the address family, the
234 argument must be filled with
247 function, this variable is used as the program to run instead of
254 returns a valid socket descriptor on success.
255 It returns -1 on error and prints a diagnostic message
256 on the standard error.
261 returns a valid, bound socket descriptor on success.
262 It returns -1 on error with the global value
264 set according to the reason for failure.
267 is overloaded to mean ``All network ports in use.''
277 .%T "Advanced Socket API for IPv6"
284 .%T "Advanced Socket API for IPv6"
289 functions appeared in
294 appeared in RFC 2292, and was implemented by the WIDE project
295 for the Hydrangea IPv6 protocol stack kit.
299 appeared in draft-ietf-ipngwg-rfc2292bis-01.txt,
300 and was implemented in the WIDE/KAME IPv6 protocol stack kit.
304 appeared in discussion on the IETF ipngwg mailing list,
305 and was implemented in