Move askpass path specification from sudoers to sudo.conf.

This commit is contained in:
Todd C. Miller
2010-06-09 17:40:44 -04:00
parent 34613c8465
commit eec336115a
16 changed files with 243 additions and 244 deletions

View File

@@ -79,16 +79,25 @@ tgetpass(const char *prompt, int timeout, int flags)
(void) fflush(stdout);
/* If using a helper program to get the password, run it instead. */
/* XXX - askpass may be set by policy */
if (ISSET(flags, TGP_ASKPASS)) {
if (!askpass) {
askpass = getenv("SUDO_ASKPASS");
if (askpass == NULL) {
askpass = getenv("SUDO_ASKPASS");
#ifdef _PATH_SUDO_ASKPASS
if (!askpass)
askpass = _PATH_SUDO_ASKPASS;
if (askpass == NULL)
askpass = _PATH_SUDO_ASKPASS;
#endif
}
/* If no tty present and we need to disable echo, try askpass. */
if (!ISSET(flags, TGP_STDIN|TGP_ECHO|TGP_ASKPASS) && !tty_present()) {
if (askpass == NULL || getenv("DISPLAY") == NULL) {
warningx("no tty present and no askpass program specified");
return(NULL);
}
SET(flags, TGP_ASKPASS);
}
/* If using a helper program to get the password, run it instead. */
if (ISSET(flags, TGP_ASKPASS)) {
if (askpass && *askpass)
return(sudo_askpass(askpass, prompt));
}