Skip to content

Commit bcbaca6

Browse files
committed
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.
1 parent 140331b commit bcbaca6

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/exec_pty.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,7 @@ exec_pty(struct command_details *details,
12411241
/* Not logging stdin, do not interpose. */
12421242
sudo_debug_printf(SUDO_DEBUG_INFO,
12431243
"stdin not user's tty, not logging");
1244-
if (S_ISFIFO(sb.st_mode))
1244+
if (S_ISFIFO(sb.st_mode) || S_ISSOCK(sb.st_mode))
12451245
SET(details->flags, CD_EXEC_BG);
12461246
io_fds[SFD_STDIN] = dup(STDIN_FILENO);
12471247
if (io_fds[SFD_STDIN] == -1)
@@ -1273,7 +1273,7 @@ exec_pty(struct command_details *details,
12731273
/* Not logging stdout, do not interpose. */
12741274
sudo_debug_printf(SUDO_DEBUG_INFO,
12751275
"stdout not user's tty, not logging");
1276-
if (S_ISFIFO(sb.st_mode)) {
1276+
if (S_ISFIFO(sb.st_mode) || S_ISSOCK(sb.st_mode)) {
12771277
SET(details->flags, CD_EXEC_BG);
12781278
term_raw_flags = SUDO_TERM_OFLAG;
12791279
}

0 commit comments

Comments
 (0)