diff options
author | Adam Tkac <atkac@redhat.com> | 2011-02-18 10:54:11 +0000 |
---|---|---|
committer | Adam Tkac <atkac@redhat.com> | 2011-02-18 10:54:11 +0000 |
commit | 348269d30bb6bfa7543cc94b61f5146f9ab062b6 (patch) | |
tree | f214134c621c7564940d200c032d8a860a785411 | |
parent | fc97cfe4a795586ea5036ab38bae3227e37959d8 (diff) | |
download | tigervnc-348269d30bb6bfa7543cc94b61f5146f9ab062b6.tar.gz tigervnc-348269d30bb6bfa7543cc94b61f5146f9ab062b6.zip |
[Bugfix] Register GNUTLS debug routines only when we actually need them.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4295 3789f03b-4d11-0410-bbf8-ca57d06f2519
-rw-r--r-- | common/rfb/CSecurityTLS.cxx | 16 | ||||
-rw-r--r-- | common/rfb/LogWriter.h | 1 | ||||
-rw-r--r-- | common/rfb/SSecurityTLS.cxx | 13 |
3 files changed, 13 insertions, 17 deletions
diff --git a/common/rfb/CSecurityTLS.cxx b/common/rfb/CSecurityTLS.cxx index c774c3db..6028792b 100644 --- a/common/rfb/CSecurityTLS.cxx +++ b/common/rfb/CSecurityTLS.cxx @@ -62,23 +62,18 @@ #define WITHOUT_X509_TIMES #endif -#define TLS_DEBUG - using namespace rfb; StringParameter CSecurityTLS::x509ca("x509ca", "X509 CA certificate", "", ConfViewer); StringParameter CSecurityTLS::x509crl("x509crl", "X509 CRL file", "", ConfViewer); static LogWriter vlog("TLS"); - -#ifdef TLS_DEBUG -static LogWriter vlog_raw("Raw TLS"); +static LogWriter vlog_raw("RawTLS"); static void debug_log(int level, const char* str) { vlog_raw.debug(str); } -#endif void CSecurityTLS::initGlobal() { @@ -87,10 +82,11 @@ void CSecurityTLS::initGlobal() if (!globalInitDone) { gnutls_global_init(); -#ifdef TLS_DEBUG - gnutls_global_set_log_level(10); - gnutls_global_set_log_function(debug_log); -#endif + /* 100 means debug log */ + if (vlog_raw.getLevel() >= 100) { + gnutls_global_set_log_level(10); + gnutls_global_set_log_function(debug_log); + } globalInitDone = true; } diff --git a/common/rfb/LogWriter.h b/common/rfb/LogWriter.h index 124c58ec..7f8b68d7 100644 --- a/common/rfb/LogWriter.h +++ b/common/rfb/LogWriter.h @@ -51,6 +51,7 @@ namespace rfb { void setLog(Logger *logger); void setLevel(int level); + int getLevel(void) { return m_level; } inline void write(int level, const char* format, ...) { if (m_log && (level <= m_level)) { diff --git a/common/rfb/SSecurityTLS.cxx b/common/rfb/SSecurityTLS.cxx index e6202a88..2ea84e07 100644 --- a/common/rfb/SSecurityTLS.cxx +++ b/common/rfb/SSecurityTLS.cxx @@ -35,7 +35,6 @@ #include <rdr/TLSOutStream.h> #define DH_BITS 1024 /* XXX This should be configurable! */ -#define TLS_DEBUG using namespace rfb; @@ -46,13 +45,12 @@ StringParameter SSecurityTLS::X509_KeyFile ("x509key", "specifies path to the key of the x509 certificate in PEM format", "", ConfServer); static LogWriter vlog("TLS"); +static LogWriter vlog_raw("RawTLS"); -#ifdef TLS_DEBUG static void debug_log(int level, const char* str) { vlog.debug(str); } -#endif void SSecurityTLS::initGlobal() { @@ -62,10 +60,11 @@ void SSecurityTLS::initGlobal() if (gnutls_global_init() != GNUTLS_E_SUCCESS) throw AuthFailureException("gnutls_global_init failed"); -#ifdef TLS_DEBUG - gnutls_global_set_log_level(10); - gnutls_global_set_log_function(debug_log); -#endif + /* 100 means debug log */ + if (vlog_raw.getLevel() >= 100) { + gnutls_global_set_log_level(10); + gnutls_global_set_log_function(debug_log); + } globalInitDone = true; } |