Commit | Line | Data |
---|---|---|
d20a1e6f KB |
1 | .\" Copyright (c) 1983 The Regents of the University of California. |
2 | .\" All rights reserved. | |
11a95b5f | 3 | .\" |
91cff1e1 | 4 | .\" %sccs.include.redist.man% |
d20a1e6f | 5 | .\" |
91cff1e1 | 6 | .\" @(#)rcmd.3 6.10 (Berkeley) %G% |
11a95b5f | 7 | .\" |
0609943c | 8 | .TH RCMD 3 "" |
11a95b5f KM |
9 | .UC 5 |
10 | .SH NAME | |
11 | rcmd, rresvport, ruserok \- routines for returning a stream to a remote command | |
12 | .SH SYNOPSIS | |
13 | .nf | |
4fb1c171 | 14 | .PP |
11a95b5f KM |
15 | .B "rem = rcmd(ahost, inport, locuser, remuser, cmd, fd2p);" |
16 | .B char **ahost; | |
f3f0480d | 17 | .B int inport; |
11a95b5f KM |
18 | .B "char *locuser, *remuser, *cmd;" |
19 | .B int *fd2p; | |
20 | .PP | |
21 | .B s = rresvport(port); | |
22 | .B int *port; | |
23 | .PP | |
24 | .B "ruserok(rhost, superuser, ruser, luser);" | |
25 | .B char *rhost; | |
26 | .B int superuser; | |
27 | .B char *ruser, *luser; | |
28 | .fi | |
29 | .SH DESCRIPTION | |
30 | .I Rcmd | |
31 | is a routine used by the super-user to execute a command on | |
32 | a remote machine using an authentication scheme based | |
33 | on reserved port numbers. | |
34 | .I Rresvport | |
35 | is a routine which returns a descriptor to a socket | |
36 | with an address in the privileged port space. | |
37 | .I Ruserok | |
38 | is a routine used by servers | |
39 | to authenticate clients requesting service with | |
40 | .IR rcmd . | |
41 | All three functions are present in the same file and are used | |
42 | by the | |
d20a1e6f | 43 | .IR rshd (8) |
11a95b5f KM |
44 | server (among others). |
45 | .PP | |
46 | .I Rcmd | |
47 | looks up the host | |
48 | .I *ahost | |
49 | using | |
d20a1e6f | 50 | .IR gethostbyname (3), |
11a95b5f KM |
51 | returning \-1 if the host does not exist. |
52 | Otherwise | |
53 | .I *ahost | |
54 | is set to the standard name of the host | |
55 | and a connection is established to a server | |
56 | residing at the well-known Internet port | |
57 | .IR inport . | |
58 | .PP | |
7faf4e1f MK |
59 | If the connection succeeds, |
60 | a socket in the Internet domain of type SOCK_STREAM | |
11a95b5f KM |
61 | is returned to the caller, and given to the remote |
62 | command as | |
63 | .B stdin | |
64 | and | |
65 | .BR stdout . | |
66 | If | |
67 | .I fd2p | |
68 | is non-zero, then an auxiliary channel to a control | |
69 | process will be set up, and a descriptor for it will be placed | |
70 | in | |
71 | .IR *fd2p . | |
72 | The control process will return diagnostic | |
73 | output from the command (unit 2) on this channel, and will also | |
74 | accept bytes on this channel as being UNIX signal numbers, to be | |
75 | forwarded to the process group of the command. | |
76 | If | |
77 | .I fd2p | |
78 | is 0, then the | |
79 | .B stderr | |
80 | (unit 2 of the remote | |
81 | command) will be made the same as the | |
82 | .B stdout | |
83 | and no | |
84 | provision is made for sending arbitrary signals to the remote process, | |
85 | although you may be able to get its attention by using out-of-band data. | |
86 | .PP | |
87 | The protocol is described in detail in | |
d20a1e6f | 88 | .IR rshd (8). |
11a95b5f KM |
89 | .PP |
90 | The | |
91 | .I rresvport | |
92 | routine is used to obtain a socket with a privileged | |
93 | address bound to it. This socket is suitable for use | |
94 | by | |
95 | .I rcmd | |
7faf4e1f MK |
96 | and several other routines. Privileged Internet ports are those |
97 | in the range 0 to 1023. Only the super-user | |
11a95b5f KM |
98 | is allowed to bind an address of this sort to a socket. |
99 | .PP | |
100 | .I Ruserok | |
d20a1e6f KB |
101 | takes a remote host's name, as returned by the |
102 | .IR gethostbyaddr (3) | |
7faf4e1f | 103 | routine, two user names and a flag indicating whether |
d20a1e6f KB |
104 | the local user's name is that of the super-user. Then, |
105 | if the user is | |
106 | .B NOT | |
107 | the super-user, it checks the files | |
108 | .IR /etc/hosts.equiv . | |
109 | If that lookup is not done, or is unsuccessful, the | |
11a95b5f | 110 | .I .rhosts |
d20a1e6f KB |
111 | in the local user's home directory is checked to see if the request for |
112 | service is allowed. If this file is owned by anyone other than the | |
113 | user or the super-user, or if it is writeable by anyone other than the | |
114 | owner, the check automatically fails. A 0 is returned if the machine | |
115 | name is listed in the ``hosts.equiv'' file, or the host and remote | |
116 | user name are found in the ``.rhosts'' file; otherwise | |
11a95b5f | 117 | .I ruserok |
d20a1e6f | 118 | returns \-1. |
0609943c MK |
119 | If the local domain (as obtained from \fIgethostname\fP\|(2)) |
120 | is the same as the remote domain, only the machine name need be specified. | |
11a95b5f | 121 | .SH SEE ALSO |
d20a1e6f | 122 | rlogin(1), rsh(1), intro(2), rexec(3), rexecd(8), rlogind(8), rshd(8) |
7faf4e1f MK |
123 | .SH DIAGNOSTICS |
124 | .I Rcmd | |
125 | returns a valid socket descriptor on success. | |
126 | It returns -1 on error and prints a diagnostic message on the standard error. | |
127 | .PP | |
128 | .I Rresvport | |
129 | returns a valid, bound socket descriptor on success. | |
130 | It returns -1 on error with the global value | |
131 | .I errno | |
132 | set according to the reason for failure. | |
133 | The error code EAGAIN is overloaded to mean ``All network ports in use.'' |