Fix 'stty -echo' in scripts
Resolves: RHEL-83043
This commit is contained in:
parent
f110868ac8
commit
2d578407ed
77
ksh-1.0.11-stty-noecho.patch
Normal file
77
ksh-1.0.11-stty-noecho.patch
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
From 4350174a5d4acabf78f97b28c6d0ae68ec703e78 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Martijn Dekker <martijn@inlv.org>
|
||||||
|
Date: Sun, 30 Mar 2025 00:14:35 +0000
|
||||||
|
Subject: [PATCH] Fix 'stty -echo' in scripts (re: 41ebb55a)
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
Vincent Mihalkovič (@vmihalko) reports:
|
||||||
|
> In ksh versions later than v1.0.0-beta.1, setting stty -echo in a
|
||||||
|
> script no longer works as expected. This issue did not occur in
|
||||||
|
> earlier versions.
|
||||||
|
>
|
||||||
|
> I performed a git bisect between the last known good tag (reboot)
|
||||||
|
> and the first known bad tag (v1.0.0-beta.1). The regression was
|
||||||
|
> introduced in commit 41ebb55a.
|
||||||
|
>
|
||||||
|
> Reproducer:
|
||||||
|
> read a
|
||||||
|
> stty -echo
|
||||||
|
> read b
|
||||||
|
>
|
||||||
|
> Expected Behavior:
|
||||||
|
> • Input for a should be visible.
|
||||||
|
> • Input for b should not be echoed to the terminal.
|
||||||
|
>
|
||||||
|
> Actual Behavior:
|
||||||
|
> • Input for a is visible as expected.
|
||||||
|
> • Input for b is also visible, despite stty -echo being set.
|
||||||
|
|
||||||
|
Analysis:
|
||||||
|
|
||||||
|
The problem was that the tty_set(-1, 0, NULL) call below, which
|
||||||
|
invalidates saved terminal attributes, was no longer being executed
|
||||||
|
when running a script (note that job.jobcontrol is 0/false for
|
||||||
|
scripts). See edit.c for the tty_set function and what it does.
|
||||||
|
|
||||||
|
src/cmd/ksh93/sh/jobs.c
|
||||||
|
1423: else if(job.jobcontrol)
|
||||||
|
1424: {
|
||||||
|
1425: if(pw->p_pid == tcgetpgrp(JOBTTY))
|
||||||
|
1426: {
|
||||||
|
...skipped for brevity...
|
||||||
|
1430: }
|
||||||
|
1431: tty_set(-1, 0, NULL);
|
||||||
|
1432: }
|
||||||
|
|
||||||
|
So, after running an external command such as stty, terminal
|
||||||
|
attributes that should have been invalidated were restored upon the
|
||||||
|
next 'read'. This was undoing the effect of the stty command.
|
||||||
|
|
||||||
|
src/cmd/ksh93/sh/jobs.c: job_wait():
|
||||||
|
- Move the test for job.jobcontrol so that saved terminal
|
||||||
|
attributes are again invalidated after running an external
|
||||||
|
command when job control for interactive shells is not active.
|
||||||
|
|
||||||
|
Resolves: https://github.com/ksh93/ksh/issues/836
|
||||||
|
---
|
||||||
|
src/cmd/ksh93/sh/jobs.c | 4 ++--
|
||||||
|
1 files changed, 2 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/cmd/ksh93/sh/jobs.c b/src/cmd/ksh93/sh/jobs.c
|
||||||
|
index c65bc6e66094..513afb5582ab 100644
|
||||||
|
--- a/src/cmd/ksh93/sh/jobs.c
|
||||||
|
+++ b/src/cmd/ksh93/sh/jobs.c
|
||||||
|
@@ -1420,9 +1420,9 @@ int job_wait(pid_t pid)
|
||||||
|
kill(sh.current_pid,SIGTSTP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
- else if(job.jobcontrol)
|
||||||
|
+ else
|
||||||
|
{
|
||||||
|
- if(pw->p_pid == tcgetpgrp(JOBTTY))
|
||||||
|
+ if(job.jobcontrol && pw->p_pid == tcgetpgrp(JOBTTY))
|
||||||
|
{
|
||||||
|
if(pw->p_pgrp==0)
|
||||||
|
pw->p_pgrp = pw->p_pid;
|
9
ksh.spec
9
ksh.spec
@ -4,7 +4,7 @@ URL: http://www.kornshell.com/
|
|||||||
License: EPL-1.0
|
License: EPL-1.0
|
||||||
Epoch: 3
|
Epoch: 3
|
||||||
Version: 1.0.6
|
Version: 1.0.6
|
||||||
Release: 8%{?dist}
|
Release: 9%{?dist}
|
||||||
Source0: https://github.com/ksh93/%{name}/archive/v%{version}/%{name}-%{version}.tar.gz
|
Source0: https://github.com/ksh93/%{name}/archive/v%{version}/%{name}-%{version}.tar.gz
|
||||||
Source1: kshcomp.conf
|
Source1: kshcomp.conf
|
||||||
Source2: kshrc.rhs
|
Source2: kshrc.rhs
|
||||||
@ -42,6 +42,9 @@ Patch8: ksh-1.0.10-pjob.patch
|
|||||||
#upstream commit: https://github.com/ksh93/ksh/commit/5e3a169785139809f1f733314f5660769c86d10c (test fix)
|
#upstream commit: https://github.com/ksh93/ksh/commit/5e3a169785139809f1f733314f5660769c86d10c (test fix)
|
||||||
Patch9: ksh-1.0.9-no-TERM-env-segfault.patch
|
Patch9: ksh-1.0.9-no-TERM-env-segfault.patch
|
||||||
|
|
||||||
|
# upstream commit: https://github.com/ksh93/ksh/commit/4350174a5d4acabf78f97b28c6d0ae68ec703e78
|
||||||
|
Patch10: ksh-1.0.11-stty-noecho.patch
|
||||||
|
|
||||||
Conflicts: pdksh
|
Conflicts: pdksh
|
||||||
Requires: coreutils, diffutils
|
Requires: coreutils, diffutils
|
||||||
BuildRequires: gcc
|
BuildRequires: gcc
|
||||||
@ -163,6 +166,10 @@ fi
|
|||||||
%config(noreplace) %{_sysconfdir}/binfmt.d/kshcomp.conf
|
%config(noreplace) %{_sysconfdir}/binfmt.d/kshcomp.conf
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Mar 31 2025 Vincent Mihalkovic <vmihalko@redhat.com> - 3:1.0.6-9
|
||||||
|
- Fix 'stty -echo' in scripts
|
||||||
|
Resolves: RHEL-83043
|
||||||
|
|
||||||
* Sat Mar 29 2025 Vincent Mihalkovic <vmihalko@redhat.com> - 3:1.0.6-8
|
* Sat Mar 29 2025 Vincent Mihalkovic <vmihalko@redhat.com> - 3:1.0.6-8
|
||||||
- Fix segfault on starting ksh with no TERM env var
|
- Fix segfault on starting ksh with no TERM env var
|
||||||
Resolves: RHEL-83283
|
Resolves: RHEL-83283
|
||||||
|
Loading…
Reference in New Issue
Block a user