Make iobufs private to exec_iolog.c.
This commit is contained in:
@@ -36,10 +36,10 @@
|
|||||||
#include "sudo_plugin.h"
|
#include "sudo_plugin.h"
|
||||||
#include "sudo_plugin_int.h"
|
#include "sudo_plugin_int.h"
|
||||||
|
|
||||||
struct io_buffer_list iobufs = SLIST_HEAD_INITIALIZER(&iobufs);
|
|
||||||
|
|
||||||
int io_fds[6] = { -1, -1, -1, -1, -1, -1 };
|
int io_fds[6] = { -1, -1, -1, -1, -1, -1 };
|
||||||
|
|
||||||
|
static struct io_buffer_list iobufs = SLIST_HEAD_INITIALIZER(&iobufs);
|
||||||
|
|
||||||
static sigset_t ttyblock;
|
static sigset_t ttyblock;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -103,8 +103,7 @@ void
|
|||||||
io_buf_new(int rfd, int wfd,
|
io_buf_new(int rfd, int wfd,
|
||||||
bool (*action)(const char *, unsigned int, struct io_buffer *),
|
bool (*action)(const char *, unsigned int, struct io_buffer *),
|
||||||
void (*read_cb)(int fd, int what, void *v),
|
void (*read_cb)(int fd, int what, void *v),
|
||||||
void (*write_cb)(int fd, int what, void *v),
|
void (*write_cb)(int fd, int what, void *v), struct exec_closure *ec)
|
||||||
struct exec_closure *ec, struct io_buffer_list *head)
|
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
struct io_buffer *iob;
|
struct io_buffer *iob;
|
||||||
@@ -132,7 +131,7 @@ io_buf_new(int rfd, int wfd,
|
|||||||
iob->buf[0] = '\0';
|
iob->buf[0] = '\0';
|
||||||
if (iob->revent == NULL || iob->wevent == NULL)
|
if (iob->revent == NULL || iob->wevent == NULL)
|
||||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||||
SLIST_INSERT_HEAD(head, iob, entries);
|
SLIST_INSERT_HEAD(&iobufs, iob, entries);
|
||||||
|
|
||||||
debug_return;
|
debug_return;
|
||||||
}
|
}
|
||||||
|
@@ -502,7 +502,7 @@ interpose_pipes(struct exec_closure *ec, int io_pipe[3][2])
|
|||||||
if (pipe2(io_pipe[STDIN_FILENO], O_CLOEXEC) != 0)
|
if (pipe2(io_pipe[STDIN_FILENO], O_CLOEXEC) != 0)
|
||||||
sudo_fatal("%s", U_("unable to create pipe"));
|
sudo_fatal("%s", U_("unable to create pipe"));
|
||||||
io_buf_new(STDIN_FILENO, io_pipe[STDIN_FILENO][1],
|
io_buf_new(STDIN_FILENO, io_pipe[STDIN_FILENO][1],
|
||||||
log_stdin, read_callback, write_callback, ec, &iobufs);
|
log_stdin, read_callback, write_callback, ec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (interpose[STDOUT_FILENO]) {
|
if (interpose[STDOUT_FILENO]) {
|
||||||
@@ -512,7 +512,7 @@ interpose_pipes(struct exec_closure *ec, int io_pipe[3][2])
|
|||||||
if (pipe2(io_pipe[STDOUT_FILENO], O_CLOEXEC) != 0)
|
if (pipe2(io_pipe[STDOUT_FILENO], O_CLOEXEC) != 0)
|
||||||
sudo_fatal("%s", U_("unable to create pipe"));
|
sudo_fatal("%s", U_("unable to create pipe"));
|
||||||
io_buf_new(io_pipe[STDOUT_FILENO][0], STDOUT_FILENO,
|
io_buf_new(io_pipe[STDOUT_FILENO][0], STDOUT_FILENO,
|
||||||
log_stdout, read_callback, write_callback, ec, &iobufs);
|
log_stdout, read_callback, write_callback, ec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (interpose[STDERR_FILENO]) {
|
if (interpose[STDERR_FILENO]) {
|
||||||
@@ -522,7 +522,7 @@ interpose_pipes(struct exec_closure *ec, int io_pipe[3][2])
|
|||||||
if (pipe2(io_pipe[STDERR_FILENO], O_CLOEXEC) != 0)
|
if (pipe2(io_pipe[STDERR_FILENO], O_CLOEXEC) != 0)
|
||||||
sudo_fatal("%s", U_("unable to create pipe"));
|
sudo_fatal("%s", U_("unable to create pipe"));
|
||||||
io_buf_new(io_pipe[STDERR_FILENO][0], STDERR_FILENO,
|
io_buf_new(io_pipe[STDERR_FILENO][0], STDERR_FILENO,
|
||||||
log_stderr, read_callback, write_callback, ec, &iobufs);
|
log_stderr, read_callback, write_callback, ec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (want_winch) {
|
if (want_winch) {
|
||||||
|
@@ -1160,12 +1160,12 @@ exec_pty(struct command_details *details, struct command_status *cstat)
|
|||||||
/* Read from /dev/tty, write to pty leader */
|
/* Read from /dev/tty, write to pty leader */
|
||||||
if (!ISSET(details->flags, CD_BACKGROUND)) {
|
if (!ISSET(details->flags, CD_BACKGROUND)) {
|
||||||
io_buf_new(io_fds[SFD_USERTTY], io_fds[SFD_LEADER],
|
io_buf_new(io_fds[SFD_USERTTY], io_fds[SFD_LEADER],
|
||||||
log_ttyin, read_callback, write_callback, &ec, &iobufs);
|
log_ttyin, read_callback, write_callback, &ec);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read from pty leader, write to /dev/tty */
|
/* Read from pty leader, write to /dev/tty */
|
||||||
io_buf_new(io_fds[SFD_LEADER], io_fds[SFD_USERTTY],
|
io_buf_new(io_fds[SFD_LEADER], io_fds[SFD_USERTTY],
|
||||||
log_ttyout, read_callback, write_callback, &ec, &iobufs);
|
log_ttyout, read_callback, write_callback, &ec);
|
||||||
|
|
||||||
/* Are we the foreground process? */
|
/* Are we the foreground process? */
|
||||||
ec.foreground = tcgetpgrp(io_fds[SFD_USERTTY]) == ppgrp;
|
ec.foreground = tcgetpgrp(io_fds[SFD_USERTTY]) == ppgrp;
|
||||||
@@ -1194,7 +1194,7 @@ exec_pty(struct command_details *details, struct command_status *cstat)
|
|||||||
if (pipe2(io_pipe[STDIN_FILENO], O_CLOEXEC) != 0)
|
if (pipe2(io_pipe[STDIN_FILENO], O_CLOEXEC) != 0)
|
||||||
sudo_fatal("%s", U_("unable to create pipe"));
|
sudo_fatal("%s", U_("unable to create pipe"));
|
||||||
io_buf_new(STDIN_FILENO, io_pipe[STDIN_FILENO][1],
|
io_buf_new(STDIN_FILENO, io_pipe[STDIN_FILENO][1],
|
||||||
log_stdin, read_callback, write_callback, &ec, &iobufs);
|
log_stdin, read_callback, write_callback, &ec);
|
||||||
io_fds[SFD_STDIN] = io_pipe[STDIN_FILENO][0];
|
io_fds[SFD_STDIN] = io_pipe[STDIN_FILENO][0];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1225,7 +1225,7 @@ exec_pty(struct command_details *details, struct command_status *cstat)
|
|||||||
if (pipe2(io_pipe[STDOUT_FILENO], O_CLOEXEC) != 0)
|
if (pipe2(io_pipe[STDOUT_FILENO], O_CLOEXEC) != 0)
|
||||||
sudo_fatal("%s", U_("unable to create pipe"));
|
sudo_fatal("%s", U_("unable to create pipe"));
|
||||||
io_buf_new(io_pipe[STDOUT_FILENO][0], STDOUT_FILENO,
|
io_buf_new(io_pipe[STDOUT_FILENO][0], STDOUT_FILENO,
|
||||||
log_stdout, read_callback, write_callback, &ec, &iobufs);
|
log_stdout, read_callback, write_callback, &ec);
|
||||||
io_fds[SFD_STDOUT] = io_pipe[STDOUT_FILENO][1];
|
io_fds[SFD_STDOUT] = io_pipe[STDOUT_FILENO][1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1245,7 +1245,7 @@ exec_pty(struct command_details *details, struct command_status *cstat)
|
|||||||
if (pipe2(io_pipe[STDERR_FILENO], O_CLOEXEC) != 0)
|
if (pipe2(io_pipe[STDERR_FILENO], O_CLOEXEC) != 0)
|
||||||
sudo_fatal("%s", U_("unable to create pipe"));
|
sudo_fatal("%s", U_("unable to create pipe"));
|
||||||
io_buf_new(io_pipe[STDERR_FILENO][0], STDERR_FILENO,
|
io_buf_new(io_pipe[STDERR_FILENO][0], STDERR_FILENO,
|
||||||
log_stderr, read_callback, write_callback, &ec, &iobufs);
|
log_stderr, read_callback, write_callback, &ec);
|
||||||
io_fds[SFD_STDERR] = io_pipe[STDERR_FILENO][1];
|
io_fds[SFD_STDERR] = io_pipe[STDERR_FILENO][1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -195,14 +195,13 @@ bool log_stdout(const char *buf, unsigned int n, struct io_buffer *iob);
|
|||||||
bool log_stderr(const char *buf, unsigned int n, struct io_buffer *iob);
|
bool log_stderr(const char *buf, unsigned int n, struct io_buffer *iob);
|
||||||
void log_suspend(void *v, int signo);
|
void log_suspend(void *v, int signo);
|
||||||
void log_winchange(struct exec_closure *ec, unsigned int rows, unsigned int cols);
|
void log_winchange(struct exec_closure *ec, unsigned int rows, unsigned int cols);
|
||||||
void io_buf_new(int rfd, int wfd, bool (*action)(const char *, unsigned int, struct io_buffer *), void (*read_cb)(int fd, int what, void *v), void (*write_cb)(int fd, int what, void *v), struct exec_closure *ec, struct io_buffer_list *head);
|
void io_buf_new(int rfd, int wfd, bool (*action)(const char *, unsigned int, struct io_buffer *), void (*read_cb)(int fd, int what, void *v), void (*write_cb)(int fd, int what, void *v), struct exec_closure *ec);
|
||||||
int safe_close(int fd);
|
int safe_close(int fd);
|
||||||
void ev_free_by_fd(struct sudo_event_base *evbase, int fd);
|
void ev_free_by_fd(struct sudo_event_base *evbase, int fd);
|
||||||
void free_io_bufs(void);
|
void free_io_bufs(void);
|
||||||
void add_io_events(struct exec_closure *ec);
|
void add_io_events(struct exec_closure *ec);
|
||||||
void del_io_events(bool nonblocking);
|
void del_io_events(bool nonblocking);
|
||||||
void init_ttyblock(void);
|
void init_ttyblock(void);
|
||||||
extern struct io_buffer_list iobufs;
|
|
||||||
|
|
||||||
/* exec_nopty.c */
|
/* exec_nopty.c */
|
||||||
void exec_nopty(struct command_details *details, struct command_status *cstat);
|
void exec_nopty(struct command_details *details, struct command_status *cstat);
|
||||||
|
Reference in New Issue
Block a user