Fix -A flag when askpass is specified in sudo.conf or if sudo doesn't need

to read a password.
This commit is contained in:
Todd C. Miller
2010-06-15 15:11:10 -04:00
parent f64bb67c6c
commit 4fb8a83e6f
5 changed files with 7 additions and 13 deletions

View File

@@ -45,9 +45,6 @@
#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.

View File

@@ -363,11 +363,6 @@ parse_args(int argc, char **argv, int *nargc, char ***nargv, char ***settingsp,
sudo_settings[ARG_IMPLIED_SHELL].value = "true";
}
#ifndef _PATH_SUDO_ASKPASS
if (ISSET(tgetpass_flags, TGP_ASKPASS) && !getenv("SUDO_ASKPASS"))
errorx(1, "no askpass program specified, try setting SUDO_ASKPASS");
#endif
if (mode == MODE_HELP)
usage(0);

View File

@@ -138,12 +138,12 @@ main(int argc, char *argv[], char *envp[])
memset(&user_details, 0, sizeof(user_details));
user_info = get_user_info(&user_details);
/* Parse command line arguments. */
sudo_mode = parse_args(argc, argv, &nargc, &nargv, &settings, &env_add);
/* Read sudo.conf and load plugins. */
sudo_load_plugins(_PATH_SUDO_CONF, &policy_plugin, &io_plugins);
/* Parse command line arguments. */
sudo_mode = parse_args(argc, argv, &nargc, &nargv, &settings, &env_add);
/* Open policy plugin. */
ok = policy_plugin.u.policy->open(SUDO_API_VERSION, sudo_conversation,
_sudo_printf, settings, user_info, envp);

View File

@@ -157,6 +157,7 @@ void cleanup(int);
/* tgetpass.c */
char *tgetpass(const char *, int, int);
int tty_present(void);
extern const char *askpass_path;
/* zero_bytes.c */
void zero_bytes(volatile void *, size_t);

View File

@@ -101,8 +101,9 @@ tgetpass(const char *prompt, int timeout, int flags)
/* 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));
if (askpass == NULL || *askpass == '\0')
errorx(1, "no askpass program specified, try setting SUDO_ASKPASS");
return(sudo_askpass(askpass, prompt));
}
restart: