1 /*
2  *  Copyright conserver.com, 2000
3  *
4  *  Maintainer/Enhancer: Bryan Stansell (bryan@conserver.com)
5  *
6  *  Copyright GNAC, Inc., 1998
7  */
8 
9 /*
10  * Copyright 1992 Purdue Research Foundation, West Lafayette, Indiana
11  * 47907.  All rights reserved.
12  *
13  * Written by Kevin S Braunsdorf, ksb@cc.purdue.edu, purdue!ksb
14  *
15  * This software is not subject to any license of the American Telephone
16  * and Telegraph Company or the Regents of the University of California.
17  *
18  * Permission is granted to anyone to use this software for any purpose on
19  * any computer system, and to alter it and redistribute it freely, subject
20  * to the following restrictions:
21  *
22  * 1. Neither the authors nor Purdue University are responsible for any
23  *    consequences of the use of this software.
24  *
25  * 2. The origin of this software must not be misrepresented, either by
26  *    explicit claim or by omission.  Credit to the authors and Purdue
27  *    University must appear in documentation and sources.
28  *
29  * 3. Altered versions must be plainly marked as such, and must not be
30  *    misrepresented as being the original software.
31  *
32  * 4. This notice may not be removed or altered.
33  */
34 /* states for a server fsm
35  */
36 typedef enum clientState {
37     S_NORMAL,			/* just pass character                     */
38     S_ESC1,			/* first escape character received         */
39     S_CMD,			/* second interrupt character received     */
40     S_CATTN,			/* change 1 escape char to next input char */
41     S_CESC,			/* change 2 escape char to next input char */
42     S_HALT1,			/* we have a halt sequence in progress     */
43     S_SUSP,			/* we are suspened, first char wakes us up */
44     S_IDENT,			/* probational connection (who is this)    */
45     S_PASSWD,			/* still needs a passwd to connect         */
46     S_QUOTE,			/* send any character we can spell         */
47     S_BCAST,			/* send a broadcast message to all clients */
48     S_CWAIT,			/* wait for client                         */
49     S_CEXEC,			/* client execing a program                */
50     S_REPLAY,			/* set replay length for 'r'               */
51     S_PLAYBACK,			/* set replay length for 'p'               */
52     S_NOTE,			/* send a note to the logfile              */
53     S_TASK,			/* invoke a task on the server side        */
54     S_CONFIRM			/* confirm input                           */
55 } CLIENTSTATE;
56 
57 typedef struct client {		/* Connection Information:              */
58     CONSFILE *fd;		/* file descriptor                      */
59     short fcon;			/* currently connect or not             */
60     short fwr;			/* (client) write enable flag           */
61     short fwantwr;		/* (client) wants to write              */
62     short fro;			/* read-only permission                 */
63     short fecho;		/* echo commands (not set by machines)  */
64     short fiwait;		/* client wanting for console init      */
65     STRING *acid;		/* login and location of client         */
66     STRING *peername;		/* location of client                   */
67     STRING *username;		/* login of client                      */
68     time_t tym;			/* time of connect                      */
69     time_t typetym;		/* time of last keystroke               */
70     char actym[32];		/* pre-formatted time                   */
71     struct consent
72      *pCEto;			/* host a client gets output from       */
73     struct client
74     **ppCLbscan,		/* back link for scan ptr               */
75      *pCLscan,			/* next client fd to scan after select  */
76 	/* scan lists link ALL clients together */
77     **ppCLbnext,		/* back link for next ptr               */
78      *pCLnext;			/* next person on this list             */
79     /* next lists link clients on a console */
80     char ic[2];			/* two character escape sequence        */
81     unsigned short replay;	/* lines to replay for 'r'              */
82     unsigned short playback;	/* lines to replay for 'p'              */
83     CLIENTSTATE iState;		/* state for fsm in server              */
84     char caccess;		/* did we trust the remote machine      */
85     IOSTATE ioState;		/* state of the socket                  */
86     time_t stateTimer;		/* timer for various ioState states */
87     STRING *accmd;		/* the command the user issued          */
88     INADDR_STYPE cnct_port;	/* where from                           */
89     FLAG confirmed;		/* confirm state                        */
90     CLIENTSTATE cState;		/* state needing confirmation           */
91     char cOption;		/* option initiating the confirmation   */
92 } CONSCLIENT;
93 
94 extern void Replay(CONSENT *, CONSFILE *, unsigned short);
95 extern void HelpUser(CONSCLIENT *);
96 extern void FindWrite(CONSENT *);
97 extern int ClientAccessOk(CONSCLIENT *);
98 extern void BumpClient(CONSENT *, char *);
99