From 477360e8cdc458b0a36e9c7fb52a35f27766255d Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Mon, 5 Dec 2011 10:54:59 +0100 Subject: Amend the agent code with more comments. * agent/command.c (server_local_s): Remove unused field MESSAGE_FD. --- agent/gpg-agent.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'agent/gpg-agent.c') diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c index 061687550..6dcde26af 100644 --- a/agent/gpg-agent.c +++ b/agent/gpg-agent.c @@ -309,6 +309,9 @@ static unsigned long pth_thread_id (void) Functions. */ +/* Allocate a string describing a library version by calling a GETFNC. + This function is expected to be called only once. GETFNC is + expected to have a semantic like gcry_check_version (). */ static char * make_libversion (const char *libname, const char *(*getfnc)(const char*)) { @@ -326,7 +329,9 @@ make_libversion (const char *libname, const char *(*getfnc)(const char*)) return result; } - +/* Return strings describing this program. The case values are + described in common/argparse.c:strusage. The values here override + the default values given by strusage. */ static const char * my_strusage (int level) { @@ -448,6 +453,9 @@ remove_socket (char *name) } } + +/* Cleanup code for this program. This is either called has an atexit + handler or directly. */ static void cleanup (void) { @@ -1268,6 +1276,8 @@ main (int argc, char **argv ) } +/* Exit entry point. This function should be called instead of a + plain exit. */ void agent_exit (int rc) { @@ -1294,6 +1304,11 @@ agent_exit (int rc) } +/* Each thread has its own local variables conveyed by a control + structure usually identified by an argument named CTRL. This + function is called immediately after allocating the control + structure. Its purpose is to setup the default values for that + structure. */ static void agent_init_default_ctrl (ctrl_t ctrl) { @@ -1319,6 +1334,8 @@ agent_init_default_ctrl (ctrl_t ctrl) } +/* Release all resources allocated by default in the control + structure. This is the counterpart to agent_init_default_ctrl. */ static void agent_deinit_default_ctrl (ctrl_t ctrl) { @@ -1720,6 +1737,7 @@ agent_sighup_action (void) } +/* A helper function to handle SIGUSR2. */ static void agent_sigusr2_action (void) { @@ -1730,6 +1748,8 @@ agent_sigusr2_action (void) } +/* The signal handler for this program. It is expected to be run in + its own trhead and not in the context of a signal handler. */ static void handle_signal (int signo) { -- cgit v1.2.3 From a2d9e48fcca6cfc2dfadef6dbd3579a30314676b Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Mon, 2 Jan 2012 22:15:00 +0100 Subject: Only set gcrypt thread callback for older version of gcrypt. * agent/gpg-agent.c, dirmngr/dirmngr.c, g13/g13.c, scd/scdaemon.c (USE_GCRY_THREAD_CBS): New macro, defined if GCRY_THREAD_OPTION_VERSION is 0. (fixed_gcry_pth_init) [!USE_GCRY_THREAD_CBS]: Don't define. (main) [!USE_GCRY_THREAD_CBS]: Do not install thread callbacks. --- agent/gpg-agent.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'agent/gpg-agent.c') diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c index 6dcde26af..f98d821ae 100644 --- a/agent/gpg-agent.c +++ b/agent/gpg-agent.c @@ -289,11 +289,18 @@ static int check_for_running_agent (int silent, int mode); /* Pth wrapper function definitions. */ ASSUAN_SYSTEM_PTH_IMPL; +#if defined(GCRY_THREAD_OPTION_VERSION) && (GCRY_THREAD_OPTION_VERSION == 0) +#define USE_GCRY_THREAD_CBS 1 +#endif + +#ifdef USE_GCRY_THREAD_CBS GCRY_THREAD_OPTION_PTH_IMPL; + static int fixed_gcry_pth_init (void) { return pth_self ()? 0 : (pth_init () == FALSE) ? errno : 0; } +#endif #ifndef PTH_HAVE_PTH_THREAD_ID @@ -618,6 +625,7 @@ main (int argc, char **argv ) init_common_subsystems (&argc, &argv); +#ifdef USE_GCRY_THREAD_CBS /* Libgcrypt requires us to register the threading model first. Note that this will also do the pth_init. */ gcry_threads_pth.init = fixed_gcry_pth_init; @@ -627,6 +635,7 @@ main (int argc, char **argv ) log_fatal ("can't register GNU Pth with Libgcrypt: %s\n", gpg_strerror (err)); } +#endif /* Check that the libraries are suitable. Do it here because -- cgit v1.2.3 From d01d9ff11f46cbd61b7b8c0e04431e4f0c4a8580 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Tue, 3 Jan 2012 11:13:30 +0100 Subject: Terminate csh commands with a semicolon. Fixes bug#1386. * agent/gpg-agent.c (main): Terminate csh style output with a semicolon. * scd/scdaemon.c: Ditto. --- agent/gpg-agent.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'agent/gpg-agent.c') diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c index f98d821ae..63f4ba2c8 100644 --- a/agent/gpg-agent.c +++ b/agent/gpg-agent.c @@ -1197,11 +1197,11 @@ main (int argc, char **argv ) if (csh_style) { *strchr (infostr, '=') = ' '; - es_printf ("setenv %s\n", infostr); + es_printf ("setenv %s;\n", infostr); if (opt.ssh_support) { *strchr (infostr_ssh_sock, '=') = ' '; - es_printf ("setenv %s\n", infostr_ssh_sock); + es_printf ("setenv %s;\n", infostr_ssh_sock); } } else -- cgit v1.2.3