From nobody Sat Feb 01 21:37:43 2025 X-Original-To: standards@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4YlmMC52GCz5m3Br for ; Sat, 01 Feb 2025 21:37:43 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YlmMC4V55z3bc1 for ; Sat, 01 Feb 2025 21:37:43 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1738445863; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=X01HhsJq4E4AiuehHQ1+BY8Z8XZ8KNCm6Bar9qAdicU=; b=MNgT/1L9rn6ylh8s0zHFI3rTqUxZ2/g+FKK1P/UCWUpqv2nKTdBs2t8tPxfXLutGWTDpMX 1n6kP7hE2npJxnMl0w8vsLBmQoNA74wmKE7omOC7gBT4OTHuoJccwR/ILTd02cDzpiskWR Tk3N++leWCMKalGdKUyNml+U5Lp0OtJiBFnx0NesyKPeQ9L/MLp0quwIshW+3yRvmg2vh9 bCvualS+tiP7o4ldLAVtl//rYKnGtahBO9jqJHJDQ3ooWcI7orHBI5xDGOvhPHpnetUSWX bsK2EavVZ+0YD4POGZDDe6Gb609QYJj/UvhbgYDcWZbwFUh2dwP5iEVgAg8ZVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1738445863; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=X01HhsJq4E4AiuehHQ1+BY8Z8XZ8KNCm6Bar9qAdicU=; b=TKEH4vXUMtemy+dfF9hBY1hB4WA2E6lMUxzrLYL6/8qApRZfks4NkwdccsydVX9t33OxVI yFHSvNGPaga9eQCx3LTk7DrytJU52Y65ffg26B0YB59ZFY1NaWjgrVXTscneOtpbO34nFR 1k2gLf5v+9CcbrLdkknYC5BJPDsYDE6KgrH3rs3aC34sTiUQSq4j0wTxXgtX6NeVpcqGKQ QMomDrKBQsamrC76gIv2AcOY482Thcxqi3zY4dgHO9tYy5Scy3Ltl7/Sw0f9hRU+j6RhaO gHsm7vK9d/kI7oaNg7D8wOUFdFSoQc7k9Qbv/NjlxU/Yp3Px1RHBKOP9jtbngg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1738445863; a=rsa-sha256; cv=none; b=Z1Znsgn59s+G/ri37B33evKYJsrysKlhsWTUti0Zccy//UWJ8jbzU6kJA6FxMkqUcsNjs7 sLLyLZa7hVTEYWVSZcSIbv1/V7F4GiLHWdXtGTBYHynblAVJuYVh+yYVRJyaxui2TK8l7p 8aIDSk3/CGJ4GGXKrEimjXwfj9ZSJg8jEtVpxdg47xLAIwPi7weTrBbgyyCbiSvAD2klid ts1WAqJ5/yTneqjQgLp/UpVjDm4fKPQ85kqCXugdupKO7wwmge2KDlGUdacTnZtruRPwSa vPzE4848Q+DPrjuAunKI2TKz1eAO0S4rD48KcBGmnmmSpV3BlczKDYmyBntP+A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4YlmMC42Rgz65c for ; Sat, 01 Feb 2025 21:37:43 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 511Lbhou041138 for ; Sat, 1 Feb 2025 21:37:43 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 511Lbhco041137 for standards@FreeBSD.org; Sat, 1 Feb 2025 21:37:43 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: standards@FreeBSD.org Subject: [Bug 284513] Default bourne shell /bin/sh ignores or destroys terminal echoctl flag Date: Sat, 01 Feb 2025 21:37:43 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: standards X-Bugzilla-Version: 14.2-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: dclarke@blastwave.org X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: standards@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Standards compliance List-Archive: https://lists.freebsd.org/archives/freebsd-standards List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: freebsd-standards@freebsd.org Sender: owner-freebsd-standards@FreeBSD.org MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D284513 Bug ID: 284513 Summary: Default bourne shell /bin/sh ignores or destroys terminal echoctl flag Product: Base System Version: 14.2-RELEASE Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: standards Assignee: standards@FreeBSD.org Reporter: dclarke@blastwave.org One of the key ideas in the UNIX world is that we should not astonish the u= ser. This has taken a few years to finally just call it a bug. The default FreeBSD bourne shell /bin/sh seems to ignore the terminal config flag echoctl and does not give the user any visual feedback to confirm that CTRL-C was issued. When one types anything on the input line for the default FreeBSD /bin/sh and then you enter CTRL-c it is silent. Which is to say that the chars "^C" do not appear. This is wrong behavior for normal terminal processing. Here I create a new account and then login via a serial terminal : hydra# uname -apKU FreeBSD hydra 14.2-RELEASE FreeBSD 14.2-RELEASE releng/14.2-n269506-c8918d6c7412 GENERIC amd64 amd64 1402000 1402000 hydra#=20 hydra# pw useradd -n debug -m -c 'Some DEBUG User' -d /home/debug -e '' \ > -g devl -M 0700 \ > -s /bin/sh -u 16042=20 hydra#=20 hydra# passwd debug Changing local password for debug New Password: Retype New Password: hydra#=20 * * * using a proper 1200 baud serial connection * * *=20 Then login with a serial terminal connection :=20 FreeBSD/amd64 (hydra) (ttyu0) login: debug Password: FreeBSD 14.2-RELEASE (GENERIC) releng/14.2-n269506-c8918d6c7412 Welcome to FreeBSD! Release Notes, Errata: https://www.FreeBSD.org/releases/ Security Advisories: https://www.FreeBSD.org/security/ FreeBSD Handbook: https://www.FreeBSD.org/handbook/ FreeBSD FAQ: https://www.FreeBSD.org/faq/ Questions List: https://www.FreeBSD.org/lists/questions/ FreeBSD Forums: https://forums.FreeBSD.org/ Documents installed with the system are in the /usr/local/share/doc/freebsd/ directory, or can be installed later with: pkg install en-freebsd-doc For other languages, replace "en" with a language code like de or fr. Show the version of FreeBSD installed: freebsd-version ; uname -a Please include that output and any error messages when posting questions. Introduction to manual pages: man man FreeBSD directory layout: man hier To change this login announcement, see motd(5). "man security" gives very good advice on how to tune the security of your FreeBSD system. debug@hydra:~ $=20 debug@hydra:~ $ uname -apKU FreeBSD hydra 14.2-RELEASE FreeBSD 14.2-RELEASE releng/14.2-n269506-c8918d6c7412 GENERIC amd64 amd64 1402000 1402000 debug@hydra:~ $=20 debug@hydra:~ $ echo $SHELL /bin/sh debug@hydra:~ $ ls -la=20 total 45 drwx------ 2 debug devl 9 Feb 1 20:12 . drwxr-xr-x 13 root devl 13 Feb 1 20:12 .. -rw-r--r-- 1 debug devl 950 Feb 1 20:12 .cshrc -rw-r--r-- 1 debug devl 311 Feb 1 20:12 .login -rw-r--r-- 1 debug devl 79 Feb 1 20:12 .login_conf -rw------- 1 debug devl 289 Feb 1 20:12 .mail_aliases -rw-r--r-- 1 debug devl 255 Feb 1 20:12 .mailrc -rw-r--r-- 1 debug devl 966 Feb 1 20:12 .profile -rw-r--r-- 1 debug devl 1003 Feb 1 20:12 .shrc debug@hydra:~ $=20 debug@hydra:~ $ stty -a=20 speed 1200 baud; 24 rows; 80 columns; lflags: icanon isig iexten echo echoe -echok echoke -echonl echoctl -echoprt -altwerase -noflsh -tostop -flusho -pendin -nokerninfo -extproc iflags: -istrip icrnl -inlcr -igncr ixon -ixoff ixany imaxbel -ignbrk brkint -inpck -ignpar -parmrk iutf8 oflags: opost onlcr -ocrnl tab3 -onocr -onlret cflags: cread cs8 -parenb -parodd hupcl clocal -cstopb -crtscts -dsrflow -dtrflow -mdmbuf rtsdtr cchars: discard =3D ^O; dsusp =3D ^Y; eof =3D ^D; eol =3D ; eol2 =3D ; erase =3D ^?; erase2 =3D ^H; intr =3D ^C; kill = =3D ^U; lnext =3D ^V; min =3D 1; quit =3D ^\; reprint =3D ^R; start =3D ^Q; status =3D ^T; stop =3D ^S; susp =3D ^Z; time =3D 0; werase =3D ^W; debug@hydra:~ $=20 debug@hydra:~ $ ls -lapb debug@hydra:~ $ That was a CTRL-c and it does not appear as ^C <-- bug !!=20 debug@hydra:~ $=20 Here I am astonished. Where is the CTRL-C ? Perhaps I can type :=20 debug@hydra:~ $ rm -rf /* How can you tell if that was ever entered or what? The echoctl was ignored. Even worse the default shell destroys the state of the terminal flag echoct= l. debug@hydra:~ $ stty -echoctl debug@hydra:~ $ ls -lapb=20 debug@hydra:~ $ the echoctl is destroyed or ignored !=20=20 debug@hydra:~ $ stty -a=20 speed 1200 baud; 24 rows; 80 columns; lflags: icanon isig iexten echo echoe -echok echoke -echonl echoctl -echoprt -altwerase -noflsh -tostop -flusho -pendin -nokerninfo -extproc iflags: -istrip icrnl -inlcr -igncr ixon -ixoff ixany imaxbel -ignbrk brkint -inpck -ignpar -parmrk iutf8 oflags: opost onlcr -ocrnl tab3 -onocr -onlret cflags: cread cs8 -parenb -parodd hupcl clocal -cstopb -crtscts -dsrflow -dtrflow -mdmbuf rtsdtr cchars: discard =3D ^O; dsusp =3D ^Y; eof =3D ^D; eol =3D ; eol2 =3D ; erase =3D ^?; erase2 =3D ^H; intr =3D ^C; kill = =3D ^U; lnext =3D ^V; min =3D 1; quit =3D ^\; reprint =3D ^R; start =3D ^Q; status =3D ^T; stop =3D ^S; susp =3D ^Z; time =3D 0; werase =3D ^W; debug@hydra:~ $ exit FreeBSD/amd64 (hydra) (ttyu0) login: OKay so that is the poor behavior of the default FreeBSD /bin/sh bourne shell which seems to handle CTRL chars poorly. Certainly CTRL-C. If I build a GNU BASH shell with minimal options. In fact, the configuration is ruthlessly harsh wherein it has no line editing and no processing of trivial control chars for things like the arrow keys on a keyboard. These are taken for granted by most users in the past three or four decades. Same machine where I now create another user to demonstrate correct behavio= r : hydra# pw useradd -n debug2 -m -c 'Another DEBUG User' -d /home/debug2 \ > -e '' -g devl -M 0700 \ > -s /usr/local/shell/bash -u 16041 hydra# passwd debug2 Changing local password for debug2 New Password: Retype New Password: hydra#=20 Then login as that user on a serial terminal connection. FreeBSD/amd64 (hydra) (ttyu0) login: debug2 Password: FreeBSD 14.2-RELEASE (GENERIC) releng/14.2-n269506-c8918d6c7412 Welcome to FreeBSD! Release Notes, Errata: https://www.FreeBSD.org/releases/ Security Advisories: https://www.FreeBSD.org/security/ FreeBSD Handbook: https://www.FreeBSD.org/handbook/ FreeBSD FAQ: https://www.FreeBSD.org/faq/ Questions List: https://www.FreeBSD.org/lists/questions/ FreeBSD Forums: https://forums.FreeBSD.org/ Documents installed with the system are in the /usr/local/share/doc/freebsd/ directory, or can be installed later with: pkg install en-freebsd-doc For other languages, replace "en" with a language code like de or fr. Show the version of FreeBSD installed: freebsd-version ; uname -a Please include that output and any error messages when posting questions. Introduction to manual pages: man man FreeBSD directory layout: man hier To change this login announcement, see motd(5). $=20 $ echo $SHELL /usr/local/shell/bash $=20 $ stty -a=20 speed 1200 baud; 24 rows; 80 columns; lflags: icanon isig iexten echo echoe -echok echoke -echonl echoctl -echoprt -altwerase -noflsh -tostop -flusho -pendin -nokerninfo -extproc iflags: -istrip icrnl -inlcr -igncr ixon -ixoff ixany imaxbel -ignbrk brkint -inpck -ignpar -parmrk iutf8 oflags: opost onlcr -ocrnl tab3 -onocr -onlret cflags: cread cs8 -parenb -parodd hupcl clocal -cstopb -crtscts -dsrflow -dtrflow -mdmbuf rtsdtr cchars: discard =3D ^O; dsusp =3D ^Y; eof =3D ^D; eol =3D ; eol2 =3D ; erase =3D ^?; erase2 =3D ^H; intr =3D ^C; kill = =3D ^U; lnext =3D ^V; min =3D 1; quit =3D ^\; reprint =3D ^R; start =3D ^Q; status =3D ^T; stop =3D ^S; susp =3D ^Z; time =3D 0; werase =3D ^W; $=20 $ ls -la ^C $=20 $ That was a CTRL-c and it works ! also we see ^C chars on the line ^C $ * * * now we flip the flag for echoctl * *=20 $ stty -echoctl $=20 $ That disables the output of CTRL chars like this -->=20 $=20 $ that is an invisible CTRL-c and that is correct for -echoctl terminal fl= ag $=20 $ stty echoctl $=20 $ Now we see the CTRL-c again ^C $ that is correct behavior .... fully reasonable and no surprise to the use= r ^C $=20 $ $SHELL --version=20 GNU bash, version 5.2.37(2)-release (x86_64-unknown-freebsd14.2) Copyright (C) 2022 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software; you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. $ exit logout FreeBSD/amd64 (hydra) (ttyu0) login:=20 Why the serial terminal config? Simply to remove any possible network layer from the problem. There is no telnet here. No SSHd daemon. This is a correct login to one of the machines serial ports. To be more clear here the GNU BASH shell that I tested with is merely a test case and the configuration was very harsh :=20 $ ./configure --prefix=3D/home/dclarke/local --enable-threads=3Dposix \ > --enable-xpg-echo-default --enable-minimal-config \ > --enable-strict-posix-default That is all. Nothing more.=20 That shell needs almost next to nothing : $ echo $SHELL /home/dclarke/local/bin/bash $=20 $ readelf -delV /home/dclarke/local/bin/bash | grep -E 'NEED|NAME|PATH' 0x0000000000000001 NEEDED Shared library: [libintl.so.8] 0x0000000000000001 NEEDED Shared library: [libiconv.so.2] 0x0000000000000001 NEEDED Shared library: [libdl.so.1] 0x0000000000000001 NEEDED Shared library: [libc.so.7] 0x000000006ffffffe VERNEED 0x402238 0x000000006fffffff VERNEEDNUM 2 $=20 This is the exact shell used by the debug2 user :=20 $ openssl dgst -sha256 -r $SHELL /usr/local/shell/bash=20 4e9ce6b33a9e909ab8d6df746898c8148a388f82eb333b7d577df9b2fa97a0d0 */home/dclarke/local/bin/bash 4e9ce6b33a9e909ab8d6df746898c8148a388f82eb333b7d577df9b2fa97a0d0 */usr/local/shell/bash $=20 The FreeBSD default bourne shell needs to respect the terminal echoctl flag correctly and output a "^C" char sequence correctly. There should be some reasonable feedback to let the user know what happened. It is wrong to astonish the user. -- Dennis Clarke RISC-V/SPARC/PPC/ARM/CISC UNIX and Linux spoken ps: some discussions were had with others and I think there is agreement that this is a bug :=20 https://lists.gnu.org/archive/html/bug-ncurses/2025-02/msg00001.html --=20 You are receiving this mail because: You are the assignee for the bug.=