1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate %/* 23*7c478bd9Sstevel@tonic-gate % * Copyright (c) 1987 by Sun Microsystems, Inc. 24*7c478bd9Sstevel@tonic-gate % */ 25*7c478bd9Sstevel@tonic-gate 26*7c478bd9Sstevel@tonic-gate %/* from rex.x */ 27*7c478bd9Sstevel@tonic-gate 28*7c478bd9Sstevel@tonic-gate #ifdef RPC_HDR 29*7c478bd9Sstevel@tonic-gate % 30*7c478bd9Sstevel@tonic-gate %#pragma ident "%Z%%M% %I% %E% SMI" 31*7c478bd9Sstevel@tonic-gate % 32*7c478bd9Sstevel@tonic-gate #endif 33*7c478bd9Sstevel@tonic-gate 34*7c478bd9Sstevel@tonic-gate /* 35*7c478bd9Sstevel@tonic-gate * Remote execution (rex) protocol specification 36*7c478bd9Sstevel@tonic-gate */ 37*7c478bd9Sstevel@tonic-gate 38*7c478bd9Sstevel@tonic-gate const STRINGSIZE = 1024; 39*7c478bd9Sstevel@tonic-gate typedef string rexstring<1024>; 40*7c478bd9Sstevel@tonic-gate 41*7c478bd9Sstevel@tonic-gate /* 42*7c478bd9Sstevel@tonic-gate * values to pass to REXPROC_SIGNAL 43*7c478bd9Sstevel@tonic-gate */ 44*7c478bd9Sstevel@tonic-gate const SIGINT = 2; /* interrupt */ 45*7c478bd9Sstevel@tonic-gate 46*7c478bd9Sstevel@tonic-gate /* 47*7c478bd9Sstevel@tonic-gate * Values for rst_flags, below 48*7c478bd9Sstevel@tonic-gate */ 49*7c478bd9Sstevel@tonic-gate const REX_INTERACTIVE = 1; /* interactive mode */ 50*7c478bd9Sstevel@tonic-gate 51*7c478bd9Sstevel@tonic-gate struct rex_start { 52*7c478bd9Sstevel@tonic-gate rexstring rst_cmd<>; /* list of command and args */ 53*7c478bd9Sstevel@tonic-gate rexstring rst_host; /* working directory host name */ 54*7c478bd9Sstevel@tonic-gate rexstring rst_fsname; /* working directory file system name */ 55*7c478bd9Sstevel@tonic-gate rexstring rst_dirwithin;/* working directory within file system */ 56*7c478bd9Sstevel@tonic-gate rexstring rst_env<>; /* list of environment */ 57*7c478bd9Sstevel@tonic-gate unsigned int rst_port0; /* port for stdin */ 58*7c478bd9Sstevel@tonic-gate unsigned int rst_port1; /* port for stdout */ 59*7c478bd9Sstevel@tonic-gate unsigned int rst_port2; /* port for stderr */ 60*7c478bd9Sstevel@tonic-gate unsigned int rst_flags; /* options - see const above */ 61*7c478bd9Sstevel@tonic-gate }; 62*7c478bd9Sstevel@tonic-gate 63*7c478bd9Sstevel@tonic-gate struct rex_result { 64*7c478bd9Sstevel@tonic-gate int rlt_stat; /* integer status code */ 65*7c478bd9Sstevel@tonic-gate rexstring rlt_message; /* string message for human consumption */ 66*7c478bd9Sstevel@tonic-gate }; 67*7c478bd9Sstevel@tonic-gate 68*7c478bd9Sstevel@tonic-gate 69*7c478bd9Sstevel@tonic-gate struct sgttyb { 70*7c478bd9Sstevel@tonic-gate unsigned four; /* always equals 4 */ 71*7c478bd9Sstevel@tonic-gate opaque chars[4]; 72*7c478bd9Sstevel@tonic-gate /* chars[0] == input speed */ 73*7c478bd9Sstevel@tonic-gate /* chars[1] == output speed */ 74*7c478bd9Sstevel@tonic-gate /* chars[2] == kill character */ 75*7c478bd9Sstevel@tonic-gate /* chars[3] == erase character */ 76*7c478bd9Sstevel@tonic-gate unsigned flags; 77*7c478bd9Sstevel@tonic-gate }; 78*7c478bd9Sstevel@tonic-gate /* values for speeds above (baud rates) */ 79*7c478bd9Sstevel@tonic-gate const B0 = 0; 80*7c478bd9Sstevel@tonic-gate const B50 = 1; 81*7c478bd9Sstevel@tonic-gate const B75 = 2; 82*7c478bd9Sstevel@tonic-gate const B110 = 3; 83*7c478bd9Sstevel@tonic-gate const B134 = 4; 84*7c478bd9Sstevel@tonic-gate const B150 = 5; 85*7c478bd9Sstevel@tonic-gate const B200 = 6; 86*7c478bd9Sstevel@tonic-gate const B300 = 7; 87*7c478bd9Sstevel@tonic-gate const B600 = 8; 88*7c478bd9Sstevel@tonic-gate const B1200 = 9; 89*7c478bd9Sstevel@tonic-gate const B1800 = 10; 90*7c478bd9Sstevel@tonic-gate const B2400 = 11; 91*7c478bd9Sstevel@tonic-gate const B4800 = 12; 92*7c478bd9Sstevel@tonic-gate const B9600 = 13; 93*7c478bd9Sstevel@tonic-gate const B19200 = 14; 94*7c478bd9Sstevel@tonic-gate const B38400 = 15; 95*7c478bd9Sstevel@tonic-gate 96*7c478bd9Sstevel@tonic-gate /* values for flags above */ 97*7c478bd9Sstevel@tonic-gate const TANDEM = 0x00000001; /* send stopc on out q full */ 98*7c478bd9Sstevel@tonic-gate const CBREAK = 0x00000002; /* half-cooked mode */ 99*7c478bd9Sstevel@tonic-gate const LCASE = 0x00000004; /* simulate lower case */ 100*7c478bd9Sstevel@tonic-gate const ECHO = 0x00000008; /* echo input */ 101*7c478bd9Sstevel@tonic-gate const CRMOD = 0x00000010; /* map \r to \r\n on output */ 102*7c478bd9Sstevel@tonic-gate const RAW = 0x00000020; /* no i/o processing */ 103*7c478bd9Sstevel@tonic-gate const ODDP = 0x00000040; /* get/send odd parity */ 104*7c478bd9Sstevel@tonic-gate const EVENP = 0x00000080; /* get/send even parity */ 105*7c478bd9Sstevel@tonic-gate const ANYP = 0x000000c0; /* get any parity/send none */ 106*7c478bd9Sstevel@tonic-gate const NLDELAY = 0x00000300; /* \n delay */ 107*7c478bd9Sstevel@tonic-gate const NL0 = 0x00000000; 108*7c478bd9Sstevel@tonic-gate const NL1 = 0x00000100; /* tty 37 */ 109*7c478bd9Sstevel@tonic-gate const NL2 = 0x00000200; /* vt05 */ 110*7c478bd9Sstevel@tonic-gate const NL3 = 0x00000300; 111*7c478bd9Sstevel@tonic-gate const TBDELAY = 0x00000c00; /* horizontal tab delay */ 112*7c478bd9Sstevel@tonic-gate const TAB0 = 0x00000000; 113*7c478bd9Sstevel@tonic-gate const TAB1 = 0x00000400; /* tty 37 */ 114*7c478bd9Sstevel@tonic-gate const TAB2 = 0x00000800; 115*7c478bd9Sstevel@tonic-gate const XTABS = 0x00000c00; /* expand tabs on output */ 116*7c478bd9Sstevel@tonic-gate const CRDELAY = 0x00003000; /* \r delay */ 117*7c478bd9Sstevel@tonic-gate const CR0 = 0x00000000; 118*7c478bd9Sstevel@tonic-gate const CR1 = 0x00001000; /* tn 300 */ 119*7c478bd9Sstevel@tonic-gate const CR2 = 0x00002000; /* tty 37 */ 120*7c478bd9Sstevel@tonic-gate const CR3 = 0x00003000; /* concept 100 */ 121*7c478bd9Sstevel@tonic-gate const VTDELAY = 0x00004000; /* vertical tab delay */ 122*7c478bd9Sstevel@tonic-gate const FF0 = 0x00000000; 123*7c478bd9Sstevel@tonic-gate const FF1 = 0x00004000; /* tty 37 */ 124*7c478bd9Sstevel@tonic-gate const BSDELAY = 0x00008000; /* \b delay */ 125*7c478bd9Sstevel@tonic-gate const BS0 = 0x00000000; 126*7c478bd9Sstevel@tonic-gate const BS1 = 0x00008000; 127*7c478bd9Sstevel@tonic-gate const CRTBS = 0x00010000; /* do backspacing for crt */ 128*7c478bd9Sstevel@tonic-gate const PRTERA = 0x00020000; /* \ ... / erase */ 129*7c478bd9Sstevel@tonic-gate const CRTERA = 0x00040000; /* " \b " to wipe out char */ 130*7c478bd9Sstevel@tonic-gate const TILDE = 0x00080000; /* hazeltine tilde kludge */ 131*7c478bd9Sstevel@tonic-gate const MDMBUF = 0x00100000; /* start/stop output on carrier intr */ 132*7c478bd9Sstevel@tonic-gate const LITOUT = 0x00200000; /* literal output */ 133*7c478bd9Sstevel@tonic-gate const TOSTOP = 0x00400000; /* SIGTTOU on background output */ 134*7c478bd9Sstevel@tonic-gate const FLUSHO = 0x00800000; /* flush output to terminal */ 135*7c478bd9Sstevel@tonic-gate const NOHANG = 0x01000000; /* no SIGHUP on carrier drop */ 136*7c478bd9Sstevel@tonic-gate const L001000 = 0x02000000; 137*7c478bd9Sstevel@tonic-gate const CRTKIL = 0x04000000; /* kill line with " \b " */ 138*7c478bd9Sstevel@tonic-gate const PASS8 = 0x08000000; 139*7c478bd9Sstevel@tonic-gate const CTLECH = 0x10000000; /* echo control chars as ^X */ 140*7c478bd9Sstevel@tonic-gate const PENDIN = 0x20000000; /* tp->t_rawq needs reread */ 141*7c478bd9Sstevel@tonic-gate const DECCTQ = 0x40000000; /* only ^Q starts after ^S */ 142*7c478bd9Sstevel@tonic-gate const NOFLSH = 0x80000000; /* no output flush on signal */ 143*7c478bd9Sstevel@tonic-gate 144*7c478bd9Sstevel@tonic-gate struct tchars { 145*7c478bd9Sstevel@tonic-gate unsigned six; /* always equals 6 */ 146*7c478bd9Sstevel@tonic-gate opaque chars[6]; 147*7c478bd9Sstevel@tonic-gate /* chars[0] == interrupt char */ 148*7c478bd9Sstevel@tonic-gate /* chars[1] == quit char */ 149*7c478bd9Sstevel@tonic-gate /* chars[2] == start output char */ 150*7c478bd9Sstevel@tonic-gate /* chars[3] == stop output char */ 151*7c478bd9Sstevel@tonic-gate /* chars[4] == end-of-file char */ 152*7c478bd9Sstevel@tonic-gate /* chars[5] == input delimeter (like nl) */ 153*7c478bd9Sstevel@tonic-gate }; 154*7c478bd9Sstevel@tonic-gate 155*7c478bd9Sstevel@tonic-gate struct ltchars { 156*7c478bd9Sstevel@tonic-gate unsigned six; /* always equals 6 */ 157*7c478bd9Sstevel@tonic-gate opaque chars[6]; 158*7c478bd9Sstevel@tonic-gate /* chars[0] == stop process signal */ 159*7c478bd9Sstevel@tonic-gate /* chars[1] == delayed stop process signal */ 160*7c478bd9Sstevel@tonic-gate /* chars[2] == reprint line */ 161*7c478bd9Sstevel@tonic-gate /* chars[3] == flush output */ 162*7c478bd9Sstevel@tonic-gate /* chars[4] == word erase */ 163*7c478bd9Sstevel@tonic-gate /* chars[5] == literal next character */ 164*7c478bd9Sstevel@tonic-gate unsigned mode; 165*7c478bd9Sstevel@tonic-gate }; 166*7c478bd9Sstevel@tonic-gate 167*7c478bd9Sstevel@tonic-gate struct rex_ttysize { 168*7c478bd9Sstevel@tonic-gate int ts_lines; 169*7c478bd9Sstevel@tonic-gate int ts_cols; 170*7c478bd9Sstevel@tonic-gate }; 171*7c478bd9Sstevel@tonic-gate 172*7c478bd9Sstevel@tonic-gate struct rex_ttymode { 173*7c478bd9Sstevel@tonic-gate sgttyb basic; /* standard unix tty flags */ 174*7c478bd9Sstevel@tonic-gate tchars more; /* interrupt, kill characters, etc. */ 175*7c478bd9Sstevel@tonic-gate ltchars yetmore; /* special Berkeley characters */ 176*7c478bd9Sstevel@tonic-gate unsigned andmore; /* and Berkeley modes */ 177*7c478bd9Sstevel@tonic-gate }; 178*7c478bd9Sstevel@tonic-gate 179*7c478bd9Sstevel@tonic-gate /* values for andmore above */ 180*7c478bd9Sstevel@tonic-gate const LCRTBS = 0x0001; /* do backspacing for crt */ 181*7c478bd9Sstevel@tonic-gate const LPRTERA = 0x0002; /* \ ... / erase */ 182*7c478bd9Sstevel@tonic-gate const LCRTERA = 0x0004; /* " \b " to wipe out char */ 183*7c478bd9Sstevel@tonic-gate const LTILDE = 0x0008; /* hazeltine tilde kludge */ 184*7c478bd9Sstevel@tonic-gate const LMDMBUF = 0x0010; /* start/stop output on carrier intr */ 185*7c478bd9Sstevel@tonic-gate const LLITOUT = 0x0020; /* literal output */ 186*7c478bd9Sstevel@tonic-gate const LTOSTOP = 0x0040; /* SIGTTOU on background output */ 187*7c478bd9Sstevel@tonic-gate const LFLUSHO = 0x0080; /* flush output to terminal */ 188*7c478bd9Sstevel@tonic-gate const LNOHANG = 0x0100; /* no SIGHUP on carrier drop */ 189*7c478bd9Sstevel@tonic-gate const LL001000 = 0x0200; 190*7c478bd9Sstevel@tonic-gate const LCRTKIL = 0x0400; /* kill line with " \b " */ 191*7c478bd9Sstevel@tonic-gate const LPASS8 = 0x0800; 192*7c478bd9Sstevel@tonic-gate const LCTLECH = 0x1000; /* echo control chars as ^X */ 193*7c478bd9Sstevel@tonic-gate const LPENDIN = 0x2000; /* needs reread */ 194*7c478bd9Sstevel@tonic-gate const LDECCTQ = 0x4000; /* only ^Q starts after ^S */ 195*7c478bd9Sstevel@tonic-gate const LNOFLSH = 0x8000; /* no output flush on signal */ 196*7c478bd9Sstevel@tonic-gate 197*7c478bd9Sstevel@tonic-gate program REXPROG { 198*7c478bd9Sstevel@tonic-gate version REXVERS { 199*7c478bd9Sstevel@tonic-gate 200*7c478bd9Sstevel@tonic-gate /* 201*7c478bd9Sstevel@tonic-gate * Start remote execution 202*7c478bd9Sstevel@tonic-gate */ 203*7c478bd9Sstevel@tonic-gate rex_result 204*7c478bd9Sstevel@tonic-gate REXPROC_START(rex_start) = 1; 205*7c478bd9Sstevel@tonic-gate 206*7c478bd9Sstevel@tonic-gate /* 207*7c478bd9Sstevel@tonic-gate * Wait for remote execution to terminate 208*7c478bd9Sstevel@tonic-gate */ 209*7c478bd9Sstevel@tonic-gate rex_result 210*7c478bd9Sstevel@tonic-gate REXPROC_WAIT(void) = 2; 211*7c478bd9Sstevel@tonic-gate 212*7c478bd9Sstevel@tonic-gate /* 213*7c478bd9Sstevel@tonic-gate * Send tty modes 214*7c478bd9Sstevel@tonic-gate */ 215*7c478bd9Sstevel@tonic-gate void 216*7c478bd9Sstevel@tonic-gate REXPROC_MODES(rex_ttymode) = 3; 217*7c478bd9Sstevel@tonic-gate 218*7c478bd9Sstevel@tonic-gate /* 219*7c478bd9Sstevel@tonic-gate * Send window size change 220*7c478bd9Sstevel@tonic-gate */ 221*7c478bd9Sstevel@tonic-gate void 222*7c478bd9Sstevel@tonic-gate REXPROC_WINCH(rex_ttysize) = 4; 223*7c478bd9Sstevel@tonic-gate 224*7c478bd9Sstevel@tonic-gate /* 225*7c478bd9Sstevel@tonic-gate * Send other signal 226*7c478bd9Sstevel@tonic-gate */ 227*7c478bd9Sstevel@tonic-gate void 228*7c478bd9Sstevel@tonic-gate REXPROC_SIGNAL(int) = 5; 229*7c478bd9Sstevel@tonic-gate } = 1; 230*7c478bd9Sstevel@tonic-gate } = 100017; 231