]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/rexec.3
err.3: EXAMPLES: use EXIT_FAILURE rather than 1 as exit status
[thirdparty/man-pages.git] / man3 / rexec.3
CommitLineData
9a562e42
MK
1.\" Copyright (c) 1983, 1991, 1993
2.\" The Regents of the University of California. All rights reserved.
3.\"
a9cd9cb7 4.\" %%%LICENSE_START(BSD_4_CLAUSE_UCB)
9a562e42
MK
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\" notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\" notice, this list of conditions and the following disclaimer in the
12.\" documentation and/or other materials provided with the distribution.
13.\" 3. All advertising materials mentioning features or use of this software
14.\" must display the following acknowledgement:
15.\" This product includes software developed by the University of
16.\" California, Berkeley and its contributors.
17.\" 4. Neither the name of the University nor the names of its contributors
18.\" may be used to endorse or promote products derived from this software
19.\" without specific prior written permission.
20.\"
21.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31.\" SUCH DAMAGE.
8c9302dc 32.\" %%%LICENSE_END
9a562e42
MK
33.\"
34.\" @(#)rexec.3 8.1 (Berkeley) 6/4/93
35.\" $FreeBSD: src/lib/libcompat/4.3/rexec.3,v 1.12 2004/07/02 23:52:14 ru Exp $
36.\"
0bd5e3de
MK
37.\" Taken from FreeBSD 5.4; not checked against Linux reality (mtk)
38.\"
f9293d98 39.\" 2013-06-21, mtk, Converted from mdoc to man macros
3233d665 40.\"
4b8c67d9 41.TH REXEC 3 2017-09-15 "Linux" "Linux Programmer's Manual"
3233d665 42.SH NAME
5e3431cd 43rexec, rexec_af \- return stream to a remote command
3233d665
MK
44.SH SYNOPSIS
45.nf
090e0f8c 46.B #include <netdb.h>
68e4db0a 47.PP
38cea4d1
RV
48.BI "int rexec(char **" ahost ", int " inport ", const char *" user ", "
49.BI " const char *" passwd ", const char *" cmd ", int *" fd2p );
68e4db0a 50.PP
38cea4d1
RV
51.BI "int rexec_af(char **" ahost ", int " inport ", const char *" user ", "
52.BI " const char *" passwd ", const char *" cmd ", int *" fd2p ,
4cd4a6f8 53.BI " sa_family_t " af );
3233d665 54.fi
68e4db0a 55.PP
7f0ec8ee
MK
56.BR rexec (),
57.BR rexec_af ():
58.nf
59 Since glibc 2.19:
60 _DEFAULT_SOURCE
61 In glibc up to and including 2.19:
62 _BSD_SOURCE
63.fi
3233d665 64.SH DESCRIPTION
9a562e42 65This interface is obsoleted by
3233d665 66.BR rcmd (3).
847e0d88 67.PP
9a562e42 68The
3233d665 69.BR rexec ()
9a562e42
MK
70function
71looks up the host
3233d665 72.IR *ahost
9a562e42 73using
3233d665 74.BR gethostbyname (3),
9a562e42 75returning \-1 if the host does not exist.
2b9b829d 76Otherwise,
3233d665 77.IR *ahost
9a562e42
MK
78is set to the standard name of the host.
79If a username and password are both specified, then these
80are used to authenticate to the foreign host; otherwise
886ea57d 81the environment and then the
3233d665 82.I .netrc
886ea57d 83file in user's
9a562e42
MK
84home directory are searched for appropriate information.
85If all this fails, the user is prompted for the information.
5ec60461 86.PP
9a562e42 87The port
3233d665 88.I inport
f084be74 89specifies which well-known DARPA Internet port to use for
9a562e42 90the connection; the call
ad2f1d0b 91.I "getservbyname(""exec"", ""tcp"")"
9a562e42 92(see
3233d665 93.BR getservent (3))
f084be74 94will return a pointer to a structure that contains the necessary port.
9a562e42 95The protocol for connection is described in detail in
3233d665 96.BR rexecd (8).
5ec60461 97.PP
9a562e42
MK
98If the connection succeeds,
99a socket in the Internet domain of type
3233d665 100.BR SOCK_STREAM
9a562e42
MK
101is returned to
102the caller, and given to the remote command as
3233d665 103.IR stdin
9a562e42 104and
3233d665 105.IR stdout .
9a562e42 106If
3233d665 107.I fd2p
c7094399 108is nonzero, then an auxiliary channel to a control
d9cb0d7d 109process will be setup, and a file descriptor for it will be placed
9a562e42 110in
3233d665 111.IR *fd2p .
9a562e42
MK
112The control process will return diagnostic
113output from the command (unit 2) on this channel, and will also
008f1ecc 114accept bytes on this channel as being UNIX signal numbers, to be
9a562e42
MK
115forwarded to the process group of the command.
116The diagnostic
117information returned does not include remote authorization failure,
118as the secondary connection is set up after authorization has been
119verified.
120If
3233d665 121.I fd2p
9a562e42 122is 0, then the
3233d665 123.IR stderr
9a562e42
MK
124(unit 2 of the remote
125command) will be made the same as the
3233d665 126.IR stdout
9a562e42
MK
127and no
128provision is made for sending arbitrary signals to the remote process,
129although you may be able to get its attention by using out-of-band data.
4cd4a6f8
MK
130.SS rexec_af()
131The
132.BR rexec ()
133function works over IPv4
134.RB ( AF_INET ).
135By contrast, the
136.BR rexec_af ()
137function provides an extra argument,
138.IR af ,
139that allows the caller to select the protocol.
140This argument can be specified as
141.BR AF_INET ,
142.BR AF_INET6 ,
143or
144.BR AF_UNSPEC
145(to allow the implementation to select the protocol).
146.SH VERSIONS
147The
148.BR rexec_af ()
149function was added to glibc in version 2.2.
d5062112 150.SH ATTRIBUTES
a852f4e0
PH
151For an explanation of the terms used in this section, see
152.BR attributes (7).
153.TS
154allbox;
155lbw19 lb lb
156l l l.
157Interface Attribute Value
158T{
159.BR rexec (),
d5062112 160.BR rexec_af ()
a852f4e0
PH
161T} Thread safety MT-Unsafe
162.TE
47297adb 163.SH CONFORMING TO
407b8585 164These functions are not in POSIX.1.
9a562e42 165The
3233d665 166.BR rexec ()
4cd4a6f8
MK
167function first appeared in
1684.2BSD, and is present on the BSDs, Solaris, and many other systems.
169The
170.BR rexec_af ()
6336b547 171function is more recent, and less widespread.
3233d665 172.SH BUGS
9a562e42 173The
3233d665 174.BR rexec ()
9a562e42 175function sends the unencrypted password across the network.
5ec60461 176.PP
9a562e42 177The underlying service is considered a big security hole and therefore
ed987e2e 178not enabled on many sites; see
3233d665 179.BR rexecd (8)
9a562e42 180for explanations.
3233d665
MK
181.SH SEE ALSO
182.BR rcmd (3),
183.BR rexecd (8)