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_int.h"
/* tgetpass.c */
extern const char *askpass_path;
/*
* Read in /etc/sudo.conf
* Returns a list of plugins.
@@ -91,8 +94,7 @@ sudo_read_conf(const char *conf_file)
}
if (strcasecmp(name, "askpass") != 0)
continue;
/* XXX - Just set in environment for now */
setenv("SUDO_ASKPASS", path, 0);
askpass_path = estrdup(path);
continue;
}

View File

@@ -64,6 +64,12 @@ static char *sudo_askpass(const char *, const char *);
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.
*/
@@ -73,7 +79,7 @@ tgetpass(const char *prompt, int timeout, int flags)
sigaction_t sa, savealrm, saveint, savehup, savequit, saveterm;
sigaction_t savetstp, savettin, savettou, savepipe;
char *pass;
static char *askpass;
static const char *askpass;
static char buf[SUDO_PASS_MAX + 1];
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) {
askpass = getenv("SUDO_ASKPASS");
#ifdef _PATH_SUDO_ASKPASS
if (askpass == NULL)
askpass = _PATH_SUDO_ASKPASS;
#endif
if (askpass == NULL || *askpass == '\0')
askpass = askpass_path;
}
/* If no tty present and we need to disable echo, try askpass. */