提交 20c5ded9 编写于 作者: D Daniel P. Berrange

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: NDaniel P. Berrange <berrange@redhat.com>
上级 d8a8af34
......@@ -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();
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册