279
/* Used by gcry for logging */
281
my_gcry_logger (void *dummy, int level, const char *fmt, va_list arg_ptr)
283
/* translate the log levels */
286
case GCRY_LOG_CONT: level = JNLIB_LOG_CONT; break;
287
case GCRY_LOG_INFO: level = JNLIB_LOG_INFO; break;
288
case GCRY_LOG_WARN: level = JNLIB_LOG_WARN; break;
289
case GCRY_LOG_ERROR:level = JNLIB_LOG_ERROR; break;
290
case GCRY_LOG_FATAL:level = JNLIB_LOG_FATAL; break;
291
case GCRY_LOG_BUG: level = JNLIB_LOG_BUG; break;
292
case GCRY_LOG_DEBUG:level = JNLIB_LOG_DEBUG; break;
293
default: level = JNLIB_LOG_ERROR; break;
295
log_logv (level, fmt, arg_ptr);
299
/* This function is called by libgcrypt if it ran out of core and
300
there is no way to return that error to the caller. We do our own
301
function here to make use of our logging functions. */
303
my_gcry_outofcore_handler ( void *opaque, size_t req_n, unsigned int flags)
305
static int been_here; /* Used to protect against recursive calls. */
311
log_fatal (_("out of core in secure memory "
312
"while allocating %lu bytes"), (unsigned long)req_n);
314
log_fatal (_("out of core while allocating %lu bytes"),
315
(unsigned long)req_n);
317
return 0; /* Let libgcrypt call its own fatal error handler. */
321
279
/* Setup the debugging. With the global variable DEBUG_LEVEL set to NULL
322
280
only the active debug flags are propagated to the subsystems. With
323
281
DEBUG_LEVEL set, a specific set of debug flags is set; thus overriding
518
476
the option parsing may need services of the library. */
519
477
if (!gcry_check_version (NEED_LIBGCRYPT_VERSION) )
521
log_fatal( _("libgcrypt is too old (need %s, have %s)\n"),
479
log_fatal( _("%s is too old (need %s, have %s)\n"), "libgcrypt",
522
480
NEED_LIBGCRYPT_VERSION, gcry_check_version (NULL) );
527
485
assuan_set_assuan_log_prefix (log_get_prefix (NULL));
528
486
assuan_set_assuan_err_source (GPG_ERR_SOURCE_DEFAULT);
530
gcry_set_log_handler (my_gcry_logger, NULL);
531
gcry_set_outofcore_handler (my_gcry_outofcore_handler, NULL);
488
setup_libgcrypt_logging ();
532
489
gcry_control (GCRYCTL_USE_SECURE_RNDPOOL);
534
491
may_coredump = disable_core_dumps ();