From c2c6616a0c7cf22a72bc18d2397290af24d9627b Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Sun, 25 Nov 2012 09:34:33 -0500 Subject: [PATCH] Move _sudo_printf from src/conversation.c to common/sudo_printf.c. Add sudo_printf function pointer that is initialized to _sudo_printf() instead of requiring a sudo_conv function pointer everywhere. The plugin will reset sudo_printf to point to the version passed in via the plugin open function. Now plugin_error.c can just call sudo_printf in all cases. The sudoers binaries no longer need their own version of sudo_printf. --- MANIFEST | 1 + common/Makefile.in | 7 +- common/sudo_debug.c | 45 ++++------- common/sudo_printf.c | 75 +++++++++++++++++++ include/error.h | 3 + plugins/sudoers/Makefile.in | 5 +- plugins/sudoers/gram.c | 19 +---- plugins/sudoers/gram.y | 19 +---- plugins/sudoers/iolog.c | 6 +- plugins/sudoers/plugin_error.c | 52 ++++--------- plugins/sudoers/policy.c | 6 +- .../regress/check_symbols/check_symbols.c | 2 +- .../regress/iolog_path/check_iolog_path.c | 3 +- plugins/sudoers/regress/logging/check_wrap.c | 4 +- plugins/sudoers/regress/parser/check_addr.c | 4 +- plugins/sudoers/regress/parser/check_fill.c | 5 +- plugins/sudoers/sudoers.c | 1 - plugins/sudoers/sudoreplay.c | 2 - plugins/sudoers/testsudoers.c | 29 ------- plugins/sudoers/visudo.c | 29 ------- src/Makefile.in | 2 +- src/conversation.c | 30 -------- src/sesh.c | 2 - 23 files changed, 129 insertions(+), 222 deletions(-) create mode 100644 common/sudo_printf.c diff --git a/MANIFEST b/MANIFEST index e49197936..534b1bfc0 100644 --- a/MANIFEST +++ b/MANIFEST @@ -19,6 +19,7 @@ common/secure_path.c common/setgroups.c common/sudo_conf.c common/sudo_debug.c +common/sudo_printf.c common/term.c common/ttysize.c common/zero_bytes.c diff --git a/common/Makefile.in b/common/Makefile.in index 30360908e..099768bdd 100644 --- a/common/Makefile.in +++ b/common/Makefile.in @@ -58,8 +58,8 @@ DEFS = @OSDEFS@ -D_PATH_SUDO_CONF=\"$(sysconfdir)/sudo.conf\" SHELL = @SHELL@ LTOBJS = alloc.lo atobool.lo fileops.lo fmt_string.lo lbuf.lo list.lo \ - secure_path.lo setgroups.lo sudo_conf.lo sudo_debug.lo term.lo \ - ttysize.lo zero_bytes.lo @COMMON_OBJS@ + secure_path.lo setgroups.lo sudo_conf.lo sudo_debug.lo sudo_printf.lo \ + term.lo ttysize.lo zero_bytes.lo @COMMON_OBJS@ all: libcommon.la @@ -151,6 +151,9 @@ sudo_debug.lo: $(srcdir)/sudo_debug.c $(top_builddir)/config.h \ $(incdir)/alloc.h $(incdir)/error.h $(incdir)/gettext.h \ $(incdir)/sudo_plugin.h $(incdir)/sudo_debug.h $(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/sudo_debug.c +sudo_printf.lo: $(srcdir)/sudo_printf.c $(top_builddir)/config.h \ + $(incdir)/sudo_plugin.h + $(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/sudo_printf.c term.lo: $(srcdir)/term.c $(top_builddir)/config.h $(incdir)/missing.h \ $(incdir)/sudo_debug.h $(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/term.c diff --git a/common/sudo_debug.c b/common/sudo_debug.c index 55c0578fc..823019058 100644 --- a/common/sudo_debug.c +++ b/common/sudo_debug.c @@ -120,8 +120,6 @@ static int sudo_debug_mode; static char sudo_debug_pidstr[(((sizeof(int) * 8) + 2) / 3) + 3]; static size_t sudo_debug_pidlen; -extern sudo_conv_t sudo_conv; - /* * Parse settings string from sudo.conf and open debugfile. * Returns 1 on success, 0 if cannot open debugfile. @@ -285,36 +283,21 @@ static void sudo_debug_write_conv(const char *func, const char *file, int lineno, const char *str, int len, int errno_val) { - struct sudo_conv_message msg; - struct sudo_conv_reply repl; - char *buf = NULL; - - /* Call conversation function */ - if (sudo_conv != NULL) { - /* Remove the newline at the end if appending extra info. */ - if (str[len - 1] == '\n') - len--; - - if (func != NULL && file != NULL && lineno != 0) { - if (errno_val) { - easprintf(&buf, "%.*s: %s @ %s() %s:%d", len, str, - strerror(errno_val), func, file, lineno); - } else { - easprintf(&buf, "%.*s @ %s() %s:%d", len, str, - func, file, lineno); - } - str = buf; - } else if (errno_val) { - easprintf(&buf, "%.*s: %s", len, str, strerror(errno_val)); - str = buf; + /* Remove the newline at the end if appending extra info. */ + if (str[len - 1] == '\n') + len--; + + if (func != NULL && file != NULL && lineno != 0) { + if (errno_val) { + sudo_printf(SUDO_CONV_DEBUG_MSG, "%.*s: %s @ %s() %s:%d", + len, str, strerror(errno_val), func, file, lineno); + } else { + sudo_printf(SUDO_CONV_DEBUG_MSG, "%.*s @ %s() %s:%d", + len, str, func, file, lineno); } - memset(&msg, 0, sizeof(msg)); - memset(&repl, 0, sizeof(repl)); - msg.msg_type = SUDO_CONV_DEBUG_MSG; - msg.msg = str; - sudo_conv(1, &msg, &repl); - if (buf != NULL) - efree(buf); + } else if (errno_val) { + sudo_printf(SUDO_CONV_DEBUG_MSG, "%.*s: %s", + len, str, strerror(errno_val)); } } diff --git a/common/sudo_printf.c b/common/sudo_printf.c new file mode 100644 index 000000000..e794eb793 --- /dev/null +++ b/common/sudo_printf.c @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2010-2012 Todd C. Miller + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include + +#include +#include +#ifdef STDC_HEADERS +# include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif +#endif /* STDC_HEADERS */ +#include +#include + +#include "sudo_plugin.h" +#include "sudo_debug.h" + +int +_sudo_printf(int msg_type, const char *fmt, ...) +{ + va_list ap; + FILE *fp; + int len; + + switch (msg_type) { + case SUDO_CONV_INFO_MSG: + fp = stdout; + break; + case SUDO_CONV_ERROR_MSG: + fp = stderr; + break; + case SUDO_CONV_DEBUG_MSG: + { + char *buf; + va_list ap; + + /* XXX - add debug version of vfprintf()? */ + va_start(ap, fmt); + len = vasprintf(&buf, fmt, ap); + va_end(ap); + if (len == -1) + return -1; + sudo_debug_write(buf, len, 0); + break; + } + default: + errno = EINVAL; + return -1; + } + + va_start(ap, fmt); + len = vfprintf(fp, fmt, ap); + va_end(ap); + + return len; +} + +int (*sudo_printf)(int msg_type, const char *fmt, ...) = _sudo_printf; diff --git a/include/error.h b/include/error.h index fe2df4e19..7c293be30 100644 --- a/include/error.h +++ b/include/error.h @@ -18,6 +18,7 @@ #define _SUDO_ERROR_H_ #include +#include /* * We wrap error/errorx and warn/warnx so that the same output can @@ -170,6 +171,8 @@ warning_restore_locale(); \ } while (0) +extern sudo_printf_t sudo_printf; + void error2(int, const char *, ...) __printflike(2, 3) __attribute__((__noreturn__)); void errorx2(int, const char *, ...) __printflike(2, 3) __attribute__((__noreturn__)); void verror2(int, const char *, va_list ap) __attribute__((__noreturn__)); diff --git a/plugins/sudoers/Makefile.in b/plugins/sudoers/Makefile.in index 3157b9e8c..9317d8aee 100644 --- a/plugins/sudoers/Makefile.in +++ b/plugins/sudoers/Makefile.in @@ -615,6 +615,7 @@ locale.lo: $(srcdir)/locale.c $(top_builddir)/config.h $(srcdir)/sudoers.h \ $(devdir)/def_data.h $(srcdir)/logging.h $(srcdir)/sudo_nss.h \ $(incdir)/sudo_plugin.h $(incdir)/sudo_debug.h $(incdir)/gettext.h $(LIBTOOL) --mode=compile $(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/locale.c +locale.o: locale.lo logging.lo: $(srcdir)/logging.c $(top_builddir)/config.h $(srcdir)/sudoers.h \ $(top_srcdir)/compat/stdbool.h $(top_builddir)/pathnames.h \ $(incdir)/missing.h $(incdir)/error.h $(incdir)/alloc.h \ @@ -800,8 +801,8 @@ sudoreplay.o: $(srcdir)/sudoreplay.c $(top_builddir)/config.h \ $(top_srcdir)/compat/timespec.h $(top_srcdir)/compat/stdbool.h \ $(top_builddir)/pathnames.h $(incdir)/missing.h \ $(incdir)/alloc.h $(incdir)/error.h $(incdir)/gettext.h \ - $(incdir)/sudo_plugin.h $(incdir)/sudo_conf.h $(incdir)/list.h \ - $(incdir)/sudo_debug.h + $(srcdir)/logging.h $(incdir)/sudo_plugin.h \ + $(incdir)/sudo_conf.h $(incdir)/list.h $(incdir)/sudo_debug.h $(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/sudoreplay.c testsudoers.o: $(srcdir)/testsudoers.c $(top_builddir)/config.h \ $(top_srcdir)/compat/fnmatch.h $(srcdir)/tsgetgrpw.h \ diff --git a/plugins/sudoers/gram.c b/plugins/sudoers/gram.c index 70b2e002a..b1149578c 100644 --- a/plugins/sudoers/gram.c +++ b/plugins/sudoers/gram.c @@ -148,27 +148,12 @@ sudoerserror(const char *s) LEXTRACE("<*> "); #ifndef TRACELEXER if (trace_print == NULL || trace_print == sudoers_trace_print) { - int oldlocale; const char fmt[] = ">>> %s: %s near line %d <<<\n"; + int oldlocale; /* Warnings are displayed in the user's locale. */ sudoers_setlocale(SUDOERS_LOCALE_USER, &oldlocale); - if (sudo_conv != NULL) { - struct sudo_conv_message msg; - struct sudo_conv_reply repl; - char *str; - - easprintf(&str, _(fmt), sudoers, _(s), sudolineno); - - memset(&msg, 0, sizeof(repl)); - memset(&repl, 0, sizeof(repl)); - msg.msg_type = SUDO_CONV_ERROR_MSG; - msg.msg = str; - sudo_conv(1, &msg, &repl); - efree(str); - } else { - fprintf(stderr, _(fmt), sudoers, _(s), sudolineno); - } + sudo_printf(SUDO_CONV_ERROR_MSG, _(fmt), sudoers, _(s), sudolineno); sudoers_setlocale(oldlocale, NULL); } #endif diff --git a/plugins/sudoers/gram.y b/plugins/sudoers/gram.y index 8140c4e97..47e1fc17d 100644 --- a/plugins/sudoers/gram.y +++ b/plugins/sudoers/gram.y @@ -110,27 +110,12 @@ sudoerserror(const char *s) LEXTRACE("<*> "); #ifndef TRACELEXER if (trace_print == NULL || trace_print == sudoers_trace_print) { - int oldlocale; const char fmt[] = ">>> %s: %s near line %d <<<\n"; + int oldlocale; /* Warnings are displayed in the user's locale. */ sudoers_setlocale(SUDOERS_LOCALE_USER, &oldlocale); - if (sudo_conv != NULL) { - struct sudo_conv_message msg; - struct sudo_conv_reply repl; - char *str; - - easprintf(&str, _(fmt), sudoers, _(s), sudolineno); - - memset(&msg, 0, sizeof(repl)); - memset(&repl, 0, sizeof(repl)); - msg.msg_type = SUDO_CONV_ERROR_MSG; - msg.msg = str; - sudo_conv(1, &msg, &repl); - efree(str); - } else { - fprintf(stderr, _(fmt), sudoers, _(s), sudolineno); - } + sudo_printf(SUDO_CONV_ERROR_MSG, _(fmt), sudoers, _(s), sudolineno); sudoers_setlocale(oldlocale, NULL); } #endif diff --git a/plugins/sudoers/iolog.c b/plugins/sudoers/iolog.c index 1317400e3..b687ad105 100644 --- a/plugins/sudoers/iolog.c +++ b/plugins/sudoers/iolog.c @@ -467,10 +467,8 @@ sudoers_io_open(unsigned int version, sudo_conv_t conversation, int rval = -1; debug_decl(sudoers_io_open, SUDO_DEBUG_PLUGIN) - if (!sudo_conv) - sudo_conv = conversation; - if (!sudo_printf) - sudo_printf = plugin_printf; + sudo_conv = conversation; + sudo_printf = plugin_printf; /* If we have no command (because -V was specified) just return. */ if (argc == 0) diff --git a/plugins/sudoers/plugin_error.c b/plugins/sudoers/plugin_error.c index 9bab1fbbc..55723df86 100644 --- a/plugins/sudoers/plugin_error.c +++ b/plugins/sudoers/plugin_error.c @@ -44,8 +44,6 @@ static void _warning(int, const char *, va_list); static sigjmp_buf error_jmp; static bool setjmp_enabled = false; -extern sudo_conv_t sudo_conv; - void error2(int eval, const char *fmt, ...) { @@ -133,47 +131,23 @@ static void _warning(int use_errno, const char *fmt, va_list ap) { int serrno = errno; + char *str; - if (sudo_conv != NULL) { - struct sudo_conv_message msg[6]; - struct sudo_conv_reply repl[6]; - int nmsgs = 4; - char *str; - - evasprintf(&str, _(fmt), ap); - - /* Call conversation function */ - memset(&msg, 0, sizeof(msg)); - msg[0].msg_type = SUDO_CONV_ERROR_MSG; - msg[0].msg = getprogname(); - msg[1].msg_type = SUDO_CONV_ERROR_MSG; - msg[1].msg = _(": "); - msg[2].msg_type = SUDO_CONV_ERROR_MSG; - msg[2].msg = str; - if (use_errno) { - msg[3].msg_type = SUDO_CONV_ERROR_MSG; - msg[3].msg = _(": "); - msg[4].msg_type = SUDO_CONV_ERROR_MSG; - msg[4].msg = strerror(errno); - nmsgs = 6; - } - msg[nmsgs - 1].msg_type = SUDO_CONV_ERROR_MSG; - msg[nmsgs - 1].msg = "\n"; - memset(&repl, 0, sizeof(repl)); - sudo_conv(nmsgs, msg, repl); - efree(str); - } else { - fputs(getprogname(), stderr); + evasprintf(&str, fmt, ap); + if (use_errno) { if (fmt != NULL) { - fputs(_(": "), stderr); - vfprintf(stderr, _(fmt), ap); + sudo_printf(SUDO_CONV_ERROR_MSG, + _("%s: %s: %s\n"), getprogname(), str, strerror(serrno)); + } else { + sudo_printf(SUDO_CONV_ERROR_MSG, + _("%s: %s\n"), getprogname(), strerror(serrno)); } - if (use_errno) { - fputs(_(": "), stderr); - fputs(strerror(serrno), stderr); - } - putc('\n', stderr); + } else { + sudo_printf(SUDO_CONV_ERROR_MSG, + _("%s: %s\n"), getprogname(), str ? str : "(null)"); } + efree(str); + errno = serrno; } static int oldlocale; diff --git a/plugins/sudoers/policy.c b/plugins/sudoers/policy.c index eb942301b..566bf6f7c 100644 --- a/plugins/sudoers/policy.c +++ b/plugins/sudoers/policy.c @@ -458,10 +458,8 @@ sudoers_policy_open(unsigned int version, sudo_conv_t conversation, debug_decl(sudoers_policy_open, SUDO_DEBUG_PLUGIN) sudo_version = version; - if (!sudo_conv) - sudo_conv = conversation; - if (!sudo_printf) - sudo_printf = plugin_printf; + sudo_conv = conversation; + sudo_printf = plugin_printf; /* Plugin args are only specified for API version 1.2 and higher. */ if (sudo_version < SUDO_API_MKVERSION(1, 2)) diff --git a/plugins/sudoers/regress/check_symbols/check_symbols.c b/plugins/sudoers/regress/check_symbols/check_symbols.c index ce9ddd25e..249f66a4c 100644 --- a/plugins/sudoers/regress/check_symbols/check_symbols.c +++ b/plugins/sudoers/regress/check_symbols/check_symbols.c @@ -116,7 +116,7 @@ main(int argc, char *argv[]) } void -cleanup(int gotsig) +sudoers_cleanup(int gotsig) { return; } diff --git a/plugins/sudoers/regress/iolog_path/check_iolog_path.c b/plugins/sudoers/regress/iolog_path/check_iolog_path.c index fb743ef96..420483196 100644 --- a/plugins/sudoers/regress/iolog_path/check_iolog_path.c +++ b/plugins/sudoers/regress/iolog_path/check_iolog_path.c @@ -47,7 +47,6 @@ struct sudo_user sudo_user; struct passwd *list_pw; -sudo_conv_t sudo_conv; /* NULL in non-plugin */ static char sessid[7]; @@ -205,7 +204,7 @@ void io_nextid(char *iolog_dir, char *fallback, char id[7]) } void -cleanup(int gotsig) +sudoers_cleanup(int gotsig) { return; } diff --git a/plugins/sudoers/regress/logging/check_wrap.c b/plugins/sudoers/regress/logging/check_wrap.c index 9be544be8..0ac548635 100644 --- a/plugins/sudoers/regress/logging/check_wrap.c +++ b/plugins/sudoers/regress/logging/check_wrap.c @@ -42,8 +42,6 @@ #include "error.h" #include "sudo_plugin.h" -sudo_conv_t sudo_conv; /* NULL in non-plugin */ - extern void writeln_wrap(FILE *fp, char *line, size_t len, size_t maxlen); __dso_public int main(int argc, char *argv[]); @@ -108,7 +106,7 @@ main(int argc, char *argv[]) } void -cleanup(int gotsig) +sudoers_cleanup(int gotsig) { return; } diff --git a/plugins/sudoers/regress/parser/check_addr.c b/plugins/sudoers/regress/parser/check_addr.c index f71629643..8bb1cd806 100644 --- a/plugins/sudoers/regress/parser/check_addr.c +++ b/plugins/sudoers/regress/parser/check_addr.c @@ -56,8 +56,6 @@ __dso_public int main(int argc, char *argv[]); struct interface *interfaces; sudo_printf_t sudo_printf = check_addr_printf; -sudo_conv_t sudo_conv; /* NULL in non-plugin */ - static int check_addr(char *input) { @@ -156,7 +154,7 @@ main(int argc, char *argv[]) /* STUB */ void -cleanup(int gotsig) +sudoers_cleanup(int gotsig) { return; } diff --git a/plugins/sudoers/regress/parser/check_fill.c b/plugins/sudoers/regress/parser/check_fill.c index d7c8e3b4d..f7c0bcf73 100644 --- a/plugins/sudoers/regress/parser/check_fill.c +++ b/plugins/sudoers/regress/parser/check_fill.c @@ -42,6 +42,7 @@ #define SUDO_ERROR_WRAP 0 +#include "missing.h" #include "list.h" #include "parse.h" #include "toke.h" @@ -54,8 +55,6 @@ __dso_public int main(int argc, char *argv[]); * TODO: test realloc */ -sudo_conv_t sudo_conv; /* NULL in non-plugin */ - YYSTYPE sudoerslval; struct fill_test { @@ -186,7 +185,7 @@ main(int argc, char *argv[]) /* STUB */ void -cleanup(int gotsig) +sudoers_cleanup(int gotsig) { return; } diff --git a/plugins/sudoers/sudoers.c b/plugins/sudoers/sudoers.c index 941256410..8dc2220e5 100644 --- a/plugins/sudoers/sudoers.c +++ b/plugins/sudoers/sudoers.c @@ -108,7 +108,6 @@ extern char *errorfile; char *login_style; #endif /* HAVE_BSD_AUTH_H */ sudo_conv_t sudo_conv; -sudo_printf_t sudo_printf; int sudo_mode; static char *prev_user; diff --git a/plugins/sudoers/sudoreplay.c b/plugins/sudoers/sudoreplay.c index 5d3c5b270..251c196ec 100644 --- a/plugins/sudoers/sudoreplay.c +++ b/plugins/sudoers/sudoreplay.c @@ -179,8 +179,6 @@ struct search_node { } u; } *search_expr; -sudo_conv_t sudo_conv; /* NULL in non-plugin */ - #define STACK_NODE_SIZE 32 static struct search_node *node_stack[32]; static int stack_top; diff --git a/plugins/sudoers/testsudoers.c b/plugins/sudoers/testsudoers.c index ba503925c..5fb11f749 100644 --- a/plugins/sudoers/testsudoers.c +++ b/plugins/sudoers/testsudoers.c @@ -82,7 +82,6 @@ void sudoers_cleanup(int); static void set_runaspw(const char *); static void set_runasgr(const char *); static int cb_runas_default(const char *); -static int testsudoers_printf(int msg_type, const char *fmt, ...); static int testsudoers_print(const char *msg); extern void setgrfile(const char *); @@ -109,8 +108,6 @@ static char *runas_group, *runas_user; extern int errorlineno; extern bool parse_error; extern char *errorfile; -sudo_printf_t sudo_printf = testsudoers_printf; -sudo_conv_t sudo_conv; /* NULL in non-plugin */ /* For getopt(3) */ extern char *optarg; @@ -663,32 +660,6 @@ print_userspecs(void) debug_return; } -static int -testsudoers_printf(int msg_type, const char *fmt, ...) -{ - va_list ap; - FILE *fp; - debug_decl(testsudoers_printf, SUDO_DEBUG_UTIL) - - switch (msg_type) { - case SUDO_CONV_INFO_MSG: - fp = stdout; - break; - case SUDO_CONV_ERROR_MSG: - fp = stderr; - break; - default: - errno = EINVAL; - debug_return_int(-1); - } - - va_start(ap, fmt); - vfprintf(fp, fmt, ap); - va_end(ap); - - debug_return_int(0); -} - void dump_sudoers(void) { diff --git a/plugins/sudoers/visudo.c b/plugins/sudoers/visudo.c index 9a5ccdd7d..adb42c817 100644 --- a/plugins/sudoers/visudo.c +++ b/plugins/sudoers/visudo.c @@ -90,8 +90,6 @@ struct sudoersfile { }; TQ_DECLARE(sudoersfile) -sudo_conv_t sudo_conv; /* NULL in non-plugin */ - /* * Function prototypes */ @@ -107,7 +105,6 @@ static bool install_sudoers(struct sudoersfile *, bool); static int print_unused(void *, void *); static void reparse_sudoers(char *, char *, bool, bool); static int run_command(char *, char **); -static int visudo_printf(int msg_type, const char *fmt, ...); static void setup_signals(void); static void help(void) __attribute__((__noreturn__)); static void usage(int); @@ -134,7 +131,6 @@ extern int optind; */ struct sudo_user sudo_user; struct passwd *list_pw; -sudo_printf_t sudo_printf = visudo_printf; static struct sudoersfile_list sudoerslist; static struct rbtree *alias_freelist; static bool checkonly; @@ -1310,28 +1306,3 @@ help(void) " -V display version information and exit")); exit(0); } - -static int -visudo_printf(int msg_type, const char *fmt, ...) -{ - va_list ap; - FILE *fp; - - switch (msg_type) { - case SUDO_CONV_INFO_MSG: - fp = stdout; - break; - case SUDO_CONV_ERROR_MSG: - fp = stderr; - break; - default: - errno = EINVAL; - return -1; - } - - va_start(ap, fmt); - vfprintf(fp, fmt, ap); - va_end(ap); - - return 0; -} diff --git a/src/Makefile.in b/src/Makefile.in index a52b1cde1..b9ba1d82d 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -175,7 +175,7 @@ env_hooks.o: $(srcdir)/env_hooks.c $(top_builddir)/config.h \ $(incdir)/sudo_plugin.h $(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/env_hooks.c error.o: $(srcdir)/error.c $(top_builddir)/config.h $(incdir)/missing.h \ - $(incdir)/alloc.h $(incdir)/error.h $(incdir)/gettext.h + $(incdir)/error.h $(incdir)/gettext.h $(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/error.c exec.o: $(srcdir)/exec.c $(top_builddir)/config.h $(srcdir)/sudo.h \ $(top_builddir)/pathnames.h $(top_srcdir)/compat/stdbool.h \ diff --git a/src/conversation.c b/src/conversation.c index 737335eb8..aea675d10 100644 --- a/src/conversation.c +++ b/src/conversation.c @@ -51,10 +51,6 @@ extern int tgetpass_flags; /* XXX */ -#if defined(HAVE_DLOPEN) || defined(HAVE_SHL_LOAD) -sudo_conv_t sudo_conv; /* NULL in sudo front-end */ -#endif - /* * Sudo conversation function. */ @@ -120,29 +116,3 @@ err: return -1; } - -int -_sudo_printf(int msg_type, const char *fmt, ...) -{ - va_list ap; - FILE *fp; - int len; - - switch (msg_type) { - case SUDO_CONV_INFO_MSG: - fp = stdout; - break; - case SUDO_CONV_ERROR_MSG: - fp = stderr; - break; - default: - errno = EINVAL; - return -1; - } - - va_start(ap, fmt); - len = vfprintf(fp, fmt, ap); - va_end(ap); - - return len; -} diff --git a/src/sesh.c b/src/sesh.c index f4a6ac326..76c69d68a 100644 --- a/src/sesh.c +++ b/src/sesh.c @@ -40,8 +40,6 @@ #include "sudo_exec.h" #include "sudo_plugin.h" -sudo_conv_t sudo_conv; /* NULL in non-plugin */ - __dso_public int main(int argc, char *argv[], char *envp[]); /* -- 2.40.0