pidgin: 90a32e7a: Allow GnuTLS logging to be controlled vi...

darkrain42 at pidgin.im darkrain42 at pidgin.im
Fri Jun 26 01:15:29 EDT 2009


-----------------------------------------------------------------
Revision: 90a32e7a2b99266fff355605733b9d184eb6ccd8
Ancestor: ad0be02568add9e6c504793e433a8c44b8b4213f
Author: darkrain42 at pidgin.im
Date: 2009-06-26T05:11:01
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/90a32e7a2b99266fff355605733b9d184eb6ccd8

Modified files:
        ChangeLog libpurple/plugins/ssl/ssl-gnutls.c

ChangeLog: 

Allow GnuTLS logging to be controlled via PURPLE_GNUTLS_DEBUG envvar.

Refs #9338.

-------------- next part --------------
============================================================
--- ChangeLog	22b2098e56fec297a9652d7e60e9e2c80a06faef
+++ ChangeLog	13eccd5dcfae7436f01ebc76591176ebd0622e01
@@ -18,6 +18,10 @@ version 2.6.0 (??/??/2009):
 	  from you on MSN.
 	* DNS servers are re-read when DNS queries fail in case the system has
 	  moved to a new network and the old servers are not accessible.
+	* GnuTLS logging (disabled by default) can be controlled through the
+	  PURPLE_GNUTLS_DEBUG environment variable, which is an integer between
+	  0 and 9 (higher is more verbose). Higher values may reveal sensitive
+	  information.
 
 	Gadu-Gadu:
 	* Accounts can specify a server to which to connect.
============================================================
--- libpurple/plugins/ssl/ssl-gnutls.c	1aa379ab4ff16ed51dfd089267aba2a2e02e6e8c
+++ libpurple/plugins/ssl/ssl-gnutls.c	90bd5f2b85d722c537f6e0366325527c0116f861
@@ -43,8 +43,17 @@ static void
 static gnutls_certificate_client_credentials xcred;
 
 static void
+ssl_gnutls_log(int level, const char *str)
+{
+	/* GnuTLS log messages include the '\n' */
+	purple_debug_misc("gnutls", "lvl %d: %s", level, str);
+}
+
+static void
 ssl_gnutls_init_gnutls(void)
 {
+	const char *debug_level;
+
 	/* Configure GnuTLS to use glib memory management */
 	/* I expect that this isn't really necessary, but it may prevent
 	   some bugs */
@@ -59,6 +68,20 @@ ssl_gnutls_init_gnutls(void)
 		(gnutls_free_function)    g_free     /* free */
 		);
 
+	debug_level = g_getenv("PURPLE_GNUTLS_DEBUG");
+	if (debug_level) {
+		int level = atoi(debug_level);
+		if (level < 0) {
+			purple_debug_warning("gnutls", "Assuming log level 0 instead of %d\n",
+			                     level);
+			level = 0;
+		}
+
+		/* "The level is an integer between 0 and 9. Higher values mean more verbosity." */
+		gnutls_global_set_log_level(level);
+		gnutls_global_set_log_function(ssl_gnutls_log);
+	}
+
 	gnutls_global_init();
 
 	gnutls_certificate_allocate_credentials(&xcred);


More information about the Commits mailing list