svcadm(1M)을 검색하려면 섹션에서 1M 을 선택하고, 맨 페이지 이름에 svcadm을 입력하고 검색을 누른다.
rexec(3c)
Standard C Library Functions rexec(3C)
NAME
rexec, rexec_af - return stream to a remote command
SYNOPSIS
#include <netdb.h>
#include <unistd.h>
int rexec(char **ahost, unsigned short inport, const char *user,
const char *passwd, const char *cmd, int *fd2p);
int rexec_af(char **ahost, unsigned short inport, const char *user,
const char *passwd, const char *cmd, int *fd2p, int af);
DESCRIPTION
These functions open a connection to a remote host to execute a com‐
mand, and return a socket connected to the remote command's standard
input and output file descriptors. The protocol for connection is
described in detail in in.rexecd(8).
The rexec() and rexec_af() functions first look up the host ahost using
getaddrinfo(3C) and return −1 if the host does not exist. Otherwise
ahost is set to the standard name of the host. The user and passwd
parameters are used as the username and password in remote host authen‐
tication. When a username and password are not specified, the .netrc
file in the user's home directory is searched for the appropriate
information. If the search fails, the user is prompted for the informa‐
tion.
The rexec() function always returns a socket of the AF_INET address
family. The rexec_af() function accepts AF_INET, AF_INET6, or AF_UNSPEC
for the address family parameter af. An application can choose which
type of socket is returned by passing AF_INET or AF_INET6 as the
address family. The use of AF_UNSPEC means that the caller will accept
any address family. Choosing AF_UNSPEC provides a socket that best
suits the connectivity to the remote host.
The parameter inport specifies which TCP port to use for the connec‐
tion. The port number used must be in network byte order, as supplied
by a call to htons(3C).
If the call succeeds, a socket of type SOCK_STREAM is returned to the
caller, and given to the remote command as its standard input and stan‐
dard output. If fd2p is non-null, an auxiliary channel to a control
process is set up and a file descriptor for it is placed in *fd2p. The
control process returns diagnostic output (file descriptor 2), from the
command on the auxiliary channel. The control process also accepts
bytes on this channel as signal numbers to be forwarded to the process
group of the command. If fd2p is NULL, the standard error (file
descriptor 2) of the remote command is made the same as its standard
output, and no provision is made for sending arbitrary signals to the
remote process, other than possibly sending out-of-band data.
There is no way to specify options to the socket() call made by the
rexec() or rexec_af() functions.
RETURN VALUES
If rexec() succeeds, a file descriptor number is returned of the socket
type SOCK_STREAM and the address family AF_INET. The parameter *ahost
is set to the standard name of the host. If the value of fd2p is other
than NULL, a file descriptor number is placed in *fd2p which represents
the standard error stream of the command.
If rexec_af() succeeds, the routine returns a file descriptor number of
the socket type SOCK_STREAM in the address family AF_INET or AF_INET6,
as determined by the value of the af parameter.
If either rexec() or rexec_af() fails, −1 is returned.
USAGE
The protocol underlying these functions uses weak authentication and
offers no protection against spoofing or snooping of traffic. The
in.rexecd(8) server is disabled by default on Oracle Solaris and most
other modern operating systems, and may be removed in future versions
of Oracle Solaris. Use of the sshd(8) server is strongly recommended
instead, and a programming interface to it is available via the libssh2
library.
ATTRIBUTES
See attributes(7) for descriptions of the following attributes:
tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) ATTRIBUTE TYPEAT‐
TRIBUTE VALUE _ Interface StabilityCommitted _ MT-LevelUnsafe
This interface is Unsafe in multithreaded applications. Unsafe inter‐
faces should be called only from the main thread.
SEE ALSO
getaddrinfo(3C), htons(3C), socket(3C), attributes(7), in.rexecd(8)
HISTORY
The rexec() function has been present since the initial release of
Solaris.
The rexec_af() function was added to Oracle Solaris in the Solaris 8
release.
Oracle Solaris 11.4 2 Feb 2021 rexec(3C)