Store askpass path in a global instead of uses setenv() which many

systems lack.
This commit is contained in:
Todd C. Miller
2010-06-10 12:03:40 -04:00
parent eec336115a
commit b91b65722b
2 changed files with 13 additions and 7 deletions

View File

@@ -45,6 +45,9 @@
#include "sudo_plugin.h" #include "sudo_plugin.h"
#include "sudo_plugin_int.h" #include "sudo_plugin_int.h"
/* tgetpass.c */
extern const char *askpass_path;
/* /*
* Read in /etc/sudo.conf * Read in /etc/sudo.conf
* Returns a list of plugins. * Returns a list of plugins.
@@ -91,8 +94,7 @@ sudo_read_conf(const char *conf_file)
} }
if (strcasecmp(name, "askpass") != 0) if (strcasecmp(name, "askpass") != 0)
continue; continue;
/* XXX - Just set in environment for now */ askpass_path = estrdup(path);
setenv("SUDO_ASKPASS", path, 0);
continue; continue;
} }

View File

@@ -64,6 +64,12 @@ static char *sudo_askpass(const char *, const char *);
extern struct user_details user_details; /* XXX */ extern struct user_details user_details; /* XXX */
#ifdef _PATH_SUDO_ASKPASS
const char *askpass_path = _PATH_SUDO_ASKPASS;
#else
const char *askpass_path;
#endif
/* /*
* Like getpass(3) but with timeout and echo flags. * Like getpass(3) but with timeout and echo flags.
*/ */
@@ -73,7 +79,7 @@ tgetpass(const char *prompt, int timeout, int flags)
sigaction_t sa, savealrm, saveint, savehup, savequit, saveterm; sigaction_t sa, savealrm, saveint, savehup, savequit, saveterm;
sigaction_t savetstp, savettin, savettou, savepipe; sigaction_t savetstp, savettin, savettou, savepipe;
char *pass; char *pass;
static char *askpass; static const char *askpass;
static char buf[SUDO_PASS_MAX + 1]; static char buf[SUDO_PASS_MAX + 1];
int i, input, output, save_errno, neednl = 0, need_restart; int i, input, output, save_errno, neednl = 0, need_restart;
@@ -81,10 +87,8 @@ tgetpass(const char *prompt, int timeout, int flags)
if (askpass == NULL) { if (askpass == NULL) {
askpass = getenv("SUDO_ASKPASS"); askpass = getenv("SUDO_ASKPASS");
#ifdef _PATH_SUDO_ASKPASS if (askpass == NULL || *askpass == '\0')
if (askpass == NULL) askpass = askpass_path;
askpass = _PATH_SUDO_ASKPASS;
#endif
} }
/* If no tty present and we need to disable echo, try askpass. */ /* If no tty present and we need to disable echo, try askpass. */