]> granicus.if.org Git - sudo/commitdiff
Store askpass path in a global instead of uses setenv() which many
authorTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 10 Jun 2010 16:03:40 +0000 (12:03 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 10 Jun 2010 16:03:40 +0000 (12:03 -0400)
systems lack.

src/load_plugins.c
src/tgetpass.c

index 685535dc128e6cd2ff72dcc637d368ed06b556c7..971ef92b6938abf3f5997a9bb8bda66ff5943808 100644 (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;
        }
 
index 6b2f054e17533ac909facd547219b2ec0f1d94a0..81caa29ebfd8fc7ffe90588da0429198d1603f93 100644 (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. */