Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!bbn!rochester!rutgers!mit-eddie!uw-beaver!tektronix!tekcrl!terryl From: terryl@tekcrl.TEK.COM Newsgroups: comp.unix.xenix,comp.sources.wanted,comp.unix.questions Subject: Re: tty watcher Message-ID: <1951@tekcrl.TEK.COM> Date: Thu, 17-Sep-87 18:16:22 EDT Article-I.D.: tekcrl.1951 Posted: Thu Sep 17 18:16:22 1987 Date-Received: Sun, 20-Sep-87 11:48:36 EDT References: <1180@mtune.ATT.COM> <198@flmis06.ATT.COM> Reply-To: terryl@tekcrl.tek.com Organization: Tektronix, Inc., Beaverton, OR. Lines: 33 Xref: mnetor comp.unix.xenix:778 comp.sources.wanted:2311 comp.unix.questions:4166 In article <198@flmis06.ATT.COM> mikel@flmis06.ATT.COM (Mikel Manitius) writes: >>2) is the major point here; there are no tty watchers that consist solely of a >>user-mode program that drops on top of a non-hacked UNIX system. > >I saw this done on 4.1bsd once, I even had the code that did it. It was >a simple program that figured out where the clist struct was for that user's >tty driver, and scanned it repeatidly in /dev/kmem for changes. It would >output his input line by line. > >This sort of thing should be feasable on most Unix systems... It's just >a pain figuring out where to find his clist, especially given just a >tty name. Actually, if you have a tty name, it is quite trivial to figure out where the C-list structure lives in kernel memory (assuming you have at least read access to /dev/kmem). ****WARNING, WILL ROBINSON!!! SPOILER AHEAD!!!**** It goes like this: first, do a stat(2) on said tty name. Inside of the stat structure returned is a field giving the major/minor number of the tty. Take the major number and use this to index into the cdevsw[] structure. One of the fields in the cdevsw[] structure is a pointer to the FIRST tty structure for the specific RS-232 device. Now use the minor number gotten from the stat(2) call to index into the tty structure. You now have a pointer to the tty structure for the tty name in question. It is left as an exercise to the student to find the appropriate C-list struc- ture. Terry Laskodi of Tektronix