ruserok()

check the identity of a remote host

Synopsis:

int ruserok( const char *rhost, 
             int superuser,
             const char *ruser,
             const char *luser );

Description:

The ruserok() routine checks the identity of a remote host. It's used by servers to authenticate clients requesting service with rcmd().

The rcmd(), rresvport(), and ruserok() functions are used by the rshd server, among others.

The ruserok() function takes a remote host's name (as returned by the gethostbyaddr() routine), 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 file /etc/hosts.equiv (described in the TCP/IP User's Guide).

If that lookup isn't done, or is unsuccessful, the .rhosts file in the local user's home directory is checked to see if the request for service is allowed. If this file is owned by anyone other than the user or the superuser, or if it's writable by anyone other than the owner, the check automatically fails.

The ruserok() function returns 0 if the machine name is listed in the hosts.equiv file or if the host and remote username are found in the .rhosts file; otherwise, it returns -1.

If the local domain obtained from gethostname() is the same as the remote domain, only the machine name need be specified.

Returns:

0
Success.
-1
An error occurred; errno is set.

Errors:

The error code EAGAIN is overloaded to mean ``All network ports in use.''

Classification:

UNIX

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

rcmd(), rresvport()