1RCMD(3) 386BSD Programmer's Manual RCMD(3) 2 3NNAAMMEE 4 rrccmmdd, rrrreessvvppoorrtt, rruusseerrookk - routines for returning a stream to a remote 5 command 6 7SSYYNNOOPPSSIISS 8 ##iinncclluuddee <<uunniissttdd..hh>> 9 10 _i_n_t 11 rrccmmdd(_c_h_a_r **_a_h_o_s_t, _i_n_t _i_n_p_o_r_t, _c_o_n_s_t _c_h_a_r *_l_o_c_u_s_e_r, _c_o_n_s_t _c_h_a_r *_r_e_m_u_s_e_r, 12 _c_o_n_s_t _c_h_a_r *_c_m_d, _i_n_t *_f_d_2_p) 13 14 _i_n_t 15 rrrreessvvppoorrtt(_i_n_t *_p_o_r_t) 16 17 _i_n_t 18 rruusseerrookk(_c_o_n_s_t _c_h_a_r *_r_h_o_s_t, _i_n_t _s_u_p_e_r_u_s_e_r, _c_o_n_s_t _c_h_a_r *_r_u_s_e_r, 19 _c_o_n_s_t _c_h_a_r *_l_u_s_e_r) 20 21DDEESSCCRRIIPPTTIIOONN 22 The rrccmmdd() function is used by the super-user to execute a command on a 23 remote machine using an authentication scheme based on reserved port 24 numbers. The rrrreessvvppoorrtt() function returns a descriptor to a socket with 25 an address in the privileged port space. The rruusseerrookk() function is used 26 by servers to authenticate clients requesting service with rrccmmdd(). All 27 three functions are present in the same file and are used by the rshd(8) 28 server (among others). 29 30 The rrccmmdd() function looks up the host *_a_h_o_s_t using gethostbyname(3), 31 returning -1 if the host does not exist. Otherwise *_a_h_o_s_t is set to the 32 standard name of the host and a connection is established to a server 33 residing at the well-known Internet port _i_n_p_o_r_t. 34 35 If the connection succeeds, a socket in the Internet domain of type 36 SOCK_STREAM is returned to the caller, and given to the remote command as 37 _s_t_d_i_n and _s_t_d_o_u_t. If _f_d_2_p is non-zero, then an auxiliary channel to a 38 control process will be set up, and a descriptor for it will be placed in 39 *_f_d_2_p. The control process will return diagnostic output from the command 40 (unit 2) on this channel, and will also accept bytes on this channel as 41 being UNIX signal numbers, to be forwarded to the process group of the 42 command. If _f_d_2_p is 0, then the _s_t_d_e_r_r (unit 2 of the remote command) 43 will be made the same as the _s_t_d_o_u_t and no provision is made for sending 44 arbitrary signals to the remote process, although you may be able to get 45 its attention by using out-of-band data. 46 47 The protocol is described in detail in rshd(8). 48 49 The rrrreessvvppoorrtt() function is used to obtain a socket with a privileged 50 address bound to it. This socket is suitable for use by rrccmmdd() and 51 several other functions. Privileged Internet ports are those in the 52 range 0 to 1023. Only the super-user is allowed to bind an address of 53 this sort to a socket. 54 55 The rruusseerrookk() argument takes a remote host's name, as returned by the 56 gethostbyaddr(3) routine, two user names and a flag indicating whether 57 the local user's name is that of the super-user. Then, if the user is 58 _N_O_T the super-user, it checks the files /_e_t_c/_h_o_s_t_s._e_q_u_i_v. If that lookup 59 is not done, or is unsuccessful, the ._r_h_o_s_t_s in the local user's home 60 directory is checked to see if the request for service is allowed. If 61 this file is owned by anyone other than the user or the super-user, or if 62 it is writeable by anyone other than the owner, the check automatically 63 fails. A 0 is returned if the machine name is listed in the 64 ``_h_o_s_t_s._e_q_u_i_v'' file, or the host and remote user name are found in the 65 ``._r_h_o_s_t_s'' file; otherwise rruusseerrookk() returns -1. If the local domain 66 (as obtained from gethostname(2)) is the same as the remote domain, only 67 the machine name need be specified. 68 69DDIIAAGGNNOOSSTTIICCSS 70 The rrccmmdd() function returns a valid socket descriptor on success. It 71 returns -1 on error and prints a diagnostic message on the standard 72 error. 73 74 The rrrreessvvppoorrtt() function returns a valid, bound socket descriptor on 75 success. It returns -1 on error with the global value _e_r_r_n_o set 76 according to the reason for failure. The error code EAGAIN is overloaded 77 to mean ``All network ports in use.'' 78 79SSEEEE AALLSSOO 80 rlogin(1), rsh(1), intro(2), rexec(3), rexecd(8), rlogind(8), 81 rshd(8) 82 83HHIISSTTOORRYY 84 These functions appeared in 4.2BSD. 85 864.2 Berkeley Distribution April 19, 1991 2 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133