1REXEC(3) Linux Programmer's Manual REXEC(3)
2
3
4
6 rexec, rexec_af - return stream to a remote command
7
9 #include <netdb.h>
10
11 int rexec(char **restrict ahost, int inport,
12 const char *restrict user, const char *restrict passwd,
13 const char *restrict cmd, int *restrict fd2p);
14 int rexec_af(char **restrict ahost, int inport,
15 const char *restrict user, const char *restrict passwd,
16 const char *restrict cmd, int *restrict fd2p,
17 sa_family_t af);
18
19 rexec(), rexec_af():
20 Since glibc 2.19:
21 _DEFAULT_SOURCE
22 In glibc up to and including 2.19:
23 _BSD_SOURCE
24
26 This interface is obsoleted by rcmd(3).
27
28 The rexec() function looks up the host *ahost using gethostbyname(3),
29 returning -1 if the host does not exist. Otherwise, *ahost is set to
30 the standard name of the host. If a username and password are both
31 specified, then these are used to authenticate to the foreign host;
32 otherwise the environment and then the .netrc file in user's home di‐
33 rectory are searched for appropriate information. If all this fails,
34 the user is prompted for the information.
35
36 The port inport specifies which well-known DARPA Internet port to use
37 for the connection; the call getservbyname("exec", "tcp") (see getser‐
38 vent(3)) will return a pointer to a structure that contains the neces‐
39 sary port. The protocol for connection is described in detail in rex‐
40 ecd(8).
41
42 If the connection succeeds, a socket in the Internet domain of type
43 SOCK_STREAM is returned to the caller, and given to the remote command
44 as stdin and stdout. If fd2p is nonzero, then an auxiliary channel to
45 a control process will be setup, and a file descriptor for it will be
46 placed in *fd2p. The control process will return diagnostic output
47 from the command (unit 2) on this channel, and will also accept bytes
48 on this channel as being UNIX signal numbers, to be forwarded to the
49 process group of the command. The diagnostic information returned does
50 not include remote authorization failure, as the secondary connection
51 is set up after authorization has been verified. If fd2p is 0, then
52 the stderr (unit 2 of the remote command) will be made the same as the
53 stdout and no provision is made for sending arbitrary signals to the
54 remote process, although you may be able to get its attention by using
55 out-of-band data.
56
57 rexec_af()
58 The rexec() function works over IPv4 (AF_INET). By contrast, the
59 rexec_af() function provides an extra argument, af, that allows the
60 caller to select the protocol. This argument can be specified as
61 AF_INET, AF_INET6, or AF_UNSPEC (to allow the implementation to select
62 the protocol).
63
65 The rexec_af() function was added to glibc in version 2.2.
66
68 For an explanation of the terms used in this section, see at‐
69 tributes(7).
70
71 ┌──────────────────────────────────────────┬───────────────┬───────────┐
72 │Interface │ Attribute │ Value │
73 ├──────────────────────────────────────────┼───────────────┼───────────┤
74 │rexec(), rexec_af() │ Thread safety │ MT-Unsafe │
75 └──────────────────────────────────────────┴───────────────┴───────────┘
76
78 These functions are not in POSIX.1. The rexec() function first ap‐
79 peared in 4.2BSD, and is present on the BSDs, Solaris, and many other
80 systems. The rexec_af() function is more recent, and less widespread.
81
83 The rexec() function sends the unencrypted password across the network.
84
85 The underlying service is considered a big security hole and therefore
86 not enabled on many sites; see rexecd(8) for explanations.
87
89 rcmd(3), rexecd(8)
90
92 This page is part of release 5.13 of the Linux man-pages project. A
93 description of the project, information about reporting bugs, and the
94 latest version of this page, can be found at
95 https://www.kernel.org/doc/man-pages/.
96
97
98
99Linux 2021-03-22 REXEC(3)