mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 09:17:52 +03:00
rpc: set gnutls log function at global init time
Currently we set the gnutls log function when creating a TLS context, however, the setting is in fact global, not per context. So we should be setting it when we first call gnutls_global_init() instead. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
d8a8af3492
commit
20c5ded9d0
@ -701,7 +701,6 @@ static virNetTLSContextPtr virNetTLSContextNew(const char *cacert,
|
||||
bool isServer)
|
||||
{
|
||||
virNetTLSContextPtr ctxt;
|
||||
const char *gnutlsdebug;
|
||||
int err;
|
||||
|
||||
if (virNetTLSContextInitialize() < 0)
|
||||
@ -710,16 +709,6 @@ static virNetTLSContextPtr virNetTLSContextNew(const char *cacert,
|
||||
if (!(ctxt = virObjectLockableNew(virNetTLSContextClass)))
|
||||
return NULL;
|
||||
|
||||
if ((gnutlsdebug = virGetEnvAllowSUID("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(virNetTLSLog);
|
||||
VIR_DEBUG("Enabled GNUTLS debug");
|
||||
}
|
||||
|
||||
|
||||
err = gnutls_certificate_allocate_credentials(&ctxt->x509cred);
|
||||
if (err) {
|
||||
virReportError(VIR_ERR_SYSTEM_ERROR,
|
||||
@ -1433,5 +1422,15 @@ void virNetTLSSessionDispose(void *obj)
|
||||
*/
|
||||
void virNetTLSInit(void)
|
||||
{
|
||||
const char *gnutlsdebug;
|
||||
if ((gnutlsdebug = virGetEnvAllowSUID("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(virNetTLSLog);
|
||||
VIR_DEBUG("Enabled GNUTLS debug");
|
||||
}
|
||||
|
||||
gnutls_global_init();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user