|
|
1.1 ! root 1: .\" Copyright (c) 1983 The Regents of the University of California. ! 2: .\" All rights reserved. ! 3: .\" ! 4: .\" Redistribution and use in source and binary forms are permitted provided ! 5: .\" that: (1) source distributions retain this entire copyright notice and ! 6: .\" comment, and (2) distributions including binaries display the following ! 7: .\" acknowledgement: ``This product includes software developed by the ! 8: .\" University of California, Berkeley and its contributors'' in the ! 9: .\" documentation or other materials provided with the distribution and in ! 10: .\" all advertising materials mentioning features or use of this software. ! 11: .\" Neither the name of the University nor the names of its contributors may ! 12: .\" be used to endorse or promote products derived from this software without ! 13: .\" specific prior written permission. ! 14: .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED ! 15: .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF ! 16: .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 17: .\" ! 18: .\" @(#)rcmd.3 6.10 (Berkeley) 6/23/90 ! 19: .\" ! 20: .TH RCMD 3 "June 23, 1990" ! 21: .UC 5 ! 22: .SH NAME ! 23: rcmd, rresvport, ruserok \- routines for returning a stream to a remote command ! 24: .SH SYNOPSIS ! 25: .nf ! 26: .PP ! 27: .B "rem = rcmd(ahost, inport, locuser, remuser, cmd, fd2p);" ! 28: .B char **ahost; ! 29: .B int inport; ! 30: .B "char *locuser, *remuser, *cmd;" ! 31: .B int *fd2p; ! 32: .PP ! 33: .B s = rresvport(port); ! 34: .B int *port; ! 35: .PP ! 36: .B "ruserok(rhost, superuser, ruser, luser);" ! 37: .B char *rhost; ! 38: .B int superuser; ! 39: .B char *ruser, *luser; ! 40: .fi ! 41: .SH DESCRIPTION ! 42: .I Rcmd ! 43: is a routine used by the super-user to execute a command on ! 44: a remote machine using an authentication scheme based ! 45: on reserved port numbers. ! 46: .I Rresvport ! 47: is a routine which returns a descriptor to a socket ! 48: with an address in the privileged port space. ! 49: .I Ruserok ! 50: is a routine used by servers ! 51: to authenticate clients requesting service with ! 52: .IR rcmd . ! 53: All three functions are present in the same file and are used ! 54: by the ! 55: .IR rshd (8) ! 56: server (among others). ! 57: .PP ! 58: .I Rcmd ! 59: looks up the host ! 60: .I *ahost ! 61: using ! 62: .IR gethostbyname (3), ! 63: returning \-1 if the host does not exist. ! 64: Otherwise ! 65: .I *ahost ! 66: is set to the standard name of the host ! 67: and a connection is established to a server ! 68: residing at the well-known Internet port ! 69: .IR inport . ! 70: .PP ! 71: If the connection succeeds, ! 72: a socket in the Internet domain of type SOCK_STREAM ! 73: is returned to the caller, and given to the remote ! 74: command as ! 75: .B stdin ! 76: and ! 77: .BR stdout . ! 78: If ! 79: .I fd2p ! 80: is non-zero, then an auxiliary channel to a control ! 81: process will be set up, and a descriptor for it will be placed ! 82: in ! 83: .IR *fd2p . ! 84: The control process will return diagnostic ! 85: output from the command (unit 2) on this channel, and will also ! 86: accept bytes on this channel as being UNIX signal numbers, to be ! 87: forwarded to the process group of the command. ! 88: If ! 89: .I fd2p ! 90: is 0, then the ! 91: .B stderr ! 92: (unit 2 of the remote ! 93: command) will be made the same as the ! 94: .B stdout ! 95: and no ! 96: provision is made for sending arbitrary signals to the remote process, ! 97: although you may be able to get its attention by using out-of-band data. ! 98: .PP ! 99: The protocol is described in detail in ! 100: .IR rshd (8). ! 101: .PP ! 102: The ! 103: .I rresvport ! 104: routine is used to obtain a socket with a privileged ! 105: address bound to it. This socket is suitable for use ! 106: by ! 107: .I rcmd ! 108: and several other routines. Privileged Internet ports are those ! 109: in the range 0 to 1023. Only the super-user ! 110: is allowed to bind an address of this sort to a socket. ! 111: .PP ! 112: .I Ruserok ! 113: takes a remote host's name, as returned by the ! 114: .IR gethostbyaddr (3) ! 115: routine, two user names and a flag indicating whether ! 116: the local user's name is that of the super-user. Then, ! 117: if the user is ! 118: .B NOT ! 119: the super-user, it checks the files ! 120: .IR /etc/hosts.equiv . ! 121: If that lookup is not done, or is unsuccessful, the ! 122: .I .rhosts ! 123: in the local user's home directory is checked to see if the request for ! 124: service is allowed. If this file is owned by anyone other than the ! 125: user or the super-user, or if it is writeable by anyone other than the ! 126: owner, the check automatically fails. A 0 is returned if the machine ! 127: name is listed in the ``hosts.equiv'' file, or the host and remote ! 128: user name are found in the ``.rhosts'' file; otherwise ! 129: .I ruserok ! 130: returns \-1. ! 131: If the local domain (as obtained from \fIgethostname\fP\|(2)) ! 132: is the same as the remote domain, only the machine name need be specified. ! 133: .SH SEE ALSO ! 134: rlogin(1), rsh(1), intro(2), rexec(3), rexecd(8), rlogind(8), rshd(8) ! 135: .SH DIAGNOSTICS ! 136: .I Rcmd ! 137: returns a valid socket descriptor on success. ! 138: It returns -1 on error and prints a diagnostic message on the standard error. ! 139: .PP ! 140: .I Rresvport ! 141: returns a valid, bound socket descriptor on success. ! 142: It returns -1 on error with the global value ! 143: .I errno ! 144: set according to the reason for failure. ! 145: The error code EAGAIN is overloaded to mean ``All network ports in use.''
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.