mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
Improved logging for error orginating from libgcrypt.
This commit is contained in:
parent
e3a8e6b727
commit
b89d98e335
16 changed files with 119 additions and 140 deletions
|
@ -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 ();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue