rcmd.3n (2010 09)

r
rcmd(3N) rcmd(3N)
NAME
rcmd(), rcmd_af(), rresvport(), rresvport_af(), ruserok() - return a stream to a remote command
SYNOPSIS
int rcmd(
char **ahost,
int remport,
const char *locuser,
const char *remuser,
const char *cmd,
int *fd2p);
int rcmd_af(
char **ahost,
int remport,
const char *locuser,
const char *remuser,
const char *cmd,
int *fd2p,
int af);
int rresvport(int *port);
int rresvport_af(int *port,int af);
int ruserok(
const char *rhost,
int superuser,
const char *ruser,
const char *luser);
DESCRIPTION
rcmd()
The rcmd() function is used by privileged programs to execute a command on a remote host.
rcmd()
returns a file descriptor for the socket to which the standard input and standard output of the command
are attached. A command level interface to rcmd() is provided by remsh (see remsh(1)), which is the
same as the BSD rsh command.
ahost is a pointer to the address of the remote host name. The name of the remote host can be either an
official host name or an alias as understood by
gethostbyname()
(see gethostent (3N), named(1M),
and hosts (4)).
remport is the Internet port on the remote system, which
rcmd() will try to connect to.
locuser and remuser point to the user login name on the local host and on the remote host, respectively.
The names are used by the server on the remote host to authenticate the user (see
ruserok() below).
cmd points to a string that specifies the command to be executed on the remote host.
fd2p is a pointer to an integer (it can be a NULL pointer).
rcmd() looks up the host *ahost using gethostbyname(), returning 1 if the host does not exist.
Otherwise, *ahost is set to the standard name of the host and a connection is established to a server
accepting requests at the port remport . If the connection is refused after five tries, or if it was refused for
a reason other than the port being in use, rcmd() returns 1.
If the call succeeds, a socket of type SOCK_STREAM is returned to the caller and given to the remote
command as
stdin and stdout.Iffd2p is non-NULL, rcmd() opens a second socket between the cal-
ling process (local) and the control process (remote), and places its descriptor in *fd2p. On this connec-
tion, the control process sends the diagnostic output (stderr) from cmd to the calling process, and
receives UNIX signals from the calling process, to be forwarded to cmd. If the auxiliary port cannot be
set up, rcmd() returns 1. If fd2p is NULL, stderr of the remote command is made the same as
stdout, and no provision is made for sending arbitrary signals to the remote process.
The protocol is described in detail in remshd (1M).
Any program using
rcmd() must be run as superuser.
HP-UX 11i Version 3: September 2010 1 Hewlett-Packard Company 1

Summary of content (4 pages)