Commit c23c6563 authored by Howard Chu's avatar Howard Chu Committed by Quanah Gibson-Mount
Browse files

ITS#6949 honor specified loglevel, not just debuglevel

But skip calls to syslog() if logfile_only is set.
parent 555a8cc4
......@@ -202,6 +202,7 @@ enum {
CFG_TLS_CERT,
CFG_TLS_KEY,
CFG_LOGFILE_ROTATE,
CFG_LOGFILE_ONLY,
CFG_LAST
};
......@@ -485,8 +486,8 @@ static ConfigTable config_back_cf_table[] = {
&config_generic, "( OLcfgGlAt:27 NAME 'olcLogFile' "
"EQUALITY caseExactMatch "
"SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
{ "logfile-only", "on|off", 2, 2, 0, ARG_ON_OFF,
&logfile_only, "( OLcfgGlAt:102 NAME 'olcLogFileOnly' "
{ "logfile-only", "on|off", 2, 2, 0, ARG_ON_OFF|ARG_MAGIC|CFG_LOGFILE_ONLY,
&config_generic, "( OLcfgGlAt:102 NAME 'olcLogFileOnly' "
"EQUALITY booleanMatch "
"SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
{ "logfile-rotate", "max> <Mbyte> <hours", 4, 4, 0, ARG_MAGIC|CFG_LOGFILE_ROTATE,
......@@ -1088,6 +1089,8 @@ static ADlist *sortVals;
static int new_daemon_threads;
static int config_syslog;
static int
config_resize_lthreads(ConfigArgs *c)
{
......@@ -1388,6 +1391,9 @@ config_generic(ConfigArgs *c) {
rc = 1;
}
break;
case CFG_LOGFILE_ONLY:
c->value_int = logfile_only;
break;
case CFG_LOGFILE_ROTATE:
rc = 1;
if ( logfile_max ) {
......@@ -1636,6 +1642,12 @@ config_generic(ConfigArgs *c) {
logfile_close();
break;
case CFG_LOGFILE_ONLY:
/* remove loglevel from debuglevel */
slap_debug = slap_debug_orig;
ldap_syslog = config_syslog;
break;
case CFG_LOGFILE_ROTATE:
logfile_max = logfile_fslimit = logfile_age = 0;
break;
......@@ -2420,6 +2432,16 @@ sortval_reject:
}
break;
case CFG_LOGFILE_ONLY:
slap_debug = slap_debug_orig;
if ( c->value_int ) {
slap_debug |= config_syslog;
ldap_syslog = 0;
} else {
ldap_syslog = config_syslog;
}
break;
case CFG_LOGFILE_ROTATE: {
unsigned lf_max, lf_mbyte, lf_hour;
if ( lutil_atoux( &lf_max, c->argv[1], 0 ) != 0 ) {
......@@ -3965,8 +3987,6 @@ loglevel_print( FILE *out )
return 0;
}
static int config_syslog;
static int
config_loglevel(ConfigArgs *c) {
int i;
......@@ -3989,7 +4009,9 @@ config_loglevel(ConfigArgs *c) {
config_syslog &= ~loglevel_ops[i].mask;
}
if ( slapMode & SLAP_SERVER_MODE ) {
ldap_syslog = config_syslog;
slap_debug = slap_debug_orig;
if ( !logfile_only )
ldap_syslog = config_syslog;
}
return 0;
}
......@@ -4019,7 +4041,12 @@ config_loglevel(ConfigArgs *c) {
config_syslog = 0;
}
if ( slapMode & SLAP_SERVER_MODE ) {
ldap_syslog = config_syslog;
if ( logfile_only ) {
slap_debug = slap_debug_orig | config_syslog;
ldap_syslog = 0;
} else {
ldap_syslog = config_syslog;
}
}
return(0);
}
......
......@@ -34,6 +34,7 @@ static char logfile_suffix[sizeof(".xx.gz")];
char logfile_path[MAXPATHLEN - sizeof(logfile_suffix) -1];
long logfile_fslimit;
int logfile_age, logfile_only, logfile_max;
int slap_debug_orig;
ldap_pvt_thread_mutex_t logfile_mutex;
......
......@@ -723,6 +723,7 @@ unhandled_option:;
ber_set_option(NULL, LBER_OPT_DEBUG_LEVEL, &slap_debug);
ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, &slap_debug);
ldif_debug = slap_debug;
slap_debug_orig = slap_debug;
if ( version ) {
fprintf( stderr, "%s\n", Versionstr );
......
......@@ -1253,6 +1253,7 @@ LDAP_SLAPD_V(int) logfile_age;
LDAP_SLAPD_V(int) logfile_only;
LDAP_SLAPD_V(int) logfile_max;
LDAP_SLAPD_V(long) logfile_fslimit;
LDAP_SLAPD_V(int) slap_debug_orig;
/*
* main.c
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment