From 75cbed3446008ca8238877be9716a8ba608b0170 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20L=C3=B3pez?= Date: Thu, 4 Jun 2026 15:41:15 +0200 Subject: [PATCH] - Resolves: RHEL-95850 - A sudo'd command when invoked from ksh through a pipe mangles output, leaves tty insane --- ...-socketpair-for-stdin-stdout-same-as.patch | 44 +++++++++++++++++++ sudo.spec | 1 + 2 files changed, 45 insertions(+) create mode 100644 0005-exec_pty-Treat-a-socketpair-for-stdin-stdout-same-as.patch diff --git a/0005-exec_pty-Treat-a-socketpair-for-stdin-stdout-same-as.patch b/0005-exec_pty-Treat-a-socketpair-for-stdin-stdout-same-as.patch new file mode 100644 index 0000000..5517ff1 --- /dev/null +++ b/0005-exec_pty-Treat-a-socketpair-for-stdin-stdout-same-as.patch @@ -0,0 +1,44 @@ +From bcbaca6f69c68a9c249fed96514889a9cc886048 Mon Sep 17 00:00:00 2001 +From: "Todd C. Miller" +Date: Tue, 13 Jan 2026 14:18:50 -0700 +Subject: [PATCH] exec_pty: Treat a socketpair for stdin/stdout same as a pipe + for ksh + +Sudo will run a command that is part of a pipeline in the background. +However, ksh appears to use a socketpair instead of a pipe for this +which broke sudo's heuristic. With this change, a command like + $ sudo cat /etc/services | head -3 +will avoid setting the terminal to raw mode in ksh, which matches +the behavior of other shells. + + +Backported by Alejandro López assisted by Claude Sonnet 4.5. +--- + src/exec_pty.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/exec_pty.c b/src/exec_pty.c +index 7857cf89d..df1bffbd9 100644 +--- a/src/exec_pty.c ++++ b/src/exec_pty.c +@@ -1220,7 +1220,7 @@ exec_pty(struct command_details *details, + /* Not logging stdin, do not interpose. */ + sudo_debug_printf(SUDO_DEBUG_INFO, + "stdin not user's tty, not logging"); +- if (S_ISFIFO(sb.st_mode)) ++ if (S_ISFIFO(sb.st_mode) || S_ISSOCK(sb.st_mode)) + SET(details->flags, CD_EXEC_BG); + io_fds[SFD_STDIN] = dup(STDIN_FILENO); + if (io_fds[SFD_STDIN] == -1) +@@ -1267,7 +1267,7 @@ exec_pty(struct command_details *details, + /* Not logging stdout, do not interpose. */ + sudo_debug_printf(SUDO_DEBUG_INFO, + "stdout not user's tty, not logging"); +- if (S_ISFIFO(sb.st_mode)) { ++ if (S_ISFIFO(sb.st_mode) || S_ISSOCK(sb.st_mode)) { + SET(details->flags, CD_EXEC_BG); + term_raw_flags = SUDO_TERM_OFLAG; + } +-- +2.54.0 + diff --git a/sudo.spec b/sudo.spec index c4720b1..1c28a66 100644 --- a/sudo.spec +++ b/sudo.spec @@ -34,6 +34,7 @@ Patch1: 0001-coverity.patch Patch2: 0002-sudo-conf.patch Patch3: 0003-rebuild_env-Avoid-setting-SHELL-twice-for-sudo-i.patch Patch4: 0004-cve-2026-35535.patch +Patch5: 0005-exec_pty-Treat-a-socketpair-for-stdin-stdout-same-as.patch %description Sudo (superuser do) allows a system administrator to give certain