Add env variable for debugging gnutls usage

Allow debugging of GNUTLS interactions by setting

  LIBVIRT_GNUTLS_DEBUG=10 LIBVIRT_DEBUG=1 virsh

* src/remote/remote_driver.c: Use LIBVIRT_GNUTLS_DEBUG to
  enable gnutls debugging
This commit is contained in:
Daniel P. Berrange 2010-05-07 13:42:11 +01:00
parent c5be8bcb8f
commit 36a03bd2ee

View File

@ -1138,16 +1138,29 @@ check_cert_file(const char *type, const char *file)
}
static void remote_debug_gnutls_log(int level, const char* str) {
DEBUG("%d %s", level, str);
}
static int
initialize_gnutls(void)
{
static int initialized = 0;
int err;
char *gnutlsdebug;
if (initialized) return 0;
gnutls_global_init ();
if ((gnutlsdebug = getenv("LIBVIRT_GNUTLS_DEBUG")) != NULL) {
int val;
if (virStrToLong_i(gnutlsdebug, NULL, 10, &val) < 0)
val = 10;
gnutls_global_set_log_level(val);
gnutls_global_set_log_function(remote_debug_gnutls_log);
}
/* X509 stuff */
err = gnutls_certificate_allocate_credentials (&x509_cred);
if (err) {