Add support for multiple Debug lines per program. Callers may
register arbitrary debug facilities or use built-in defaults. We now use separate Debug statements for plugins and programs.
This commit is contained in:
37
src/exec.c
37
src/exec.c
@@ -93,7 +93,7 @@ static int fork_cmnd(struct command_details *details, int sv[2])
|
||||
{
|
||||
struct command_status cstat;
|
||||
sigaction_t sa;
|
||||
debug_decl(fork_cmnd, SUDO_DEBUG_EXEC)
|
||||
debug_decl(fork_cmnd, SUDO_DEBUG_EXEC, sudo_debug_instance)
|
||||
|
||||
ppgrp = getpgrp(); /* parent's process group */
|
||||
|
||||
@@ -165,7 +165,7 @@ void
|
||||
exec_cmnd(struct command_details *details, struct command_status *cstat,
|
||||
int errfd)
|
||||
{
|
||||
debug_decl(exec_cmnd, SUDO_DEBUG_EXEC)
|
||||
debug_decl(exec_cmnd, SUDO_DEBUG_EXEC, sudo_debug_instance)
|
||||
|
||||
restore_signals();
|
||||
if (exec_setup(details, NULL, -1) == true) {
|
||||
@@ -173,10 +173,15 @@ exec_cmnd(struct command_details *details, struct command_status *cstat,
|
||||
sudo_debug_execve(SUDO_DEBUG_INFO, details->command,
|
||||
details->argv, details->envp);
|
||||
if (details->closefrom >= 0) {
|
||||
/* Preserve debug fd and error pipe as needed. */
|
||||
int debug_fd = sudo_debug_fd_get();
|
||||
if (debug_fd != -1)
|
||||
add_preserved_fd(&details->preserved_fds, debug_fd);
|
||||
int fd, maxfd;
|
||||
fd_set *debug_fds;
|
||||
|
||||
/* Preserve debug fds and error pipe as needed. */
|
||||
maxfd = sudo_debug_get_fds(&debug_fds);
|
||||
for (fd = 0; fd <= maxfd; fd++) {
|
||||
if (FD_ISSET(fd, debug_fds))
|
||||
add_preserved_fd(&details->preserved_fds, fd);
|
||||
}
|
||||
if (errfd != -1)
|
||||
add_preserved_fd(&details->preserved_fds, errfd);
|
||||
|
||||
@@ -206,7 +211,7 @@ backchannel_cb(int fd, int what, void *v)
|
||||
{
|
||||
struct exec_closure *ec = v;
|
||||
ssize_t n;
|
||||
debug_decl(backchannel_cb, SUDO_DEBUG_EXEC)
|
||||
debug_decl(backchannel_cb, SUDO_DEBUG_EXEC, sudo_debug_instance)
|
||||
|
||||
/* read child status */
|
||||
n = recv(fd, ec->cstat, sizeof(struct command_status), MSG_WAITALL);
|
||||
@@ -298,7 +303,7 @@ static struct sudo_event_base *
|
||||
exec_event_setup(int backchannel, struct exec_closure *ec)
|
||||
{
|
||||
struct sudo_event_base *evbase;
|
||||
debug_decl(exec_event_setup, SUDO_DEBUG_EXEC)
|
||||
debug_decl(exec_event_setup, SUDO_DEBUG_EXEC, sudo_debug_instance)
|
||||
|
||||
evbase = sudo_ev_base_alloc();
|
||||
if (evbase == NULL)
|
||||
@@ -349,7 +354,7 @@ sudo_execute(struct command_details *details, struct command_status *cstat)
|
||||
sigaction_t sa;
|
||||
pid_t child;
|
||||
int sv[2];
|
||||
debug_decl(sudo_execute, SUDO_DEBUG_EXEC)
|
||||
debug_decl(sudo_execute, SUDO_DEBUG_EXEC, sudo_debug_instance)
|
||||
|
||||
dispatch_pending_signals(cstat);
|
||||
|
||||
@@ -537,7 +542,7 @@ dispatch_signal(struct sudo_event_base *evbase, pid_t child,
|
||||
int signo, char *signame, struct command_status *cstat)
|
||||
{
|
||||
int rc = 1;
|
||||
debug_decl(dispatch_signal, SUDO_DEBUG_EXEC)
|
||||
debug_decl(dispatch_signal, SUDO_DEBUG_EXEC, sudo_debug_instance)
|
||||
|
||||
sudo_debug_printf(SUDO_DEBUG_INFO,
|
||||
"%s: evbase %p, child: %d, signo %s(%d), cstat %p",
|
||||
@@ -648,7 +653,7 @@ dispatch_signal_pty(struct sudo_event_base *evbase, pid_t child,
|
||||
int signo, char *signame, struct command_status *cstat)
|
||||
{
|
||||
int rc = 1;
|
||||
debug_decl(dispatch_signal_pty, SUDO_DEBUG_EXEC)
|
||||
debug_decl(dispatch_signal_pty, SUDO_DEBUG_EXEC, sudo_debug_instance)
|
||||
|
||||
sudo_debug_printf(SUDO_DEBUG_INFO,
|
||||
"%s: evbase %p, child: %d, signo %s(%d), cstat %p",
|
||||
@@ -707,7 +712,7 @@ signal_pipe_cb(int fd, int what, void *v)
|
||||
unsigned char signo;
|
||||
ssize_t nread;
|
||||
int rc = 0;
|
||||
debug_decl(signal_pipe_cb, SUDO_DEBUG_EXEC)
|
||||
debug_decl(signal_pipe_cb, SUDO_DEBUG_EXEC, sudo_debug_instance)
|
||||
|
||||
do {
|
||||
/* read signal pipe */
|
||||
@@ -755,7 +760,7 @@ dispatch_pending_signals(struct command_status *cstat)
|
||||
struct sigaction sa;
|
||||
unsigned char signo = 0;
|
||||
int rval = 0;
|
||||
debug_decl(dispatch_pending_signals, SUDO_DEBUG_EXEC)
|
||||
debug_decl(dispatch_pending_signals, SUDO_DEBUG_EXEC, sudo_debug_instance)
|
||||
|
||||
for (;;) {
|
||||
nread = read(signal_pipe[0], &signo, sizeof(signo));
|
||||
@@ -810,7 +815,7 @@ forward_signals(int sock, int what, void *v)
|
||||
struct sigforward *sigfwd;
|
||||
struct command_status cstat;
|
||||
ssize_t nsent;
|
||||
debug_decl(forward_signals, SUDO_DEBUG_EXEC)
|
||||
debug_decl(forward_signals, SUDO_DEBUG_EXEC, sudo_debug_instance)
|
||||
|
||||
while (!TAILQ_EMPTY(&sigfwd_list)) {
|
||||
sigfwd = TAILQ_FIRST(&sigfwd_list);
|
||||
@@ -854,7 +859,7 @@ schedule_signal(struct sudo_event_base *evbase, int signo)
|
||||
{
|
||||
struct sigforward *sigfwd;
|
||||
char signame[SIG2STR_MAX];
|
||||
debug_decl(schedule_signal, SUDO_DEBUG_EXEC)
|
||||
debug_decl(schedule_signal, SUDO_DEBUG_EXEC, sudo_debug_instance)
|
||||
|
||||
if (signo == SIGCONT_FG)
|
||||
strlcpy(signame, "CONT_FG", sizeof(signame));
|
||||
@@ -974,7 +979,7 @@ int
|
||||
pipe_nonblock(int fds[2])
|
||||
{
|
||||
int flags, rval;
|
||||
debug_decl(pipe_nonblock, SUDO_DEBUG_EXEC)
|
||||
debug_decl(pipe_nonblock, SUDO_DEBUG_EXEC, sudo_debug_instance)
|
||||
|
||||
rval = pipe(fds);
|
||||
if (rval != -1) {
|
||||
|
Reference in New Issue
Block a user