Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!zaphod.mps.ohio-state.edu!mips!cmic!garvey From: garvey@cmic.UUCP (Joe Garvey) Newsgroups: comp.sys.hp Subject: Beware of serial port programs run by users Keywords: breaks hpux, warning, 4-port mux, hp9000/3xx Message-ID: <235@cmic.UUCP> Date: 2 Feb 90 21:30:16 GMT Organization: Califonia Microwave Inc., Sunnyvale, CA. Lines: 97 I was doing a little program to read/write from a serial interface on my HP 9000/370 running HP-UX 6.5. To my dismay, a small little software bug screwed the interface to a fair-thee-well. This program can be run by any user with access to the port. There should *not* be a getty running on this port, and a getty running on the other ports. It does not seem to affect the internal serial port (other than to give it a temporarily ridiculous set of settings). The response center considers this a feature. I consider it a bug. You decide for yourself. I call this program wedge.c... because of the effect it has. Consider yourself warned. After all forwarned is forarmed (four armed might actually be better :-) ). -------------------------- cut here ------------------------------------------ /* * This little demo program will cause a 4-port mux in a series 300 computer * to permenantly go out to lunch. In fact, in my case I used it on port 2 * and ports 0, 1, and 2 ceased to function. (You could see the getty issue * a prompt, but could not respond.) /dev/tty13.2 has no getty running on it. * * The only way out of this is to reset (turn the power off) the computer!!! * Any user can do this. Take heed a protect your serial ports accordingly. * * Modification History: * Joe Garvey, Jan 1990: Created to show HP what happened when I made a simple * mistake. * */ #include #include #include #include #include #include static int RAU_fd; /* file descriptor for RAU line */ main () { /***** Definitions *****/ struct termio RAU_Line_Settings; /***** Code *****/ if ((RAU_fd = open("/dev/tty13.2", O_RDWR)) < 0) { fprintf(stderr, "%s: ", "wedge"); fprintf(stderr, "Couldn't open RAU line \"%s\"\n", "/dev/tty13.2"); exit(1); } RAU_Line_Settings.c_iflag = IGNBRK | PARMRK | INPCK | IXANY; RAU_Line_Settings.c_oflag = ONOCR; /* use of CSTOP instead of CSTOPB screws a 4-port mux up */ /* even the ports you're not using!!! */ /* right */ RAU_Line_Settings.c_cflag = B2400 | CSTOPB | CREAD | CS8 | PARENB | PARODD | HUPCL; */ /* wrong */ RAU_Line_Settings.c_cflag = B2400 | CSTOP | CREAD | CS8 | PARENB | PARODD | HUPCL; RAU_Line_Settings.c_lflag = 0; RAU_Line_Settings.c_line = 0; RAU_Line_Settings.c_cc[VTIME] = 1; RAU_Line_Settings.c_cc[VMIN] = 0; if (ioctl(RAU_fd, TCSETA, &RAU_Line_Settings) < 0) { fprintf(stderr, "%s: ", "wedge"); fprintf(stderr, "Couldn't configure RAU line\n"); exit(1); } sleep(1000); /* use this delay to check settings of line using stty(1) */ /* stty -a < /dev/tty13.2 */ return; } -------------------------- cut here, too ------------------------------------- Joe Garvey UUCP: {apple,backbone}!versatc!mips!cmic!garvey California Microwave Internet: garvey%cmic@mips.com 990 Almanor Ave HP Desk: xxx ("mips!cmic!garvey")/hp1900/ux Sunnyvale, Ca, 94086 800-831-3104 (outside CA) 408-720-6439 (let it ring) 800-824-7814 (inside CA)