diff options
author | Werner Koch <[email protected]> | 2007-04-20 16:59:37 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2007-04-20 16:59:37 +0000 |
commit | b89d98e3353f6101bc256476c0269f48a92d3f56 (patch) | |
tree | 6da6c9dd9e7b78f97ae6e89e54e6603f314cc644 /agent | |
parent | * certcheck.c (do_encode_md): Add arg PKEY. Add support for DSA2 (diff) | |
download | gnupg-b89d98e3353f6101bc256476c0269f48a92d3f56.tar.gz gnupg-b89d98e3353f6101bc256476c0269f48a92d3f56.zip |
Improved logging for error orginating from libgcrypt.
Diffstat (limited to 'agent')
-rw-r--r-- | agent/ChangeLog | 7 | ||||
-rw-r--r-- | agent/gpg-agent.c | 47 | ||||
-rw-r--r-- | agent/protect-tool.c | 24 |
3 files changed, 11 insertions, 67 deletions
diff --git a/agent/ChangeLog b/agent/ChangeLog index aa48c1ebc..5d1ce5d52 100644 --- a/agent/ChangeLog +++ b/agent/ChangeLog @@ -1,3 +1,10 @@ +2007-04-20 Werner Koch <[email protected]> + + * gpg-agent.c (my_gcry_logger, my_gcry_outofcore_handler): Removed. + (main): Call the setup_libgcrypt_logging helper. + * protect-tool.c (my_gcry_logger): Removed. + (main): Call the setup_libgcrypt_logging helper. + 2007-04-03 Werner Koch <[email protected]> * trustlist.c (read_trustfiles): Take a missing trustlist as an diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c index 5da308797..1d73dfcd6 100644 --- a/agent/gpg-agent.c +++ b/agent/gpg-agent.c @@ -276,48 +276,6 @@ i18n_init (void) -/* Used by gcry for logging */ -static void -my_gcry_logger (void *dummy, int level, const char *fmt, va_list arg_ptr) -{ - /* translate the log levels */ - switch (level) - { - case GCRY_LOG_CONT: level = JNLIB_LOG_CONT; break; - case GCRY_LOG_INFO: level = JNLIB_LOG_INFO; break; - case GCRY_LOG_WARN: level = JNLIB_LOG_WARN; break; - case GCRY_LOG_ERROR:level = JNLIB_LOG_ERROR; break; - case GCRY_LOG_FATAL:level = JNLIB_LOG_FATAL; break; - case GCRY_LOG_BUG: level = JNLIB_LOG_BUG; break; - case GCRY_LOG_DEBUG:level = JNLIB_LOG_DEBUG; break; - default: level = JNLIB_LOG_ERROR; break; - } - log_logv (level, fmt, arg_ptr); -} - - -/* This function is called by libgcrypt if it ran out of core and - there is no way to return that error to the caller. We do our own - function here to make use of our logging functions. */ -static int -my_gcry_outofcore_handler ( void *opaque, size_t req_n, unsigned int flags) -{ - static int been_here; /* Used to protect against recursive calls. */ - - if (!been_here) - { - been_here = 1; - if ( (flags & 1) ) - log_fatal (_("out of core in secure memory " - "while allocating %lu bytes"), (unsigned long)req_n); - else - log_fatal (_("out of core while allocating %lu bytes"), - (unsigned long)req_n); - } - return 0; /* Let libgcrypt call its own fatal error handler. */ -} - - /* Setup the debugging. With the global variable DEBUG_LEVEL set to NULL only the active debug flags are propagated to the subsystems. With DEBUG_LEVEL set, a specific set of debug flags is set; thus overriding @@ -518,7 +476,7 @@ main (int argc, char **argv ) the option parsing may need services of the library. */ if (!gcry_check_version (NEED_LIBGCRYPT_VERSION) ) { - log_fatal( _("libgcrypt is too old (need %s, have %s)\n"), + log_fatal( _("%s is too old (need %s, have %s)\n"), "libgcrypt", NEED_LIBGCRYPT_VERSION, gcry_check_version (NULL) ); } @@ -527,8 +485,7 @@ main (int argc, char **argv ) assuan_set_assuan_log_prefix (log_get_prefix (NULL)); assuan_set_assuan_err_source (GPG_ERR_SOURCE_DEFAULT); - gcry_set_log_handler (my_gcry_logger, NULL); - gcry_set_outofcore_handler (my_gcry_outofcore_handler, NULL); + setup_libgcrypt_logging (); gcry_control (GCRYCTL_USE_SECURE_RNDPOOL); may_coredump = disable_core_dumps (); diff --git a/agent/protect-tool.c b/agent/protect-tool.c index 937b0ef0c..8496601b5 100644 --- a/agent/protect-tool.c +++ b/agent/protect-tool.c @@ -177,25 +177,6 @@ i18n_init (void) -/* Used by gcry for logging */ -static void -my_gcry_logger (void *dummy, int level, const char *fmt, va_list arg_ptr) -{ - /* translate the log levels */ - switch (level) - { - case GCRY_LOG_CONT: level = JNLIB_LOG_CONT; break; - case GCRY_LOG_INFO: level = JNLIB_LOG_INFO; break; - case GCRY_LOG_WARN: level = JNLIB_LOG_WARN; break; - case GCRY_LOG_ERROR:level = JNLIB_LOG_ERROR; break; - case GCRY_LOG_FATAL:level = JNLIB_LOG_FATAL; break; - case GCRY_LOG_BUG: level = JNLIB_LOG_BUG; break; - case GCRY_LOG_DEBUG:level = JNLIB_LOG_DEBUG; break; - default: level = JNLIB_LOG_ERROR; break; } - log_logv (level, fmt, arg_ptr); -} - - /* static void */ /* print_mpi (const char *text, gcry_mpi_t a) */ /* { */ @@ -1075,12 +1056,11 @@ main (int argc, char **argv ) if (!gcry_check_version (NEED_LIBGCRYPT_VERSION) ) { - log_fatal( _("libgcrypt is too old (need %s, have %s)\n"), + log_fatal( _("%s is too old (need %s, have %s)\n"), "libgcrypt", NEED_LIBGCRYPT_VERSION, gcry_check_version (NULL) ); } - gcry_set_log_handler (my_gcry_logger, NULL); - + setup_libgcrypt_logging (); gcry_control (GCRYCTL_INIT_SECMEM, 16384, 0); |