Browse Source

Ticket 47636 - errorlog-level 16384 is listed as 0 in cn=config

Bug Description:  Even if the nsslapd-errorlog-level is set to the
                  default value(16384), a search on cn=config returns
                  the value "0".  This is inconsistent and confusing
                  with the server documentation.

Fix Description:  Do not convert the default errorlog level to zero when
                  updating the internal configuration.  We still allow
                  zero to be set from a ldap client to return the logging
                  to the default state, but that zero will still be stored
                  as 16384.

https://fedorahosted.org/389/ticket/47636

Reviewed by: rmeggins & nhosoi(Thanks!!)
Mark Reynolds 11 years ago
parent
commit
933cbd5c1c
3 changed files with 9 additions and 17 deletions
  1. 5 3
      ldap/servers/slapd/daemon.c
  2. 3 14
      ldap/servers/slapd/libglobs.c
  3. 1 0
      ldap/servers/slapd/slap.h

+ 5 - 3
ldap/servers/slapd/daemon.c

@@ -798,10 +798,12 @@ disk_monitoring_thread(void *nothing)
          */
         if(verbose_logging != 0 && verbose_logging != LDAP_DEBUG_ANY){
             LDAPDebug(LDAP_DEBUG_ANY, "Disk space is low on disk (%s), remaining space: %" NSPRIu64 " Kb, "
-                "temporarily setting error loglevel to zero.\n", dirstr,
-                (disk_space / 1024), 0);
+                "temporarily setting error loglevel to the default level(%d).\n", dirstr,
+                (disk_space / 1024), SLAPD_DEFAULT_ERRORLOG_LEVEL);
             /* Setting the log level back to zero, actually sets the value to LDAP_DEBUG_ANY */
-            config_set_errorlog_level(CONFIG_LOGLEVEL_ATTRIBUTE, "0", errorbuf, CONFIG_APPLY);
+            config_set_errorlog_level(CONFIG_LOGLEVEL_ATTRIBUTE,
+                                      STRINGIFYDEFINE(SLAPD_DEFAULT_ERRORLOG_LEVEL),
+                                      errorbuf, CONFIG_APPLY);
             continue;
         }
         /*

+ 3 - 14
ldap/servers/slapd/libglobs.c

@@ -118,7 +118,6 @@ typedef enum {
 	CONFIG_CONSTANT_STRING, /* for #define values, e.g. */
 	CONFIG_SPECIAL_REFERRALLIST, /* this is a berval list */
 	CONFIG_SPECIAL_SSLCLIENTAUTH, /* maps strings to an enumeration */
-	CONFIG_SPECIAL_ERRORLOGLEVEL, /* requires & with LDAP_DEBUG_ANY */
 	CONFIG_STRING_OR_EMPTY, /* use an empty string */
 	CONFIG_SPECIAL_ANON_ACCESS_SWITCH, /* maps strings to an enumeration */
 	CONFIG_SPECIAL_VALIDATE_CERT_SWITCH, /* maps strings to an enumeration */
@@ -289,7 +288,7 @@ slapi_onoff_t init_mempool_switch;
 static int
 isInt(ConfigVarType type)
 {
-    return type == CONFIG_INT || type == CONFIG_ON_OFF || type == CONFIG_SPECIAL_SSLCLIENTAUTH || type == CONFIG_SPECIAL_ERRORLOGLEVEL;
+    return type == CONFIG_INT || type == CONFIG_ON_OFF || type == CONFIG_SPECIAL_SSLCLIENTAUTH;
 }
 
 /* the caller will typically have to cast the result based on the ConfigVarType */
@@ -339,7 +338,7 @@ static struct config_get_and_set {
 	{CONFIG_LOGLEVEL_ATTRIBUTE, config_set_errorlog_level,
 		NULL, 0,
 		(void**)&global_slapdFrontendConfig.errorloglevel,
-		CONFIG_SPECIAL_ERRORLOGLEVEL, NULL, NULL},
+		CONFIG_INT, NULL, STRINGIFYDEFINE(SLAPD_DEFAULT_ERRORLOG_LEVEL)},
 	{CONFIG_ERRORLOG_LOGGING_ENABLED_ATTRIBUTE, NULL,
 		log_set_logging, SLAPD_ERROR_LOG,
 		(void**)&global_slapdFrontendConfig.errorlog_logging_enabled,
@@ -1520,7 +1519,7 @@ FrontendConfig_init () {
   cfg->errorlog_minfreespace = 5;
   cfg->errorlog_exptime = 1;
   cfg->errorlog_exptimeunit = slapi_ch_strdup(INIT_ERRORLOG_EXPTIMEUNIT);
-  cfg->errorloglevel = 0;
+  cfg->errorloglevel = SLAPD_DEFAULT_ERRORLOG_LEVEL;
 
   init_auditlog_logging_enabled = cfg->auditlog_logging_enabled = LDAP_OFF;
   cfg->auditlog_mode = slapi_ch_strdup(INIT_AUDITLOG_MODE);
@@ -7475,16 +7474,6 @@ config_set_value(
                                      *((char **)value) : "unknown");
         break;
 
-    case CONFIG_SPECIAL_ERRORLOGLEVEL:
-        if (value) {
-            int ival = *(int *)value;
-            ival &= ~LDAP_DEBUG_ANY;
-            slapi_entry_attr_set_int(e, cgas->attr_name, ival);
-        }
-        else
-            slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
-        break;
-
     case CONFIG_SPECIAL_ANON_ACCESS_SWITCH:
         if (!value) {
             slapi_entry_attr_set_charptr(e, cgas->attr_name, "off");

+ 1 - 0
ldap/servers/slapd/slap.h

@@ -272,6 +272,7 @@ typedef void	(*VFPV)(); /* takes undefined arguments */
 #define SLAPD_DEFAULT_DIR_MODE				S_IRWXU
 #endif
 
+#define SLAPD_DEFAULT_ERRORLOG_LEVEL			16384
 #define SLAPD_DEFAULT_IDLE_TIMEOUT			0		/* seconds - 0 == never */
 #define SLAPD_DEFAULT_SIZELIMIT				2000	/* use -1 for no limit */
 #define SLAPD_DEFAULT_TIMELIMIT				3600	/* use -1 for no limit */