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.
This commit is contained in:
Todd C. Miller
2012-11-25 09:34:33 -05:00
parent 5496ffe1e8
commit c2c6616a0c
23 changed files with 128 additions and 221 deletions

View File

@@ -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)
{