# # $Id: README,v 1.5 1997/05/29 14:50:45 dmlb Exp $ # tclpty and tkpty ================ tclpty and tkpty are versions of tclsh and wish built with the 'pty' command which creates a new channel type for tcl7.6. A pty/tty pair is opened and a command is then exec'd with its input and output streams connected to the slave side of the pair. The master side is accessible using the normal tcl channel and file manipulation commands. A C API interface (Tcl_OpenPtyChannel) is also provided which is similar to Tcl_OpenFileChannel. The pty command allows setting of the termios and winsize structures both from the C API and the tcl command. Author ====== tclpty was written by Duncan Barclay, dmlb@ragnet.demon.co.uk Versioning and Availability =========================== tclpty has not yet got an official home, the Tcl archive at ftp.neosoft.com contains the most recent copy: ftp://ftp.neosoft.com/pub/tcl/sorted/devel/tclpty-1.0.tar.gz The current version is 1.0 and is listed in the file pty.h. History ======= tclpty grew from an urge to learn about and play with ptys. As I quite like hacking in tcl I threw together a very rough version of the pty command. As I added a couple of features (and moved to Tcl 7.6) the code got to a size where an extra few hours of work would produce a (hopefully) reasonable package to release. One question must spring to many peoples mids. Why didn't he use expect? Well, the answer is simple. Even though I knew about expect I had never used it and it was quicker to write a bit of C than to pull expect off the net (i.e. I started hacking ptys late one night at home). Obviously tclpty overlaps greatly with expect but someone may find it suits them better. Installation and Running ======================== On FreeBSD 2.2.1 (and probably 2.2.2 and maybe current) if you have installed the tcl-7.6 and tk-4.2 packages then all that should be needed is a make. The example program in tksh can be run with $ cd tksh $ ./tksh If tcl-7.6 or tk-4.2 is not installed then a local copy can installed in the directory the tclpty was unpacked in with the following commands. $ pkg_add -R -p `pwd`/tcl7.6 /usr/packages/All/tcl-7.6.tgz $ pkg_add -R -p `pwd`/tcl4.2 /usr/packages/All/tcl-4.2.tgz Edit the Makefile to change the library lines and type make. To run the example programs $ cd tksh $ LD_LIBRARY_PATH=`pwd`/../tcl7.6/lib:`pwd`/../tk4.2/lib \ TCL_LIBRARY=`pwd`/../tcl7.6/lib/tcl7.6 \ TK_LIBRARY=`pwd`/../tk4.2/lib/tk4.2 \ ./tksh As I haven't tested tclpty on other machines I will refer to the next section, the infamous porting notes... Porting ======= I wrote tclpty on FreeBSD 2.2.1 and used the functions in FreeBSDs libutil which actually open the pty. I have provided a copy of this in the libutil subdirectory with this distribution. All that is really needed is a function which searches the ptys on your system and opens the first available one. If people send me diffs of their ports I will try to combine them into a simple library. Under FreeBSD ptys are locked by changing permissions and ownership. This requires tclpty to run suid root. I have attempted to contain the security hole by wrapping all operations that require root privilege in calls to a couple of functions which get and release the privilege. These functions (in ptyInit.c) use seteuid(2), geteuid(2) and getuid(2). I hope that this will be vaguley portable in a POSIX world. I haven't really tested the security of tclpty so use as suid at your peril! Any additions to the security will be greatly appreciated and rolled into future releases. Future Work =========== To be honest I feel that tclpty is as functionally complete as it ever needs to be. It is not perfect but it does hopefully do one job well and not suffer from too much bloat. As such I will not really develop it further but will be ready to track new Tcl releases and incorporate ports, bug fixes and any minor additions (a few a marked in the source).