From owner-freebsd-bugs@FreeBSD.ORG Fri Nov 12 01:10:10 2010 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E2ADE1065670 for ; Fri, 12 Nov 2010 01:10:09 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id A7D018FC20 for ; Fri, 12 Nov 2010 01:10:09 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id oAC1A9HE049337 for ; Fri, 12 Nov 2010 01:10:09 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id oAC1A94V049336; Fri, 12 Nov 2010 01:10:09 GMT (envelope-from gnats) Resent-Date: Fri, 12 Nov 2010 01:10:09 GMT Resent-Message-Id: <201011120110.oAC1A94V049336@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, "Ronald F.Guilmette" Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 262311065674 for ; Fri, 12 Nov 2010 01:02:12 +0000 (UTC) (envelope-from rfg@tristatelogic.com) Received: from outgoing.tristatelogic.com (segfault.tristatelogic.com [69.62.255.118]) by mx1.freebsd.org (Postfix) with ESMTP id 02EC38FC13 for ; Fri, 12 Nov 2010 01:02:11 +0000 (UTC) Received: by segfault.tristatelogic.com (Postfix, from userid 1237) id 87641BDC46; Thu, 11 Nov 2010 17:02:10 -0800 (PST) Message-Id: <20101112010210.87641BDC46@segfault.tristatelogic.com> Date: Thu, 11 Nov 2010 17:02:10 -0800 (PST) From: "Ronald F.Guilmette" To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: rfg@tristatelogic.com Subject: bin/152154: /bin/csh & /bin/tcsh improperly diddle termios flags X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: "Ronald F.Guilmette" List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Nov 2010 01:10:10 -0000 >Number: 152154 >Category: bin >Synopsis: /bin/csh & /bin/tcsh improperly diddle termios flags >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Nov 12 01:10:09 UTC 2010 >Closed-Date: >Last-Modified: >Originator: Ronald F. Guilmette >Release: FreeBSD 7.0-RELEASE i386 >Organization: Infinite Monkeys & Co. >Environment: System: FreeBSD segfault.tristatelogic.com 7.0-RELEASE FreeBSD 7.0-RELEASE #0: Tue Aug 5 02:38:40 PDT 2008 root@segfault.monkeys.com:/usr/src/sys/i386/compile/rfg20080805 i386 >Description: Apparently, /bin/csh (aka /bin/tcsh) is diddling termios flags, in particular the ECHO flag, for no apparently good reason and without ever even having been asked to do so. The result is that the /usr/bin/script program, when invoked with the -k option, will log every input character the user types in TWICE, but only if the user has SHELL set in the environment to either /bin/csh or to /bin/tcsh. This behavior does not seem to occur when and if SHELL is set to /bin/sh. >How-To-Repeat: setenv SHELL /bin/tcsh /usr/bin/script -k Then just type something... anything... and then exit the shell and then look at the typescript file to see the doubled characters. I further traced this problem down by inserting the following changes into /usr/bin/script. These show what the termios flags look like before and after the first call to select() within script.c, and thus they will show how once tcsh is fired up (as a child process) by script, it changes the termios flags on its pty, unsetting MANY of the bitflags, including ECHO. Note that if you run /usr/bin/script with these changes installed, and do so with SHELL set to /bin/sh then you will see that in that case, the termios bit flags DO NOT get diddled by the child shell process, and that the ECHO bitflag, in particular, does not get un-set, and thus, "script -k" works properly in that case. *** script.c.orig 2004-02-15 09:30:13.000000000 -0800 --- script.c 2010-11-11 16:41:15.000000000 -0800 *************** *** 92,95 **** --- 92,96 ---- fd_set rfd; int flushtime = 30; + int first_time = 1; aflg = kflg = 0; *************** *** 174,178 **** --- 175,184 ---- tv.tv_usec = 0; } + if (first_time & tcgetattr(master, &stt) >= 0) + fprintf (stderr, "Pre-select: 0x%08x\r\n", stt.c_lflag); n = select(master + 1, &rfd, 0, 0, tvp); + if (first_time & tcgetattr(master, &stt) >= 0) + fprintf (stderr, "Post-select: 0x%08x\r\n", stt.c_lflag); + first_time = 0; if (n < 0 && errno != EINTR) break; >Fix: I have no idea how to fix this. I tried to dredge into the tcsh source code, but it is just too imposing for me right now. So I'm sort-of hoping that somebody more familiarity with tcsh than me will dredge into it and find the problem. P.S. Strangely, when you run /usr/bin/script with SHELL set to /bin/tcsh and when you then run a program from the tcsh command prompt, that program will see a properly set group of termios bitflags, e.g. when and if it calls tcgetattr(). >Release-Note: >Audit-Trail: >Unformatted: