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