rcmd(3)rcmd(3)NAME
rcmd, rcmd_r - Allow execution of commands on a remote host
SYNOPSIS
#include <sys/types.h> #include <netdb.h> #include <unistd.h>
int rcmd(
char **host,
u_short port,
char *local_user,
char *remote_user,
char *command,
int *err_file_desc );
The following function is supported in order to maintain backward com‐
patibility with previous versions of the operating system: int rcmd_r(
char **host,
u_short port,
char *local_user,
char *remote_user,
char *command,
int *err_file_desc,
struct hostent_data *host_data );
LIBRARY
Standard C Library (libc)
PARAMETERS
Specifies the name of a remote host. The function sets the host parame‐
ter to be the fully qualified hostname. Specifies the well-known port
to use for the connection. The /etc/services file contains the Inter‐
net services, their ports, and socket types. Points to usernames that
are valid at the local host. Any valid username can be given. Points
to usernames that are valid at the remote host. Any valid username can
be given. Specifies the name of the command to be executed at the
remote host. Points to an address used by rcmd() to store a pointer to
the file descriptor for a channel used by the remote process to write
stderr messages and to accept bytes as signal numbers to be forwarded
to the process group of the command.
If a null pointer is specified, the standard error (stderr) of
the remote command is the same as the standard output (stdout).
No provision is made for sending arbitrary signals to the remote
process. However, it is possible to send out-of-band data to
the remote command. Per-thread data for reentrant version.
DESCRIPTION
The rcmd() (remote command) function allows execution of certain com‐
mands on a remote host. For example, the rcmd() function is used by rsh
and rlogin, among others.
The rcmd() function looks up a host via the name server or, if the
local name server is not running, via the /etc/hosts file. If the con‐
nection 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 name. If the local domain and remote domain
are the same, specifying the domain parts is optional. The rcmd() func‐
tion returns the fully qualified hostname in the host parameter. To re‐
use the host name in another rcmd() call, you should make a string copy
of the host parameter. For example:
rcmd ( &host, .... ); first_host = strdup(host); ... rcmd ( &host,
.... );
Only processes with an effective user ID of root user can use the
rcmd() function. A user authentication scheme based on remote port
numbers is used to verify permissions. Ports in the range from 0 to
1023 can only be used by a root user.
Alternatively, the rcmd() function can use a Secure Shell connection to
authenticate users. In addition to authenticating users, a Secure Shell
connection also authenticates the client and server and provides data
encryption, data integrity, and nonrepudiation. You configure the
rcmd() function (and the rsh, rlogin, and rcp commands) to automati‐
cally use a Secure Shell connection by enabling the Secure Shell
EnforceSecureRutils keyword in the /etc/ssh2/ssh2_config file or in a
user's $HOME/.ssh2/ssh2_config file. When the EnforceSecureRutils key‐
word is enabled: The sshd daemon runs and spawns the srcmd child
process; the rshd and rlogind daemons do not run. The rcmd() function
can use only Secure Shell host-based authentication to authenticate
users.
See Security Administration for more information about configuring
Secure Shell host-based authentication and the EnforceSecureRutils key‐
word.
NOTES
The rcmd_r() function is the reentrant version of rcmd(). It is sup‐
ported in order to maintain backward compatibility with previous ver‐
sions of the operating system.
The netdb.h header file defines the hostent_data structures.
RETURN VALUES
Upon successful completion, the rcmd() function returns a valid socket
descriptor. The function returns a value of -1 if the effective user ID
of the calling process is not root user, if the function fails to
resolve the host, or if it encounters a socket connection error.
FILES
Contains the service names, ports, and socket types. Contains host‐
names and their addresses for the hosts in a network. Contains the
name server and the domain name. Specifies remote users that can use a
local user account. Specifies Secure Shell client configuration infor‐
mation. Specifies Secure Shell server configuration information.
SEE ALSO
Functions: gethostname(2), rresvport(3), rresvport_af(3), ruserok(3),
sethostname(2)
Commands: rlogin(1), rsh(1)rcmd(3)