| 1 |
'\" t |
| 2 |
.\" Copyright 1983-1993, The Regents of the University of California. |
| 3 |
.\" Copyright, the authors of the Linux man-pages project |
| 4 |
.\" |
| 5 |
.\" SPDX-License-Identifier: BSD-4-Clause-UC |
| 6 |
.\" |
| 7 |
.TH rexec 3 2025-09-21 "Linux man-pages 6.18" |
| 8 |
.SH NAME |
| 9 |
rexec, rexec_af \- return stream to a remote command |
| 10 |
.SH LIBRARY |
| 11 |
Standard C library |
| 12 |
.RI ( libc ,\~ \-lc ) |
| 13 |
.SH SYNOPSIS |
| 14 |
.nf |
| 15 |
.B #include <netdb.h> |
| 16 |
.P |
| 17 |
.B [[deprecated]] |
| 18 |
.BI "int rexec(char **restrict " ahost ", int " inport , |
| 19 |
.BI " const char *restrict " user ", const char *restrict " passwd , |
| 20 |
.BI " const char *restrict " cmd ", int *restrict " fd2p ); |
| 21 |
.P |
| 22 |
.B [[deprecated]] |
| 23 |
.BI "int rexec_af(char **restrict " ahost ", int " inport , |
| 24 |
.BI " const char *restrict " user ", const char *restrict " passwd , |
| 25 |
.BI " const char *restrict " cmd ", int *restrict " fd2p , |
| 26 |
.BI " sa_family_t " af ); |
| 27 |
.fi |
| 28 |
.P |
| 29 |
.BR rexec (), |
| 30 |
.BR rexec_af (): |
| 31 |
.nf |
| 32 |
Since glibc 2.19: |
| 33 |
_DEFAULT_SOURCE |
| 34 |
In glibc up to and including 2.19: |
| 35 |
_BSD_SOURCE |
| 36 |
.fi |
| 37 |
.SH DESCRIPTION |
| 38 |
This interface is obsoleted by |
| 39 |
.BR rcmd (3). |
| 40 |
.P |
| 41 |
The |
| 42 |
.BR rexec () |
| 43 |
function |
| 44 |
looks up the host |
| 45 |
.I *ahost |
| 46 |
using |
| 47 |
.BR gethostbyname (3), |
| 48 |
returning \-1 if the host does not exist. |
| 49 |
Otherwise, |
| 50 |
.I *ahost |
| 51 |
is set to the standard name of the host. |
| 52 |
If a username and password are both specified, |
| 53 |
then these are used |
| 54 |
to authenticate to the foreign host; |
| 55 |
otherwise, |
| 56 |
the environment and then the |
| 57 |
.I .netrc |
| 58 |
file in user's home directory |
| 59 |
are searched for appropriate information. |
| 60 |
If all this fails, |
| 61 |
the user is prompted for the information. |
| 62 |
.P |
| 63 |
The port |
| 64 |
.I inport |
| 65 |
specifies which well-known DARPA Internet port to use |
| 66 |
for the connection; |
| 67 |
the call |
| 68 |
.I "getservbyname(""exec"", ""tcp"")" |
| 69 |
(see |
| 70 |
.BR getservent (3)) |
| 71 |
will return a pointer to a structure that contains the necessary port. |
| 72 |
The protocol for connection is described in detail in |
| 73 |
.BR rexecd (8). |
| 74 |
.P |
| 75 |
If the connection succeeds, |
| 76 |
a socket in the Internet domain of type |
| 77 |
.B SOCK_STREAM |
| 78 |
is returned to |
| 79 |
the caller, and given to the remote command as |
| 80 |
.I stdin |
| 81 |
and |
| 82 |
.IR stdout . |
| 83 |
If |
| 84 |
.I fd2p |
| 85 |
is nonzero, then an auxiliary channel to a control |
| 86 |
process will be setup, and a file descriptor for it will be placed |
| 87 |
in |
| 88 |
.IR *fd2p . |
| 89 |
The control process will return diagnostic |
| 90 |
output from the command (unit 2) on this channel, and will also |
| 91 |
accept bytes on this channel as being UNIX signal numbers, to be |
| 92 |
forwarded to the process group of the command. |
| 93 |
The diagnostic |
| 94 |
information returned does not include remote authorization failure, |
| 95 |
as the secondary connection is set up after authorization has been |
| 96 |
verified. |
| 97 |
If |
| 98 |
.I fd2p |
| 99 |
is 0, then the |
| 100 |
.I stderr |
| 101 |
(unit 2 of the remote |
| 102 |
command) will be made the same as the |
| 103 |
.I stdout |
| 104 |
and no |
| 105 |
provision is made for sending arbitrary signals to the remote process, |
| 106 |
although you may be able to get its attention by using out-of-band data. |
| 107 |
.SS rexec_af() |
| 108 |
The |
| 109 |
.BR rexec () |
| 110 |
function works over IPv4 |
| 111 |
.RB ( AF_INET ). |
| 112 |
By contrast, the |
| 113 |
.BR rexec_af () |
| 114 |
function provides an extra argument, |
| 115 |
.IR af , |
| 116 |
that allows the caller to select the protocol. |
| 117 |
This argument can be specified as |
| 118 |
.BR AF_INET , |
| 119 |
.BR AF_INET6 , |
| 120 |
or |
| 121 |
.B AF_UNSPEC |
| 122 |
(to allow the implementation to select the protocol). |
| 123 |
.SH ATTRIBUTES |
| 124 |
For an explanation of the terms used in this section, see |
| 125 |
.BR attributes (7). |
| 126 |
.TS |
| 127 |
allbox; |
| 128 |
lbx lb lb |
| 129 |
l l l. |
| 130 |
Interface Attribute Value |
| 131 |
T{ |
| 132 |
.na |
| 133 |
.nh |
| 134 |
.BR rexec (), |
| 135 |
.BR rexec_af () |
| 136 |
T} Thread safety MT-Unsafe |
| 137 |
.TE |
| 138 |
.SH STANDARDS |
| 139 |
None. |
| 140 |
.SH HISTORY |
| 141 |
.TP |
| 142 |
.BR rexec () |
| 143 |
4.2BSD, BSD, Solaris. |
| 144 |
.TP |
| 145 |
.BR rexec_af () |
| 146 |
glibc 2.2. |
| 147 |
.SH BUGS |
| 148 |
The |
| 149 |
.BR rexec () |
| 150 |
function sends the unencrypted password across the network. |
| 151 |
.P |
| 152 |
The underlying service is considered a big security hole, |
| 153 |
and therefore, |
| 154 |
not enabled on many sites; |
| 155 |
see |
| 156 |
.BR rexecd (8) |
| 157 |
for explanations. |
| 158 |
.SH SEE ALSO |
| 159 |
.BR rcmd (3), |
| 160 |
.BR rexecd (8) |