Use the SUDO_CONV_PREFER_TTY flag during authentication.

This prevents the password and PAM prompts from being redirected.
Bug #895
This commit is contained in:
Todd C. Miller
2019-08-26 19:30:11 -06:00
parent 5a22865131
commit 972670bfca
9 changed files with 51 additions and 29 deletions

View File

@@ -32,22 +32,28 @@
#include "sudo_compat.h"
#include "sudo_plugin.h"
#include "sudo_debug.h"
#include "pathnames.h"
static int
sudo_printf_int(int msg_type, const char *fmt, ...)
{
FILE *fp = stdout;
FILE *ttyfp = NULL;
va_list ap;
int len;
switch (msg_type) {
if (ISSET(msg_type, SUDO_CONV_PREFER_TTY)) {
/* Try writing to /dev/tty first. */
ttyfp = fopen(_PATH_TTY, "w");
}
switch (msg_type & 0xff) {
case SUDO_CONV_ERROR_MSG:
fp = stderr;
/* FALLTHROUGH */
case SUDO_CONV_INFO_MSG:
va_start(ap, fmt);
len = vfprintf(stdout, fmt, ap);
va_end(ap);
break;
case SUDO_CONV_ERROR_MSG:
va_start(ap, fmt);
len = vfprintf(stderr, fmt, ap);
len = vfprintf(ttyfp ? ttyfp : fp, fmt, ap);
va_end(ap);
break;
default:
@@ -56,6 +62,9 @@ sudo_printf_int(int msg_type, const char *fmt, ...)
break;
}
if (ttyfp != NULL)
fclose(ttyfp);
return len;
}