Allows execution of commands on a remote host.
Standard C Library (libc.a)
int rcmd (Host,
Port, LocalUser, RemoteUser, Command, ErrFileDesc)
char ** Host;
u_short Port;
char * LocalUser;
char * RemoteUser;
char * Command;
int * ErrFileDesc;
The rcmd subroutine allows execution of certain commands on a remote host that supports rshd, rlogin, and rpc among others.
Only processes with an effective user ID of root user can use the rcmd subroutine. An authentication scheme based on remote port numbers is used to verify permissions. Ports in the range between 0 and 1023 can only be used by a root user. The application must pass in Port, which must be in the range 512 to 1023.
The rcmd subroutine looks up a host by way of the name server or if the local name server isn't running, in the /etc/hosts file.
If the connection succeeds, a socket in the Internet domain of type SOCK_STREAM is returned to the calling process and given to the remote command as standard input (stdin) and standard output (stdout).
Always specify the Host parameter. If the local domain and remote domain are the same, specifying the domain parts is optional.
All applications containing the rcmd 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 |
---|---|
Host | Specifies the name of a remote host that is listed in the /etc/hosts file. If the specified name of the host is not found in this file, the rcmd subroutine is unsuccessful. |
Port | Specifies the well-known port to use for the connection. The /etc/services file contains the DARPA Internet services, their ports, and socket types. |
LocalUser and RemoteUser | Points to user names that are valid at the local and remote host, respectively. Any valid user name can be given. |
Command | Specifies the name of the command to be started at the remote host. |
ErrFileDesc | Specifies an integer controlling the set up of communication
channels. Integer options are as follows:
|
Upon successful completion, the rcmd subroutine returns a valid socket descriptor.
Upon unsuccessful completion, the rcmd subroutine returns a value of -1. The subroutine returns a -1, if the effective user ID of the calling process is not root user or if the subroutine is unsuccessful to resolve the host.
Item | Description |
---|---|
/etc/services | Contains the service names, ports, and socket type. |
/etc/hosts | Contains host names and their addresses for hosts in a network. |
/etc/resolv.conf | Contains the name server and domain name. |