[PATCH] Remove the environment file when quitting.
luca at pca.it
Mon Sep 19 20:33:13 CEST 2011
Please see Debian bug #642021 for more information:
Please Cc: me, I am not subscribed to the list.
The discussion started on the Debian BTS (bug #642021) and it has
effects on other part of the Xsession (see bug #642012).
Please note that there are two different bugs in Debian: one upstream
(the one suggested by the title of bug #642021, with implication for
ssh-agent) and another one Debian-specific. The patch included below
deals with the former. If needed, the license is the same as GnuPG-2,
The patch has been tested on my up-to-date Debian sid, both in the
console (gpg-agent killed with `kill -s SIGTERM $PID`) and in X11 via
XDM login, thus with gpg-agent started by Xsession as it is the
default on Debian (gpg-agent killed automatically when quitting X11).
In both cases the environment file is deleted.
The package I used to test it is available at:
Please excuse me if there are fundamental errors, I have very few
experience in programming.
Gismo / Luca
agent/ChangeLog | 8 ++++++++
agent/gpg-agent.c | 10 +++++++++-
2 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/agent/ChangeLog b/agent/ChangeLog
index 3c52e1f..9c16e2e 100644
@@ -1,3 +1,11 @@
+2011-09-19 Luca Capello <luca at pca.it>
+ * gpg-agent.c: New global *env_file_name variable.
+ (cleanup): Delete the above file.
+ (main): Remove local *env_file_name variable.
+ (main): Do not let cleanup() remove the above file.
+ (check_own_socket_thread): Ditto.
2011-09-12 Ben Kibbey <bjk at luxsci.net>
* genkey.c (agent_ask_new_passphrase): Allow for an empty passphrase
diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c
index 0616875..81d9cd4 100644
@@ -239,6 +239,9 @@ static char *socket_name;
/* Name of the communication socket used for ssh-agent-emulation. */
static char *socket_name_ssh;
+/* The file containing the environment variables. */
+static char *env_file_name = NULL;
/* We need to keep track of the server's nonces (these are dummies for
POSIX systems). */
static assuan_sock_nonce_t socket_nonce;
@@ -459,6 +462,7 @@ cleanup (void)
+ remove (env_file_name);
@@ -585,7 +589,6 @@ main (int argc, char **argv )
int debug_wait = 0;
int gpgconf_list = 0;
- const char *env_file_name = NULL;
struct assuan_malloc_hooks malloc_hooks;
/* Before we do anything else we save the list of currently open
@@ -1140,6 +1143,8 @@ main (int argc, char **argv )
es_putc ('\n', fp);
+ *env_file_name = 0; /* Don't let cleanup() remove the file */
@@ -2188,6 +2193,9 @@ check_own_socket_thread (void *arg)
*socket_name = 0;
*socket_name_ssh = 0;
+ /* Ditto for the file containing the environment variables. */
+ if (env_file_name)
+ *env_file_name = 0;
shutdown_pending = 2;
log_info ("this process is useless - shutting down\n");
More information about the Gnupg-devel