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