Convert sudo to use BSD TAILQ macros instead of home ground tail
queue functions. This includes a private queue.h header derived from FreeBSD. It is simpler to just use our own header rather than try to deal with macros that may or may not be present in various queue.h incarnations.
This commit is contained in:
@@ -186,63 +186,61 @@ conversation.o: $(srcdir)/conversation.c $(top_builddir)/config.h \
|
||||
$(srcdir)/sudo.h $(top_builddir)/pathnames.h \
|
||||
$(top_srcdir)/compat/stdbool.h $(incdir)/missing.h \
|
||||
$(incdir)/alloc.h $(incdir)/fatal.h $(incdir)/fileops.h \
|
||||
$(incdir)/list.h $(incdir)/sudo_conf.h $(incdir)/list.h \
|
||||
$(incdir)/sudo_debug.h $(incdir)/gettext.h \
|
||||
$(incdir)/sudo_plugin.h $(srcdir)/sudo_plugin_int.h
|
||||
$(incdir)/sudo_conf.h $(incdir)/queue.h $(incdir)/sudo_debug.h \
|
||||
$(incdir)/gettext.h $(incdir)/sudo_plugin.h \
|
||||
$(srcdir)/sudo_plugin_int.h
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/conversation.c
|
||||
env_hooks.o: $(srcdir)/env_hooks.c $(top_builddir)/config.h \
|
||||
$(top_srcdir)/compat/dlfcn.h $(srcdir)/sudo.h \
|
||||
$(top_builddir)/pathnames.h $(top_srcdir)/compat/stdbool.h \
|
||||
$(incdir)/missing.h $(incdir)/alloc.h $(incdir)/fatal.h \
|
||||
$(incdir)/fileops.h $(incdir)/list.h $(incdir)/sudo_conf.h \
|
||||
$(incdir)/list.h $(incdir)/sudo_debug.h $(incdir)/gettext.h \
|
||||
$(incdir)/sudo_plugin.h
|
||||
$(incdir)/fileops.h $(incdir)/sudo_conf.h $(incdir)/queue.h \
|
||||
$(incdir)/sudo_debug.h $(incdir)/gettext.h $(incdir)/sudo_plugin.h
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/env_hooks.c
|
||||
exec.o: $(srcdir)/exec.c $(top_builddir)/config.h $(srcdir)/sudo.h \
|
||||
$(top_builddir)/pathnames.h $(top_srcdir)/compat/stdbool.h \
|
||||
$(incdir)/missing.h $(incdir)/alloc.h $(incdir)/fatal.h \
|
||||
$(incdir)/fileops.h $(incdir)/list.h $(incdir)/sudo_conf.h \
|
||||
$(incdir)/list.h $(incdir)/sudo_debug.h $(incdir)/gettext.h \
|
||||
$(srcdir)/sudo_exec.h $(incdir)/sudo_plugin.h \
|
||||
$(incdir)/fileops.h $(incdir)/sudo_conf.h $(incdir)/queue.h \
|
||||
$(incdir)/sudo_debug.h $(incdir)/gettext.h $(srcdir)/sudo_exec.h \
|
||||
$(incdir)/sudo_event.h $(incdir)/queue.h $(incdir)/sudo_plugin.h \
|
||||
$(srcdir)/sudo_plugin_int.h
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/exec.c
|
||||
exec_common.o: $(srcdir)/exec_common.c $(top_builddir)/config.h \
|
||||
$(srcdir)/sudo.h $(top_builddir)/pathnames.h \
|
||||
$(top_srcdir)/compat/stdbool.h $(incdir)/missing.h \
|
||||
$(incdir)/alloc.h $(incdir)/fatal.h $(incdir)/fileops.h \
|
||||
$(incdir)/list.h $(incdir)/sudo_conf.h $(incdir)/list.h \
|
||||
$(incdir)/sudo_debug.h $(incdir)/gettext.h $(srcdir)/sudo_exec.h
|
||||
$(incdir)/sudo_conf.h $(incdir)/queue.h $(incdir)/sudo_debug.h \
|
||||
$(incdir)/gettext.h $(srcdir)/sudo_exec.h
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/exec_common.c
|
||||
exec_pty.o: $(srcdir)/exec_pty.c $(top_builddir)/config.h $(srcdir)/sudo.h \
|
||||
$(top_builddir)/pathnames.h $(top_srcdir)/compat/stdbool.h \
|
||||
$(incdir)/missing.h $(incdir)/alloc.h $(incdir)/fatal.h \
|
||||
$(incdir)/fileops.h $(incdir)/list.h $(incdir)/sudo_conf.h \
|
||||
$(incdir)/list.h $(incdir)/sudo_debug.h $(incdir)/gettext.h \
|
||||
$(srcdir)/sudo_exec.h $(incdir)/sudo_plugin.h \
|
||||
$(incdir)/fileops.h $(incdir)/sudo_conf.h $(incdir)/queue.h \
|
||||
$(incdir)/sudo_debug.h $(incdir)/gettext.h $(incdir)/sudo_event.h \
|
||||
$(incdir)/queue.h $(srcdir)/sudo_exec.h $(incdir)/sudo_plugin.h \
|
||||
$(srcdir)/sudo_plugin_int.h
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/exec_pty.c
|
||||
get_pty.o: $(srcdir)/get_pty.c $(top_builddir)/config.h $(srcdir)/sudo.h \
|
||||
$(top_builddir)/pathnames.h $(top_srcdir)/compat/stdbool.h \
|
||||
$(incdir)/missing.h $(incdir)/alloc.h $(incdir)/fatal.h \
|
||||
$(incdir)/fileops.h $(incdir)/list.h $(incdir)/sudo_conf.h \
|
||||
$(incdir)/list.h $(incdir)/sudo_debug.h $(incdir)/gettext.h
|
||||
$(incdir)/fileops.h $(incdir)/sudo_conf.h $(incdir)/queue.h \
|
||||
$(incdir)/sudo_debug.h $(incdir)/gettext.h
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/get_pty.c
|
||||
hooks.o: $(srcdir)/hooks.c $(top_builddir)/config.h $(srcdir)/sudo.h \
|
||||
$(top_builddir)/pathnames.h $(top_srcdir)/compat/stdbool.h \
|
||||
$(incdir)/missing.h $(incdir)/alloc.h $(incdir)/fatal.h \
|
||||
$(incdir)/fileops.h $(incdir)/list.h $(incdir)/sudo_conf.h \
|
||||
$(incdir)/list.h $(incdir)/sudo_debug.h $(incdir)/gettext.h \
|
||||
$(incdir)/sudo_plugin.h $(srcdir)/sudo_plugin_int.h \
|
||||
$(incdir)/sudo_debug.h
|
||||
$(incdir)/fileops.h $(incdir)/sudo_conf.h $(incdir)/queue.h \
|
||||
$(incdir)/sudo_debug.h $(incdir)/gettext.h $(incdir)/sudo_plugin.h \
|
||||
$(srcdir)/sudo_plugin_int.h $(incdir)/sudo_debug.h
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/hooks.c
|
||||
load_plugins.o: $(srcdir)/load_plugins.c $(top_builddir)/config.h \
|
||||
$(top_srcdir)/compat/dlfcn.h $(srcdir)/sudo.h \
|
||||
$(top_builddir)/pathnames.h $(top_srcdir)/compat/stdbool.h \
|
||||
$(incdir)/missing.h $(incdir)/alloc.h $(incdir)/fatal.h \
|
||||
$(incdir)/fileops.h $(incdir)/list.h $(incdir)/sudo_conf.h \
|
||||
$(incdir)/list.h $(incdir)/sudo_debug.h $(incdir)/gettext.h \
|
||||
$(incdir)/fileops.h $(incdir)/sudo_conf.h $(incdir)/queue.h \
|
||||
$(incdir)/sudo_debug.h $(incdir)/gettext.h \
|
||||
$(incdir)/sudo_plugin.h $(srcdir)/sudo_plugin_int.h \
|
||||
$(incdir)/sudo_conf.h $(incdir)/list.h $(incdir)/sudo_debug.h
|
||||
$(incdir)/sudo_conf.h $(incdir)/queue.h $(incdir)/sudo_debug.h
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/load_plugins.c
|
||||
locale_stub.o: $(srcdir)/locale_stub.c $(top_builddir)/config.h \
|
||||
$(incdir)/missing.h $(incdir)/fatal.h
|
||||
@@ -254,56 +252,54 @@ net_ifs.o: $(srcdir)/net_ifs.c $(top_builddir)/config.h $(incdir)/missing.h \
|
||||
openbsd.o: $(srcdir)/openbsd.c $(top_builddir)/config.h $(srcdir)/sudo.h \
|
||||
$(top_builddir)/pathnames.h $(top_srcdir)/compat/stdbool.h \
|
||||
$(incdir)/missing.h $(incdir)/alloc.h $(incdir)/fatal.h \
|
||||
$(incdir)/fileops.h $(incdir)/list.h $(incdir)/sudo_conf.h \
|
||||
$(incdir)/list.h $(incdir)/sudo_debug.h $(incdir)/gettext.h
|
||||
$(incdir)/fileops.h $(incdir)/sudo_conf.h $(incdir)/queue.h \
|
||||
$(incdir)/sudo_debug.h $(incdir)/gettext.h
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/openbsd.c
|
||||
parse_args.o: $(srcdir)/parse_args.c $(top_builddir)/config.h \
|
||||
$(top_srcdir)/compat/getopt.h ./sudo_usage.h $(srcdir)/sudo.h \
|
||||
$(top_builddir)/pathnames.h $(top_srcdir)/compat/stdbool.h \
|
||||
$(incdir)/missing.h $(incdir)/alloc.h $(incdir)/fatal.h \
|
||||
$(incdir)/fileops.h $(incdir)/list.h $(incdir)/sudo_conf.h \
|
||||
$(incdir)/list.h $(incdir)/sudo_debug.h $(incdir)/gettext.h \
|
||||
$(incdir)/lbuf.h
|
||||
$(incdir)/fileops.h $(incdir)/sudo_conf.h $(incdir)/queue.h \
|
||||
$(incdir)/sudo_debug.h $(incdir)/gettext.h $(incdir)/lbuf.h
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/parse_args.c
|
||||
preload.o: $(srcdir)/preload.c $(top_builddir)/config.h $(incdir)/sudo_plugin.h
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/preload.c
|
||||
selinux.o: $(srcdir)/selinux.c $(top_builddir)/config.h $(srcdir)/sudo.h \
|
||||
$(top_builddir)/pathnames.h $(top_srcdir)/compat/stdbool.h \
|
||||
$(incdir)/missing.h $(incdir)/alloc.h $(incdir)/fatal.h \
|
||||
$(incdir)/fileops.h $(incdir)/list.h $(incdir)/sudo_conf.h \
|
||||
$(incdir)/list.h $(incdir)/sudo_debug.h $(incdir)/gettext.h \
|
||||
$(srcdir)/sudo_exec.h
|
||||
$(incdir)/fileops.h $(incdir)/sudo_conf.h $(incdir)/queue.h \
|
||||
$(incdir)/sudo_debug.h $(incdir)/gettext.h $(srcdir)/sudo_exec.h
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/selinux.c
|
||||
sesh.o: $(srcdir)/sesh.c $(top_builddir)/config.h \
|
||||
$(top_srcdir)/compat/stdbool.h $(incdir)/missing.h $(incdir)/alloc.h \
|
||||
$(incdir)/fatal.h $(incdir)/gettext.h $(incdir)/sudo_conf.h \
|
||||
$(incdir)/list.h $(incdir)/sudo_debug.h $(srcdir)/sudo_exec.h \
|
||||
$(incdir)/queue.h $(incdir)/sudo_debug.h $(srcdir)/sudo_exec.h \
|
||||
$(incdir)/sudo_plugin.h
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/sesh.c
|
||||
signal.o: $(srcdir)/signal.c $(top_builddir)/config.h $(srcdir)/sudo.h \
|
||||
$(top_builddir)/pathnames.h $(top_srcdir)/compat/stdbool.h \
|
||||
$(incdir)/missing.h $(incdir)/alloc.h $(incdir)/fatal.h \
|
||||
$(incdir)/fileops.h $(incdir)/list.h $(incdir)/sudo_conf.h \
|
||||
$(incdir)/list.h $(incdir)/sudo_debug.h $(incdir)/gettext.h
|
||||
$(incdir)/fileops.h $(incdir)/sudo_conf.h $(incdir)/queue.h \
|
||||
$(incdir)/sudo_debug.h $(incdir)/gettext.h
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/signal.c
|
||||
solaris.o: $(srcdir)/solaris.c $(top_builddir)/config.h $(srcdir)/sudo.h \
|
||||
$(top_builddir)/pathnames.h $(top_srcdir)/compat/stdbool.h \
|
||||
$(incdir)/missing.h $(incdir)/alloc.h $(incdir)/fatal.h \
|
||||
$(incdir)/fileops.h $(incdir)/list.h $(incdir)/sudo_conf.h \
|
||||
$(incdir)/list.h $(incdir)/sudo_debug.h $(incdir)/gettext.h
|
||||
$(incdir)/fileops.h $(incdir)/sudo_conf.h $(incdir)/queue.h \
|
||||
$(incdir)/sudo_debug.h $(incdir)/gettext.h
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/solaris.c
|
||||
sudo.o: $(srcdir)/sudo.c $(top_builddir)/config.h ./sudo_usage.h \
|
||||
$(srcdir)/sudo.h $(top_builddir)/pathnames.h \
|
||||
$(top_srcdir)/compat/stdbool.h $(incdir)/missing.h $(incdir)/alloc.h \
|
||||
$(incdir)/fatal.h $(incdir)/fileops.h $(incdir)/list.h \
|
||||
$(incdir)/sudo_conf.h $(incdir)/list.h $(incdir)/sudo_debug.h \
|
||||
$(incdir)/gettext.h $(incdir)/sudo_plugin.h $(srcdir)/sudo_plugin_int.h
|
||||
$(incdir)/fatal.h $(incdir)/fileops.h $(incdir)/sudo_conf.h \
|
||||
$(incdir)/queue.h $(incdir)/sudo_debug.h $(incdir)/gettext.h \
|
||||
$(incdir)/sudo_plugin.h $(srcdir)/sudo_plugin_int.h
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/sudo.c
|
||||
sudo_edit.o: $(srcdir)/sudo_edit.c $(top_builddir)/config.h $(srcdir)/sudo.h \
|
||||
$(top_builddir)/pathnames.h $(top_srcdir)/compat/stdbool.h \
|
||||
$(incdir)/missing.h $(incdir)/alloc.h $(incdir)/fatal.h \
|
||||
$(incdir)/fileops.h $(incdir)/list.h $(incdir)/sudo_conf.h \
|
||||
$(incdir)/list.h $(incdir)/sudo_debug.h $(incdir)/gettext.h
|
||||
$(incdir)/fileops.h $(incdir)/sudo_conf.h $(incdir)/queue.h \
|
||||
$(incdir)/sudo_debug.h $(incdir)/gettext.h
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/sudo_edit.c
|
||||
sudo_noexec.lo: $(srcdir)/sudo_noexec.c $(top_builddir)/config.h \
|
||||
$(incdir)/missing.h
|
||||
@@ -311,20 +307,18 @@ sudo_noexec.lo: $(srcdir)/sudo_noexec.c $(top_builddir)/config.h \
|
||||
tgetpass.o: $(srcdir)/tgetpass.c $(top_builddir)/config.h $(srcdir)/sudo.h \
|
||||
$(top_builddir)/pathnames.h $(top_srcdir)/compat/stdbool.h \
|
||||
$(incdir)/missing.h $(incdir)/alloc.h $(incdir)/fatal.h \
|
||||
$(incdir)/fileops.h $(incdir)/list.h $(incdir)/sudo_conf.h \
|
||||
$(incdir)/list.h $(incdir)/sudo_debug.h $(incdir)/gettext.h \
|
||||
$(incdir)/sudo_plugin.h
|
||||
$(incdir)/fileops.h $(incdir)/sudo_conf.h $(incdir)/queue.h \
|
||||
$(incdir)/sudo_debug.h $(incdir)/gettext.h $(incdir)/sudo_plugin.h
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/tgetpass.c
|
||||
ttyname.o: $(srcdir)/ttyname.c $(top_builddir)/config.h $(srcdir)/sudo.h \
|
||||
$(top_builddir)/pathnames.h $(top_srcdir)/compat/stdbool.h \
|
||||
$(incdir)/missing.h $(incdir)/alloc.h $(incdir)/fatal.h \
|
||||
$(incdir)/fileops.h $(incdir)/list.h $(incdir)/sudo_conf.h \
|
||||
$(incdir)/list.h $(incdir)/sudo_debug.h $(incdir)/gettext.h
|
||||
$(incdir)/fileops.h $(incdir)/sudo_conf.h $(incdir)/queue.h \
|
||||
$(incdir)/sudo_debug.h $(incdir)/gettext.h
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/ttyname.c
|
||||
utmp.o: $(srcdir)/utmp.c $(top_builddir)/config.h $(srcdir)/sudo.h \
|
||||
$(top_builddir)/pathnames.h $(top_srcdir)/compat/stdbool.h \
|
||||
$(incdir)/missing.h $(incdir)/alloc.h $(incdir)/fatal.h \
|
||||
$(incdir)/fileops.h $(incdir)/list.h $(incdir)/sudo_conf.h \
|
||||
$(incdir)/list.h $(incdir)/sudo_debug.h $(incdir)/gettext.h \
|
||||
$(srcdir)/sudo_exec.h
|
||||
$(incdir)/fileops.h $(incdir)/sudo_conf.h $(incdir)/queue.h \
|
||||
$(incdir)/sudo_debug.h $(incdir)/gettext.h $(srcdir)/sudo_exec.h
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/utmp.c
|
||||
|
41
src/exec.c
41
src/exec.c
@@ -65,14 +65,13 @@ struct exec_closure {
|
||||
|
||||
/* We keep a tailq of signals to forward to child. */
|
||||
struct sigforward {
|
||||
struct sigforward *prev, *next;
|
||||
TAILQ_ENTRY(sigforward) entries;
|
||||
int signo;
|
||||
};
|
||||
static struct {
|
||||
struct sigforward *first, *last;
|
||||
struct sudo_event *event;
|
||||
} sigfwd_list;
|
||||
TAILQ_HEAD(sigfwd_list, sigforward);
|
||||
static struct sigfwd_list sigfwd_list = TAILQ_HEAD_INITIALIZER(sigfwd_list);
|
||||
static struct sudo_event *signal_event;
|
||||
static struct sudo_event *sigfwd_event;
|
||||
static struct sudo_event *backchannel_event;
|
||||
static pid_t ppgrp = -1;
|
||||
|
||||
@@ -318,9 +317,9 @@ exec_event_setup(int backchannel, struct exec_closure *ec)
|
||||
fatal(_("unable to add event to queue"));
|
||||
|
||||
/* The signal forwarding event gets added on demand. */
|
||||
sigfwd_list.event = sudo_ev_alloc(backchannel,
|
||||
sigfwd_event = sudo_ev_alloc(backchannel,
|
||||
SUDO_EV_WRITE, forward_signals, NULL);
|
||||
if (sigfwd_list.event == NULL)
|
||||
if (sigfwd_event == NULL)
|
||||
fatal(NULL);
|
||||
|
||||
sudo_debug_printf(SUDO_DEBUG_INFO, "signal pipe fd %d\n", signal_pipe[0]);
|
||||
@@ -373,7 +372,7 @@ sudo_execute(struct command_details *details, struct command_status *cstat)
|
||||
* need to allocate a pty. It is OK to set log_io in the pty-only case
|
||||
* as the io plugin tailqueue will be empty and no I/O logging will occur.
|
||||
*/
|
||||
if (!tq_empty(&io_plugins) || ISSET(details->flags, CD_USE_PTY)) {
|
||||
if (!TAILQ_EMPTY(&io_plugins) || ISSET(details->flags, CD_USE_PTY)) {
|
||||
log_io = true;
|
||||
if (ISSET(details->flags, CD_SET_UTMP))
|
||||
utmp_user = details->utmp_user ? details->utmp_user : user_details.username;
|
||||
@@ -494,12 +493,12 @@ sudo_execute(struct command_details *details, struct command_status *cstat)
|
||||
#endif
|
||||
|
||||
/* Free things up. */
|
||||
while (!tq_empty(&sigfwd_list)) {
|
||||
struct sigforward *sigfwd = tq_first(&sigfwd_list);
|
||||
tq_remove(&sigfwd_list, sigfwd);
|
||||
while (!TAILQ_EMPTY(&sigfwd_list)) {
|
||||
struct sigforward *sigfwd = TAILQ_FIRST(&sigfwd_list);
|
||||
TAILQ_REMOVE(&sigfwd_list, sigfwd, entries);
|
||||
efree(sigfwd);
|
||||
}
|
||||
sudo_ev_free(sigfwd_list.event);
|
||||
sudo_ev_free(sigfwd_event);
|
||||
sudo_ev_free(signal_event);
|
||||
sudo_ev_free(backchannel_event);
|
||||
sudo_ev_base_free(evbase);
|
||||
@@ -782,8 +781,8 @@ forward_signals(int sock, int what, void *v)
|
||||
ssize_t nsent;
|
||||
debug_decl(forward_signals, SUDO_DEBUG_EXEC)
|
||||
|
||||
while (!tq_empty(&sigfwd_list)) {
|
||||
sigfwd = tq_first(&sigfwd_list);
|
||||
while (!TAILQ_EMPTY(&sigfwd_list)) {
|
||||
sigfwd = TAILQ_FIRST(&sigfwd_list);
|
||||
if (sigfwd->signo == SIGCONT_FG)
|
||||
strlcpy(signame, "CONT_FG", sizeof(signame));
|
||||
else if (sigfwd->signo == SIGCONT_BG)
|
||||
@@ -797,16 +796,16 @@ forward_signals(int sock, int what, void *v)
|
||||
do {
|
||||
nsent = send(sock, &cstat, sizeof(cstat), 0);
|
||||
} while (nsent == -1 && errno == EINTR);
|
||||
tq_remove(&sigfwd_list, sigfwd);
|
||||
TAILQ_REMOVE(&sigfwd_list, sigfwd, entries);
|
||||
efree(sigfwd);
|
||||
if (nsent != sizeof(cstat)) {
|
||||
if (errno == EPIPE) {
|
||||
sudo_debug_printf(SUDO_DEBUG_ERROR,
|
||||
"broken pipe writing to child over backchannel");
|
||||
/* Other end of socket gone, empty out sigfwd_list. */
|
||||
while (!tq_empty(&sigfwd_list)) {
|
||||
sigfwd = tq_first(&sigfwd_list);
|
||||
tq_remove(&sigfwd_list, sigfwd);
|
||||
while (!TAILQ_EMPTY(&sigfwd_list)) {
|
||||
sigfwd = TAILQ_FIRST(&sigfwd_list);
|
||||
TAILQ_REMOVE(&sigfwd_list, sigfwd, entries);
|
||||
efree(sigfwd);
|
||||
}
|
||||
/* XXX - child (monitor) is dead, we should exit too? */
|
||||
@@ -835,12 +834,10 @@ schedule_signal(struct sudo_event_base *evbase, int signo)
|
||||
sudo_debug_printf(SUDO_DEBUG_DIAG, "scheduled SIG%s for child", signame);
|
||||
|
||||
sigfwd = ecalloc(1, sizeof(*sigfwd));
|
||||
sigfwd->prev = sigfwd;
|
||||
/* sigfwd->next = NULL; */
|
||||
sigfwd->signo = signo;
|
||||
tq_append(&sigfwd_list, sigfwd);
|
||||
TAILQ_INSERT_TAIL(&sigfwd_list, sigfwd, entries);
|
||||
|
||||
if (sudo_ev_add(evbase, sigfwd_list.event, true) == -1)
|
||||
if (sudo_ev_add(evbase, sigfwd_event, true) == -1)
|
||||
fatal(_("unable to add event to queue"));
|
||||
|
||||
debug_return;
|
||||
|
@@ -117,7 +117,7 @@ pty_cleanup(void)
|
||||
{
|
||||
debug_decl(cleanup, SUDO_DEBUG_EXEC);
|
||||
|
||||
if (!tq_empty(&io_plugins) && io_fds[SFD_USERTTY] != -1) {
|
||||
if (!TAILQ_EMPTY(&io_plugins) && io_fds[SFD_USERTTY] != -1) {
|
||||
check_foreground();
|
||||
if (foreground)
|
||||
term_restore(io_fds[SFD_USERTTY], 0);
|
||||
@@ -202,7 +202,7 @@ log_ttyin(const char *buf, unsigned int n)
|
||||
debug_decl(log_ttyin, SUDO_DEBUG_EXEC);
|
||||
|
||||
sigprocmask(SIG_BLOCK, &ttyblock, &omask);
|
||||
tq_foreach_fwd(&io_plugins, plugin) {
|
||||
TAILQ_FOREACH(plugin, &io_plugins, entries) {
|
||||
if (plugin->u.io->log_ttyin) {
|
||||
if (!plugin->u.io->log_ttyin(buf, n)) {
|
||||
rval = false;
|
||||
@@ -225,7 +225,7 @@ log_stdin(const char *buf, unsigned int n)
|
||||
debug_decl(log_stdin, SUDO_DEBUG_EXEC);
|
||||
|
||||
sigprocmask(SIG_BLOCK, &ttyblock, &omask);
|
||||
tq_foreach_fwd(&io_plugins, plugin) {
|
||||
TAILQ_FOREACH(plugin, &io_plugins, entries) {
|
||||
if (plugin->u.io->log_stdin) {
|
||||
if (!plugin->u.io->log_stdin(buf, n)) {
|
||||
rval = false;
|
||||
@@ -248,7 +248,7 @@ log_ttyout(const char *buf, unsigned int n)
|
||||
debug_decl(log_ttyout, SUDO_DEBUG_EXEC);
|
||||
|
||||
sigprocmask(SIG_BLOCK, &ttyblock, &omask);
|
||||
tq_foreach_fwd(&io_plugins, plugin) {
|
||||
TAILQ_FOREACH(plugin, &io_plugins, entries) {
|
||||
if (plugin->u.io->log_ttyout) {
|
||||
if (!plugin->u.io->log_ttyout(buf, n)) {
|
||||
rval = false;
|
||||
@@ -271,7 +271,7 @@ log_stdout(const char *buf, unsigned int n)
|
||||
debug_decl(log_stdout, SUDO_DEBUG_EXEC);
|
||||
|
||||
sigprocmask(SIG_BLOCK, &ttyblock, &omask);
|
||||
tq_foreach_fwd(&io_plugins, plugin) {
|
||||
TAILQ_FOREACH(plugin, &io_plugins, entries) {
|
||||
if (plugin->u.io->log_stdout) {
|
||||
if (!plugin->u.io->log_stdout(buf, n)) {
|
||||
rval = false;
|
||||
@@ -294,7 +294,7 @@ log_stderr(const char *buf, unsigned int n)
|
||||
debug_decl(log_stderr, SUDO_DEBUG_EXEC);
|
||||
|
||||
sigprocmask(SIG_BLOCK, &ttyblock, &omask);
|
||||
tq_foreach_fwd(&io_plugins, plugin) {
|
||||
TAILQ_FOREACH(plugin, &io_plugins, entries) {
|
||||
if (plugin->u.io->log_stderr) {
|
||||
if (!plugin->u.io->log_stderr(buf, n)) {
|
||||
rval = false;
|
||||
|
@@ -231,7 +231,7 @@ sudo_load_plugin(struct plugin_container *policy_plugin,
|
||||
}
|
||||
} else if (plugin->type == SUDO_IO_PLUGIN) {
|
||||
/* Check for duplicate entries. */
|
||||
tq_foreach_fwd(io_plugins, container) {
|
||||
TAILQ_FOREACH(container, io_plugins, entries) {
|
||||
if (strcmp(container->name, info->symbol_name) == 0) {
|
||||
warningx(_("ignoring duplicate I/O plugin `%s' in %s, line %d"),
|
||||
info->symbol_name, _PATH_SUDO_CONF, info->lineno);
|
||||
@@ -242,13 +242,11 @@ sudo_load_plugin(struct plugin_container *policy_plugin,
|
||||
}
|
||||
if (handle != NULL) {
|
||||
container = ecalloc(1, sizeof(*container));
|
||||
container->prev = container;
|
||||
/* container->next = NULL; */
|
||||
container->handle = handle;
|
||||
container->name = info->symbol_name;
|
||||
container->options = info->options;
|
||||
container->u.generic = plugin;
|
||||
tq_append(io_plugins, container);
|
||||
TAILQ_INSERT_TAIL(io_plugins, container, entries);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,7 +270,7 @@ sudo_load_plugins(struct plugin_container *policy_plugin,
|
||||
|
||||
/* Walk the plugin list from sudo.conf, if any. */
|
||||
plugins = sudo_conf_plugins();
|
||||
tq_foreach_fwd(plugins, info) {
|
||||
TAILQ_FOREACH(info, plugins, entries) {
|
||||
rval = sudo_load_plugin(policy_plugin, io_plugins, info);
|
||||
if (!rval)
|
||||
goto done;
|
||||
@@ -288,21 +286,17 @@ sudo_load_plugins(struct plugin_container *policy_plugin,
|
||||
info->symbol_name = "sudoers_policy";
|
||||
info->path = SUDOERS_PLUGIN;
|
||||
/* info->options = NULL; */
|
||||
info->prev = info;
|
||||
/* info->next = NULL; */
|
||||
rval = sudo_load_plugin(policy_plugin, io_plugins, info);
|
||||
efree(info);
|
||||
if (!rval)
|
||||
goto done;
|
||||
|
||||
/* Default I/O plugin */
|
||||
if (tq_empty(io_plugins)) {
|
||||
if (TAILQ_EMPTY(io_plugins)) {
|
||||
info = ecalloc(1, sizeof(*info));
|
||||
info->symbol_name = "sudoers_io";
|
||||
info->path = SUDOERS_PLUGIN;
|
||||
/* info->options = NULL; */
|
||||
info->prev = info;
|
||||
/* info->next = NULL; */
|
||||
rval = sudo_load_plugin(policy_plugin, io_plugins, info);
|
||||
efree(info);
|
||||
if (!rval)
|
||||
@@ -321,7 +315,7 @@ sudo_load_plugins(struct plugin_container *policy_plugin,
|
||||
if (policy_plugin->u.policy->register_hooks != NULL)
|
||||
policy_plugin->u.policy->register_hooks(SUDO_HOOK_VERSION, register_hook);
|
||||
}
|
||||
tq_foreach_fwd(io_plugins, container) {
|
||||
TAILQ_FOREACH(container, io_plugins, entries) {
|
||||
if (container->u.io->version >= SUDO_API_MKVERSION(1, 2)) {
|
||||
if (container->u.io->register_hooks != NULL)
|
||||
container->u.io->register_hooks(SUDO_HOOK_VERSION, register_hook);
|
||||
|
13
src/sudo.c
13
src/sudo.c
@@ -92,7 +92,7 @@
|
||||
* Local variables
|
||||
*/
|
||||
struct plugin_container policy_plugin;
|
||||
struct plugin_container_list io_plugins;
|
||||
struct plugin_container_list io_plugins = TAILQ_HEAD_INITIALIZER(io_plugins);
|
||||
struct user_details user_details;
|
||||
const char *list_user; /* extern for parse_args.c */
|
||||
static struct command_details command_details;
|
||||
@@ -216,7 +216,7 @@ main(int argc, char *argv[], char *envp[])
|
||||
switch (sudo_mode & MODE_MASK) {
|
||||
case MODE_VERSION:
|
||||
policy_show_version(&policy_plugin, !user_details.uid);
|
||||
tq_foreach_fwd(&io_plugins, plugin) {
|
||||
TAILQ_FOREACH(plugin, &io_plugins, entries) {
|
||||
ok = iolog_open(plugin, settings, user_info, NULL,
|
||||
nargc, nargv, envp);
|
||||
if (ok != -1)
|
||||
@@ -250,8 +250,7 @@ main(int argc, char *argv[], char *envp[])
|
||||
exit(1); /* plugin printed error message */
|
||||
}
|
||||
/* Open I/O plugins once policy plugin succeeds. */
|
||||
for (plugin = io_plugins.first; plugin != NULL; plugin = next) {
|
||||
next = plugin->next;
|
||||
TAILQ_FOREACH_SAFE(plugin, &io_plugins, entries, next) {
|
||||
ok = iolog_open(plugin, settings, user_info,
|
||||
command_info, nargc, nargv, envp);
|
||||
switch (ok) {
|
||||
@@ -1051,7 +1050,7 @@ run_command(struct command_details *details)
|
||||
sudo_debug_printf(SUDO_DEBUG_DEBUG,
|
||||
"calling policy close with errno %d", cstat.val);
|
||||
policy_close(&policy_plugin, 0, cstat.val);
|
||||
tq_foreach_fwd(&io_plugins, plugin) {
|
||||
TAILQ_FOREACH(plugin, &io_plugins, entries) {
|
||||
sudo_debug_printf(SUDO_DEBUG_DEBUG,
|
||||
"calling I/O close with errno %d", cstat.val);
|
||||
iolog_close(plugin, 0, cstat.val);
|
||||
@@ -1063,7 +1062,7 @@ run_command(struct command_details *details)
|
||||
sudo_debug_printf(SUDO_DEBUG_DEBUG,
|
||||
"calling policy close with wait status %d", cstat.val);
|
||||
policy_close(&policy_plugin, cstat.val, 0);
|
||||
tq_foreach_fwd(&io_plugins, plugin) {
|
||||
TAILQ_FOREACH(plugin, &io_plugins, entries) {
|
||||
sudo_debug_printf(SUDO_DEBUG_DEBUG,
|
||||
"calling I/O close with wait status %d", cstat.val);
|
||||
iolog_close(plugin, cstat.val, 0);
|
||||
@@ -1262,7 +1261,7 @@ iolog_unlink(struct plugin_container *plugin)
|
||||
deregister_hook);
|
||||
}
|
||||
/* Remove from io_plugins list and free. */
|
||||
tq_remove(&io_plugins, plugin);
|
||||
TAILQ_REMOVE(&io_plugins, plugin, entries);
|
||||
efree(plugin);
|
||||
|
||||
debug_return;
|
||||
|
@@ -34,7 +34,6 @@
|
||||
#include "alloc.h"
|
||||
#include "fatal.h"
|
||||
#include "fileops.h"
|
||||
#include "list.h"
|
||||
#include "sudo_conf.h"
|
||||
#include "sudo_debug.h"
|
||||
#include "gettext.h"
|
||||
|
@@ -81,8 +81,7 @@ struct io_plugin_1_1 {
|
||||
* Sudo plugin internals.
|
||||
*/
|
||||
struct plugin_container {
|
||||
struct plugin_container *prev; /* required */
|
||||
struct plugin_container *next; /* required */
|
||||
TAILQ_ENTRY(plugin_container) entries;
|
||||
const char *name;
|
||||
char * const *options;
|
||||
void *handle;
|
||||
@@ -95,7 +94,7 @@ struct plugin_container {
|
||||
struct io_plugin_1_1 *io_1_1;
|
||||
} u;
|
||||
};
|
||||
TQ_DECLARE(plugin_container)
|
||||
TAILQ_HEAD(plugin_container_list, plugin_container);
|
||||
|
||||
extern struct plugin_container policy_plugin;
|
||||
extern struct plugin_container_list io_plugins;
|
||||
|
Reference in New Issue
Block a user