Allows command execution on a remote host.
int rexec_af(char **ahost, unsigned short rport, const char *name,
const char *pass, const char *cmd, int *fd2p, int af)
The rexec_af subroutine allows the calling process to start commands on a remote host. It behaves the same as the existing rexec() function, but instead of creating only an AF_INET TCP socket, it can also create an AF_INET6 TCP socket.
The rexec_af subroutine is useful because the existing rexec() function cannot transparently use AF_INET6 sockets. This is because an application would not be prepared to handle AF_INET6 addresses returned by functions such as getpeername() on the file descriptor created by rexec().
If the rexec_af connection succeeds, a socket in the Internet domain of type SOCK_STREAM is returned to the calling process and is given to the remote command as standard input and standard output.
All applications containing the rexec_af subroutine must be compiled with the _BSD macro set to a specific value. Acceptable values are 43 and 44. In addition, all socket applications must include the BSD libbsd.a library.
Item | Description |
---|---|
ahost | Contains the name of a remote host that is listed in the /etc/hosts file or /etc/resolv.config file. If the name of the host is not found in either file, the rexec subroutine is unsuccessful. |
rport | Specifies the well-known DARPA Internet port
to use for the connection. A pointer to the structure that contains
the necessary port can be obtained by issuing the following library
call:
|
name and pass | Points to a valid user ID and password at the
host. If these parameters are not supplied, the rexec_af subroutine
takes the following actions until it finds a user ID and password
to send to the remote host:
|
cmd | Points to the name of the command to be executed at the remote host. |
fd2p | Specifies one of the following values:
|
af | The family argument is AF_INET, AF_INET6, or AF_UNSPEC. When either AF_INET or AF_INET6 is specified, this subroutine will create a socket of the specified address family. When AF_UNSPEC is specified, it will try all possible address families until a connection can be established, and will return the associated socket of the connection. |
Upon successful completion, the system returns a socket to the remote command. If the rexec_af subroutine is unsuccessful, the system returns a –1, indicating that the specified host name does not exist.
Item | Description |
---|---|
/etc/hosts | Contains host names and their addresses for hosts in a network. This file is used to resolve a host name into an Internet address. |
/etc/resolv.conf | Contains the name server and domain name. |
$HOME/.netrc | Contains automatic login information. |