X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=pgp.c;h=74f73a925961259a34f799dbf5f32faf30cf06c3;hb=9f2abc10bfcd2cbefd7dd040b7509b2942a7c425;hp=5580c6936e0e6d8068d2e86bf8c983b7dba6f870;hpb=9a448de49a40f076d27e96a9a8f8a9034c08e6a9;p=apps%2Fmadmutt.git diff --git a/pgp.c b/pgp.c index 5580c69..74f73a9 100644 --- a/pgp.c +++ b/pgp.c @@ -104,18 +104,15 @@ void pgp_forget_passphrase (void) } int pgp_use_gpg_agent (void) { - char *tty; + char *tty, *ttybuf; if (!option (OPTUSEGPGAGENT) || !getenv ("GPG_AGENT_INFO")) return 0; - if ((tty = ttyname(0))) { - char tmp[SHORT_STRING]; - snprintf (tmp, sizeof (tmp), "GPG_TTY=%s", tty); - putenv (tmp); -#if 0 - setenv("GPG_TTY", tty, 0); -#endif + if ((tty = ttyname(0)) && + ((ttybuf = mem_malloc (sizeof("GPG_TTY") + strlen(tty) + 1)))) { + snprintf (ttybuf, sizeof (ttybuf), "GPG_TTY=%s", tty); + putenv (ttybuf); } return 1;