From: Brian J. <bjj...@us...> - 2002-05-06 18:12:07
|
Everyone, I have a (very) preliminary version of a patch which provides a way to pipe serial input/output to programs instead of actual ports, as requested in the second-to-last item of the "TODO" file. Here's a URL: ftp://ftp.frontiernet.net/pub/users/brianj1/B2_pty_020506.patch (I'm not sure if this will work directly as input to patch; I had some trouble with "cvs rdiff" and had to manually edit things a bit.) Just put a pipe character ("|") at the beginning of the port device file name, and BII will allocate a pseudoterminal, connect the master side to the BII serial infrastructure, and run the rest of the port device file name as a program using "/bin/sh -c", with the slave side of the pty as its standard input, output, and error. I.e. BII will treat the process as a serial port, and the process will think it's talking to a normal terminal. On IRIX, the only platform I've tried, I can (sort of) open tcsh and get a shell prompt. I think the pty needs some slave-side configuration to get everything working right. But I can open a PPP daemon (via a shell script to set the correct environment variables) and talk TCP/IP between the Mac and the host. It works great: the host takes care of routing among the Mac, the host, and remote machines, so the Mac can connect to any machine the host can. Now all I have to do is upgrade to a version of MacOS which supports Appletalk over IP.... Way cool. The code in pty.c is stolen from GNU screen. I probably need to steal their slave-side setup code as well... it's big and ugly, though. I just hope it doesn't lead to too much autoconf madness. Some questions: - How should BII call wait() to clean up after the subprocess exits? From the serial port close handler? From a separate pthread (so it can block)? Currently I don't call it at all. - Should I automatically drop privileges in the subprocess if BII is running setuid? What's the philosophy for making BII security-conscious vs. just documenting the issues and saying, "if you install BII as setuid, you do so at your own risk"? - Any other security concerns? - Is the current code structure OK, or would you prefer that I move the PTY setup/fork/exec/etc. into a subroutine? I also added a hook for midi support: if the device name is "midi", it's treated specially (returns an error for now). I have no idea if Mac MIDI drivers actually use the serial manager, or if this is the best way to add MIDI to BasiliskII. Or if I'll get around to finding out within the next couple of years.... Brian J. Johnson -------------------------------------------------------------------- "The public needs NREN because 300 baud used to be fast and low- resolution graphics used to be pretty.... We wait impatiently, sure that we spend half our lives waiting for printers, and the other half waiting for disk drives. Time is a commodity." -- Jean Armour Polly |