Fix stair-stepped output when the output of a sudo command is piped
to another command and use_pty is set.
This commit is contained in:
@@ -164,6 +164,9 @@
|
|||||||
#ifndef _S_IFLNK
|
#ifndef _S_IFLNK
|
||||||
# define _S_IFLNK S_IFLNK
|
# define _S_IFLNK S_IFLNK
|
||||||
#endif /* _S_IFLNK */
|
#endif /* _S_IFLNK */
|
||||||
|
#ifndef _S_IFIFO
|
||||||
|
# define _S_IFIFO S_IFIFO
|
||||||
|
#endif /* _S_IFIFO */
|
||||||
#ifndef S_ISREG
|
#ifndef S_ISREG
|
||||||
# define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
|
# define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
|
||||||
#endif /* S_ISREG */
|
#endif /* S_ISREG */
|
||||||
@@ -173,6 +176,9 @@
|
|||||||
#ifndef S_ISLNK
|
#ifndef S_ISLNK
|
||||||
# define S_ISLNK(m) (((m) & _S_IFMT) == _S_IFLNK)
|
# define S_ISLNK(m) (((m) & _S_IFMT) == _S_IFLNK)
|
||||||
#endif /* S_ISLNK */
|
#endif /* S_ISLNK */
|
||||||
|
#ifndef S_ISFIFO
|
||||||
|
# define S_ISFIFO(m) (((m) & _S_IFMT) == _S_IFIFO)
|
||||||
|
#endif /* S_ISLNK */
|
||||||
#ifndef S_ISTXT
|
#ifndef S_ISTXT
|
||||||
# define S_ISTXT 0001000
|
# define S_ISTXT 0001000
|
||||||
#endif /* S_ISTXT */
|
#endif /* S_ISTXT */
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
@@ -1159,6 +1160,7 @@ exec_pty(struct command_details *details, struct command_status *cstat)
|
|||||||
struct plugin_container *plugin;
|
struct plugin_container *plugin;
|
||||||
sigset_t set, oset;
|
sigset_t set, oset;
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
|
struct stat sb;
|
||||||
pid_t ppgrp;
|
pid_t ppgrp;
|
||||||
int sv[2];
|
int sv[2];
|
||||||
debug_decl(exec_pty, SUDO_DEBUG_EXEC)
|
debug_decl(exec_pty, SUDO_DEBUG_EXEC)
|
||||||
@@ -1259,6 +1261,8 @@ exec_pty(struct command_details *details, struct command_status *cstat)
|
|||||||
/* Not logging stdin, do not interpose. */
|
/* Not logging stdin, do not interpose. */
|
||||||
sudo_debug_printf(SUDO_DEBUG_INFO,
|
sudo_debug_printf(SUDO_DEBUG_INFO,
|
||||||
"stdin not a tty, not logging");
|
"stdin not a tty, not logging");
|
||||||
|
if (fstat(STDIN_FILENO, &sb) == 0 && S_ISFIFO(sb.st_mode))
|
||||||
|
pipeline = true;
|
||||||
io_fds[SFD_STDIN] = dup(STDIN_FILENO);
|
io_fds[SFD_STDIN] = dup(STDIN_FILENO);
|
||||||
if (io_fds[SFD_STDIN] == -1)
|
if (io_fds[SFD_STDIN] == -1)
|
||||||
sudo_fatal("dup");
|
sudo_fatal("dup");
|
||||||
@@ -1278,6 +1282,8 @@ exec_pty(struct command_details *details, struct command_status *cstat)
|
|||||||
/* Not logging stdout, do not interpose. */
|
/* Not logging stdout, do not interpose. */
|
||||||
sudo_debug_printf(SUDO_DEBUG_INFO,
|
sudo_debug_printf(SUDO_DEBUG_INFO,
|
||||||
"stdout not a tty, not logging");
|
"stdout not a tty, not logging");
|
||||||
|
if (fstat(STDOUT_FILENO, &sb) == 0 && S_ISFIFO(sb.st_mode))
|
||||||
|
pipeline = true;
|
||||||
io_fds[SFD_STDOUT] = dup(STDOUT_FILENO);
|
io_fds[SFD_STDOUT] = dup(STDOUT_FILENO);
|
||||||
if (io_fds[SFD_STDOUT] == -1)
|
if (io_fds[SFD_STDOUT] == -1)
|
||||||
sudo_fatal("dup");
|
sudo_fatal("dup");
|
||||||
@@ -1297,6 +1303,8 @@ exec_pty(struct command_details *details, struct command_status *cstat)
|
|||||||
/* Not logging stderr, do not interpose. */
|
/* Not logging stderr, do not interpose. */
|
||||||
sudo_debug_printf(SUDO_DEBUG_INFO,
|
sudo_debug_printf(SUDO_DEBUG_INFO,
|
||||||
"stderr not a tty, not logging");
|
"stderr not a tty, not logging");
|
||||||
|
if (fstat(STDERR_FILENO, &sb) == 0 && S_ISFIFO(sb.st_mode))
|
||||||
|
pipeline = true;
|
||||||
io_fds[SFD_STDERR] = dup(STDERR_FILENO);
|
io_fds[SFD_STDERR] = dup(STDERR_FILENO);
|
||||||
if (io_fds[SFD_STDERR] == -1)
|
if (io_fds[SFD_STDERR] == -1)
|
||||||
sudo_fatal("dup");
|
sudo_fatal("dup");
|
||||||
|
Reference in New Issue
Block a user