From 9f2abc10bfcd2cbefd7dd040b7509b2942a7c425 Mon Sep 17 00:00:00 2001 From: pdmef Date: Fri, 7 Oct 2005 16:44:14 +0000 Subject: [PATCH] From: David Champion Rocco Rutte: - use putenv() instead of setenv() (this one from mutt-dev is more elegant than mine) git-svn-id: svn://svn.berlios.de/mutt-ng/trunk@539 e385b8ad-14ed-0310-8656-cc95a2468c6d --- VERSION.svn | 2 +- pgp.c | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/VERSION.svn b/VERSION.svn index b85aab3..d41de60 100644 --- a/VERSION.svn +++ b/VERSION.svn @@ -1 +1 @@ -538 +539 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; -- 2.20.1