diff --git a/src/tgetpass.c b/src/tgetpass.c index b1edd8ae55..d37e272567 100644 --- a/src/tgetpass.c +++ b/src/tgetpass.c @@ -131,7 +131,10 @@ tgetpass(const char *prompt, int timeout, unsigned int flags, /* If no tty present and we need to disable echo, try askpass. */ ttyfd = open(_PATH_TTY, O_RDWR); if (ttyfd == -1 && !ISSET(flags, TGP_ECHO|TGP_NOECHO_TRY)) { - if (askpass == NULL || getenv_unhooked("DISPLAY") == NULL) { + if (askpass == NULL || + (getenv_unhooked("DISPLAY") == NULL && + getenv_unhooked("WAYLAND_DISPLAY") == NULL && + getenv_unhooked("WAYLAND_SOCKET") == NULL)) { if (getenv_unhooked("SSH_CONNECTION") != NULL && getenv_unhooked("SSH_TTY") == NULL) { sudo_warnx("%s", U_("a terminal is required to read the password; either use ssh's -t option or configure an askpass helper"));