| RCMD(3) | Library Functions Manual | RCMD(3) |
NAME
rcmd, rresvport,
iruserok, ruserok —
routines for returning a stream to a remote
command
SYNOPSIS
#include <netdb.h>
/* Or <unistd.h> on some systems */
int
rcmd(char
**ahost, int
inport, const char
*locuser, const char
*remuser, const char
*cmd, int
*fd2p);
int
rresvport(int
*port);
int
iruserok(u_int32_t
raddr, int
superuser, const char
*ruser, const char
*luser);
int
ruserok(const
char *rhost, int
superuser, const char
*ruser, const char
*luser);
DESCRIPTION
The
rcmd()
function is used by the superuser to execute a command on a remote machine
using an authentication scheme based on reserved port numbers. The
rresvport() function returns a descriptor to a
socket with an address in the privileged port space. The
iruserok() and ruserok()
functions are used by servers to authenticate clients requesting service
with rcmd(). All four functions are present in the
same file and are used by the rshd(8) server (among
others).
The
rcmd()
function looks up the host *ahost using
gethostbyname(3), 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 residing at the well-known
Internet port inport.
If the connection succeeds, a socket in the Internet
domain of type SOCK_STREAM is returned to the
caller, and given to the remote command as
stdin and
stdout. If fd2p is non-zero, then an
auxiliary channel to a control process will be set up, and a descriptor for
it will be placed in *fd2p. The control process will
return diagnostic output from the command (unit 2) on this channel, and will
also accept bytes on this channel as being UNIX signal numbers, to be
forwarded to the process group of the command. If fd2p
is 0, then the
stderr
(unit 2 of the remote command) will be made the same as the
stdout and no provision is made for sending arbitrary
signals to the remote process, although you may be able to get its attention
by using out-of-band data.
The protocol is described in detail in rshd(8).
The
rresvport()
function is used to obtain a socket with a privileged address bound to it.
This socket is suitable for use by rcmd() and
several other functions. Privileged Internet ports are those in the range 0
to 1023. Only the superuser is allowed to bind an address of this sort to a
socket.
The
iruserok()
and
ruserok()
functions take a remote host's IP address or name, respectively, two user
names and a flag indicating whether the local user's name is that of the
superuser. Then, if the user is
NOT the
superuser, it checks the /etc/hosts.equiv file. If
that lookup is not done, or is unsuccessful, the
.rhosts in the local user's home directory is
checked to see if the request for service is allowed.
If this file does not exist, is not a regular
file, is owned by anyone other than the user or the superuser, or is
writeable by anyone other than the owner, the check automatically fails.
Zero is returned if the machine name is listed in the
“hosts.equiv” file, or the host and
remote user name are found in the
“.rhosts” file; otherwise
iruserok()
and
ruserok()
return -1. If the local domain (as obtained from
gethostname(2)) is the same as the remote domain, only the
machine name need be specified.
If the IP address of the remote host is known,
iruserok()
should be used in preference to
ruserok(),
as it does not require trusting the DNS server for the remote host's
domain.
DIAGNOSTICS
The rcmd() function returns a valid socket
descriptor on success. It returns -1 on error and prints a diagnostic
message on the standard error.
The rresvport() function returns a valid,
bound socket descriptor on success. It returns -1 on error with the global
value errno set according to the reason for failure.
The error code EAGAIN is overloaded to mean ``All
network ports in use.''
SEE ALSO
rlogin(1), rsh(1), intro(2), rexec(3), rexecd(8), rlogind(8), rshd(8)
HISTORY
These functions appeared in 4.2BSD.
| June 4, 1993 | 4.2BSD |
Different Versions of this Page:
- Version 6.17 (latest)
- Version 6.16
- Version 6.15
- Version 6.14
- Version 6.13
- Version 6.12
- Version 6.11
- Version 6.10
- Version 6.9.1
- Version 6.9
- Version 6.8
- Version 6.7
- Version 6.06
- Version 6.05.01
- Version 6.05
- Version 6.04
- Version 6.03
- Version 6.02
- Version 6.01
- Version 6.00
- Version 5.13
- Version 5.12
- Version 5.11
- Version 5.10
- Version 5.09
- Version 5.08
- Version 5.07
- Version 5.06
- Version 5.05
- Version 5.04
- Version 5.03
- Version 5.02
- Version 5.01
- Version 5.00
- Version 4.16
- Version 4.15
- Version 4.14
- Version 4.13
- Version 4.12
- Version 4.10
- Version 4.09
- Version 4.08
- Version 4.07
- Version 4.06
- Version 4.05
- Version 4.04
- Version 4.03
- Version 4.02
- Version 4.01
- Version 4.00
- Version 3.83
- Version 3.82
- Version 3.81
- Version 3.80
- Version 3.79
- Version 3.78
- Version 3.77
- Version 3.76
- Version 3.75
- Version 3.74
- Version 3.73
- Version 3.72
- Version 3.71
- Version 3.70
- Version 3.69
- Version 3.68
- Version 3.67
- Version 3.66
- Version 3.65
- Version 3.64
- Version 3.63
- Version 3.62
- Version 3.61
- Version 3.60
- Version 3.59
- Version 3.58
- Version 3.57
- Version 3.56
- Version 3.55
- Version 3.54
- Version 3.53
- Version 3.52
- Version 3.49
- Version 3.48
- Version 3.47
- Version 3.46
- Version 3.45
- Version 3.44
- Version 3.43
- Version 3.42
- Version 3.41
- Version 3.40
- Version 3.39
- Version 3.38
- Version 3.37
- Version 3.36
- Version 3.35
- Version 3.34
- Version 3.33
- Version 3.32
- Version 3.31
- Version 3.30
- Version 3.29
- Version 3.28
- Version 3.27
- Version 3.26
- Version 3.25
- Version 3.24
- Version 3.23
- Version 3.22
- Version 3.21
- Version 3.20
- Version 3.17
- Version 3.16
- Version 3.15
- Version 3.14
- Version 3.13
- Version 3.12
- Version 3.11
- Version 3.10
- Version 3.09
- Version 3.08
- Version 3.07
- Version 3.06
- Version 3.05
- Version 3.04
- Version 3.03
- Version 3.02
- Version 3.01
- Version 3.00
- Version 2.80
- Version 2.79
- Version 2.78
- Version 2.77
- Version 2.76
- Version 2.75
- Version 2.74
- Version 2.73
- Version 2.72
- Version 2.71
- Version 2.70
- Version 2.69
- Version 2.68
- Version 2.67
- Version 2.66
- Version 2.65
- Version 2.64
- Version 2.63
- Version 2.62
- Version 2.61
- Version 2.60
- Version 2.59
- Version 2.58
- Version 2.57
- Version 2.56
- Version 2.55
- Version 2.54
- Version 2.53
- Version 2.52
- Version 2.51
- Version 2.50
- Version 2.49
- Version 2.48
- Version 2.47
- Version 2.46
- Version 2.45
- Version 2.44
- Version 2.43
- Version 2.42
- Version 2.41
- Version 2.40
- Version 2.39
- Version 2.38
- Version 2.37
- Version 2.36
- Version 2.35
- Version 2.34
- Version 2.33
- Version 2.32
- Version 2.31
- Version 2.30
- Version 2.29
- Version 2.28
- Version 2.27
- Version 2.26
- Version 2.25
- Version 2.24
- Version 2.23
- Version 2.22
- Version 2.21
- Version 2.20
- Version 2.19
- Version 2.18
- Version 2.17
- Version 2.16
- Version 2.15
- Version 2.14
- Version 2.13
- Version 2.12
- Version 2.11
- Version 2.10
- Version 2.09
- Version 2.08
- Version 2.07
- Version 2.06
- Version 2.05
- Version 2.04
- Version 2.03
- Version 2.02
- Version 2.01
- Version 2.00