Skip to content

Commit 9125ddf

Browse files
committed
add global parameter "debug.gnutls"
enables GnuTLS indepth debugging closes rsyslog#219
1 parent 15f884e commit 9125ddf

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

runtime/glbl.c

+10
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ static int bOptimizeUniProc = 1; /* enable uniprocessor optimizations */
8484
static int bParseHOSTNAMEandTAG = 1; /* parser modification (based on startup params!) */
8585
static int bPreserveFQDN = 0; /* should FQDNs always be preserved? */
8686
static int iMaxLine = 8096; /* maximum length of a syslog message */
87+
static int iGnuTLSLoglevel = 0;
8788
static int iDefPFFamily = PF_UNSPEC; /* protocol family (IPv4, IPv6 or both) */
8889
static int bDropMalPTRMsgs = 0;/* Drop messages which have malicious PTR records during DNS lookup */
8990
static int option_DisallowWarning = 1; /* complain if message from disallowed sender is received */
@@ -131,6 +132,7 @@ static struct cnfparamdescr cnfparamdescr[] = {
131132
{ "preservefqdn", eCmdHdlrBinary, 0 },
132133
{ "debug.onshutdown", eCmdHdlrBinary, 0 },
133134
{ "debug.logfile", eCmdHdlrString, 0 },
135+
{ "debug.gnutls", eCmdHdlrPositiveInt, 0 },
134136
{ "defaultnetstreamdrivercafile", eCmdHdlrString, 0 },
135137
{ "defaultnetstreamdriverkeyfile", eCmdHdlrString, 0 },
136138
{ "defaultnetstreamdrivercertfile", eCmdHdlrString, 0 },
@@ -183,6 +185,12 @@ GetMaxLine(void)
183185
return(iMaxLine);
184186
}
185187

188+
int
189+
GetGnuTLSLoglevel(void)
190+
{
191+
return(iGnuTLSLoglevel);
192+
}
193+
186194
/* define a macro for the simple properties' set and get functions
187195
* (which are always the same). This is only suitable for pretty
188196
* simple cases which require neither checks nor memory allocation.
@@ -1040,6 +1048,8 @@ glblDoneLoadCnf(void)
10401048
} else if(!strcmp(paramblk.descr[i].name, "debug.onshutdown")) {
10411049
glblDebugOnShutdown = (int) cnfparamvals[i].val.d.n;
10421050
errmsg.LogError(0, RS_RET_OK, "debug: onShutdown set to %d", glblDebugOnShutdown);
1051+
} else if(!strcmp(paramblk.descr[i].name, "debug.gnutls")) {
1052+
iGnuTLSLoglevel = (int) cnfparamvals[i].val.d.n;
10431053
} else if(!strcmp(paramblk.descr[i].name, "parser.controlcharacterescapeprefix")) {
10441054
cCCEscapeChar = (uchar) *es_str2cstr(cnfparamvals[i].val.d.estr, NULL);
10451055
} else if(!strcmp(paramblk.descr[i].name, "parser.droptrailinglfonreception")) {

runtime/glbl.h

+1
Original file line numberDiff line numberDiff line change
@@ -122,5 +122,6 @@ void glblDestructMainqCnfObj();
122122
void glblDoneLoadCnf(void);
123123
const uchar * glblGetWorkDirRaw(void);
124124
tzinfo_t* glblFindTimezoneInfo(char *id);
125+
int GetGnuTLSLoglevel(void);
125126

126127
#endif /* #ifndef GLBL_H_INCLUDED */

runtime/nsd_gtls.c

+7-12
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
*
33
* An implementation of the nsd interface for GnuTLS.
44
*
5-
* Copyright (C) 2007-2014 Rainer Gerhards and Adiscon GmbH.
5+
* Copyright (C) 2007-2015 Rainer Gerhards and Adiscon GmbH.
66
*
77
* This file is part of the rsyslog runtime library.
88
*
@@ -87,8 +87,6 @@ static pthread_mutex_t mutGtlsStrerror; /**< a mutex protecting the potentially
8787
/* ------------------------------ GnuTLS specifics ------------------------------ */
8888
static gnutls_certificate_credentials_t xcred;
8989

90-
#ifdef DEBUG
91-
#if 0 /* uncomment, if needed some time again -- DEV Debug only */
9290
/* This defines a log function to be provided to GnuTLS. It hopefully
9391
* helps us track down hard to find problems.
9492
* rgerhards, 2008-06-20
@@ -97,8 +95,7 @@ static void logFunction(int level, const char *msg)
9795
{
9896
dbgprintf("GnuTLS log msg, level %d: %s\n", level, msg);
9997
}
100-
#endif
101-
#endif /* #ifdef DEBUG */
98+
10299

103100

104101
/* read in the whole content of a file. The caller is responsible for
@@ -605,13 +602,11 @@ gtlsGlblInit(void)
605602
ABORT_FINALIZE(RS_RET_GNUTLS_ERR);
606603
}
607604

608-
# ifdef DEBUG
609-
#if 0 /* do this in special cases only. WARNING: if active, it may reveal sensitive information! */
610-
/* intialize log function - set a level only for hard-to-find bugs */
611-
gnutls_global_set_log_function(logFunction);
612-
gnutls_global_set_log_level(10); /* 0 (no) to 9 (most), 10 everything */
613-
# endif
614-
# endif
605+
if(GetGnuTLSLoglevel() > 0){
606+
gnutls_global_set_log_function(logFunction);
607+
gnutls_global_set_log_level(GetGnuTLSLoglevel());
608+
/* 0 (no) to 9 (most), 10 everything */
609+
}
615610

616611
finalize_it:
617612
RETiRet;

0 commit comments

Comments
 (0)