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:
@@ -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
|
||||
|
Reference in New Issue
Block a user