From e07d05038ad58e147c37d5a1534cd42620739048 Mon Sep 17 00:00:00 2001 From: William Brown Date: Fri, 28 Oct 2016 15:09:52 +1000 Subject: [PATCH 3/3] Ticket 48961 - Minimise template-dse.ldif Bug Description: Given that our defaults are all in the server, we should stop hardcoding them in template.dse.ldif. The issue here is if we need to *change* a value, because it's in the dse.ldif, we will always be overridden. Our default upgrade process is useless now! Fix Description: Remove most of the hardcoded values in dse.ldif. It turns out some of the conflicted with the values in slap.h (slap.h now matches what was in dse.ldif to not break expectations). Fix logging initialisation to use the cfg, as it relied on there being values in dse.ldif else it wouldn't even start the logging system. https://fedorahosted.org/389/ticket/48961 Author: wibrown Review by: ??? --- ldap/ldif/template-dse.ldif.in | 44 -------------------- ldap/servers/slapd/libglobs.c | 2 +- ldap/servers/slapd/log.c | 89 +++++++++++++++++++++-------------------- ldap/servers/slapd/main.c | 2 +- ldap/servers/slapd/proto-slap.h | 2 +- 5 files changed, 48 insertions(+), 91 deletions(-) diff --git a/ldap/ldif/template-dse.ldif.in b/ldap/ldif/template-dse.ldif.in index 8258b70..d9f6166 100644 --- a/ldap/ldif/template-dse.ldif.in +++ b/ldap/ldif/template-dse.ldif.in @@ -11,59 +11,15 @@ nsslapd-ldifdir: %ldif_dir% nsslapd-bakdir: %bak_dir% nsslapd-rundir: %run_dir% nsslapd-instancedir: %inst_dir% -nsslapd-accesslog-logging-enabled: on -nsslapd-accesslog-maxlogsperdir: 10 -nsslapd-accesslog-mode: 600 -nsslapd-accesslog-maxlogsize: 100 -nsslapd-accesslog-logrotationtime: 1 -nsslapd-accesslog-logrotationtimeunit: day -nsslapd-accesslog-logrotationsync-enabled: off -nsslapd-accesslog-logrotationsynchour: 0 -nsslapd-accesslog-logrotationsyncmin: 0 nsslapd-accesslog: %log_dir%/access -nsslapd-enquote-sup-oc: off nsslapd-localhost: %fqdn% -nsslapd-schemacheck: on -nsslapd-syntaxcheck: on -nsslapd-dn-validate-strict: off -nsslapd-rewrite-rfc1274: off -nsslapd-return-exact-case: on -nsslapd-ssl-check-hostname: on -nsslapd-validate-cert: warn -nsslapd-allow-unauthenticated-binds: off -nsslapd-require-secure-binds: off -nsslapd-allow-anonymous-access: on -nsslapd-localssf: 71 -nsslapd-minssf: 0 nsslapd-port: %ds_port% nsslapd-localuser: %ds_user% -nsslapd-errorlog-logging-enabled: on -nsslapd-errorlog-mode: 600 -nsslapd-errorlog-maxlogsperdir: 2 -nsslapd-errorlog-maxlogsize: 100 -nsslapd-errorlog-logrotationtime: 1 -nsslapd-errorlog-logrotationtimeunit: week -nsslapd-errorlog-logrotationsync-enabled: off -nsslapd-errorlog-logrotationsynchour: 0 -nsslapd-errorlog-logrotationsyncmin: 0 nsslapd-errorlog: %log_dir%/errors nsslapd-auditlog: %log_dir%/audit -nsslapd-auditlog-mode: 600 -nsslapd-auditlog-maxlogsize: 100 -nsslapd-auditlog-logrotationtime: 1 -nsslapd-auditlog-logrotationtimeunit: day -nsslapd-auditlog-logging-enabled: off nsslapd-auditfaillog: %log_dir%/audit -nsslapd-auditfaillog-logging-enabled: off nsslapd-rootdn: %rootdn% nsslapd-rootpw: %ds_passwd% -nsslapd-maxdescriptors: 1024 -nsslapd-max-filter-nest-level: 40 -nsslapd-ndn-cache-enabled: on -nsslapd-sasl-mapping-fallback: off -nsslapd-dynamic-plugins: off -nsslapd-allow-hashed-passwords: off -nsslapd-logging-backend: dirsrv-log dn: cn=features,cn=config objectclass: top diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c index 3cf05ec..ac95f2c 100644 --- a/ldap/servers/slapd/libglobs.c +++ b/ldap/servers/slapd/libglobs.c @@ -1436,7 +1436,7 @@ FrontendConfig_init(void) { cfg->anon_limits_dn = slapi_ch_strdup(""); init_schemacheck = cfg->schemacheck = LDAP_ON; init_schemamod = cfg->schemamod = LDAP_ON; - init_syntaxcheck = cfg->syntaxcheck = LDAP_OFF; + init_syntaxcheck = cfg->syntaxcheck = LDAP_ON; init_plugin_track = cfg->plugin_track = LDAP_OFF; init_moddn_aci = cfg->moddn_aci = LDAP_ON; init_syntaxlogging = cfg->syntaxlogging = LDAP_OFF; diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c index 9838bd3..e1dae00 100644 --- a/ldap/servers/slapd/log.c +++ b/ldap/servers/slapd/log.c @@ -242,28 +242,29 @@ void g_set_detached(int val) /****************************************************************************** * Tell me whether logging begins or not ******************************************************************************/ -void g_log_init(int log_enabled) +void g_log_init() { - slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); + slapdFrontendConfig_t *cfg = getFrontendConfig(); + CFG_LOCK_READ(cfg); /* ACCESS LOG */ - loginfo.log_access_state = 0; + loginfo.log_access_state = cfg->accesslog_logging_enabled; loginfo.log_access_mode = SLAPD_DEFAULT_FILE_MODE; - loginfo.log_access_maxnumlogs = 1; - loginfo.log_access_maxlogsize = -1; - loginfo.log_access_rotationsync_enabled = 0; - loginfo.log_access_rotationsynchour = -1; - loginfo.log_access_rotationsyncmin = -1; + loginfo.log_access_maxnumlogs = cfg->accesslog_maxnumlogs; + loginfo.log_access_maxlogsize = cfg->accesslog_maxlogsize; + loginfo.log_access_rotationsync_enabled = cfg->accesslog_rotationsync_enabled; + loginfo.log_access_rotationsynchour = cfg->accesslog_rotationsynchour; + loginfo.log_access_rotationsyncmin = cfg->accesslog_rotationsyncmin; loginfo.log_access_rotationsyncclock = -1; - loginfo.log_access_rotationtime = 1; /* default: 1 */ + loginfo.log_access_rotationtime = cfg->accesslog_rotationtime; /* default: 1 */ loginfo.log_access_rotationunit = LOG_UNIT_DAYS; /* default: day */ loginfo.log_access_rotationtime_secs = _SEC_PER_DAY; /* default: 1 day */ - loginfo.log_access_maxdiskspace = -1; - loginfo.log_access_minfreespace = -1; - loginfo.log_access_exptime = -1; /* default: -1 */ + loginfo.log_access_maxdiskspace = cfg->accesslog_maxdiskspace; + loginfo.log_access_minfreespace = cfg->accesslog_minfreespace; + loginfo.log_access_exptime = cfg->accesslog_exptime; /* default: -1 */ loginfo.log_access_exptimeunit = LOG_UNIT_MONTHS; /* default: month */ loginfo.log_access_exptime_secs = -1; /* default: -1 */ - loginfo.log_access_level = LDAP_DEBUG_STATS; + loginfo.log_access_level = cfg->accessloglevel; loginfo.log_access_ctime = 0L; loginfo.log_access_fdes = NULL; loginfo.log_access_file = NULL; @@ -277,23 +278,22 @@ void g_log_init(int log_enabled) if ((loginfo.log_access_buffer->lock = PR_NewLock())== NULL ) { exit (-1); } - slapdFrontendConfig->accessloglevel = LDAP_DEBUG_STATS; /* ERROR LOG */ - loginfo.log_error_state = 0; + loginfo.log_error_state = cfg->errorlog_logging_enabled; loginfo.log_error_mode = SLAPD_DEFAULT_FILE_MODE; - loginfo.log_error_maxnumlogs = 1; - loginfo.log_error_maxlogsize = -1; - loginfo.log_error_rotationsync_enabled = 0; - loginfo.log_error_rotationsynchour = -1; - loginfo.log_error_rotationsyncmin = -1; + loginfo.log_error_maxnumlogs = cfg->errorlog_maxnumlogs; + loginfo.log_error_maxlogsize = cfg->errorlog_maxlogsize; + loginfo.log_error_rotationsync_enabled = cfg->errorlog_rotationsync_enabled; + loginfo.log_error_rotationsynchour = cfg->errorlog_rotationsynchour; + loginfo.log_error_rotationsyncmin = cfg->errorlog_rotationsyncmin; loginfo.log_error_rotationsyncclock = -1; - loginfo.log_error_rotationtime = 1; /* default: 1 */ + loginfo.log_error_rotationtime = cfg->errorlog_rotationtime; /* default: 1 */ loginfo.log_error_rotationunit = LOG_UNIT_WEEKS; /* default: week */ loginfo.log_error_rotationtime_secs = 604800; /* default: 1 week */ - loginfo.log_error_maxdiskspace = -1; - loginfo.log_error_minfreespace = -1; - loginfo.log_error_exptime = -1; /* default: -1 */ + loginfo.log_error_maxdiskspace = cfg->errorlog_maxdiskspace; + loginfo.log_error_minfreespace = cfg->errorlog_minfreespace; + loginfo.log_error_exptime = cfg->errorlog_exptime; /* default: -1 */ loginfo.log_error_exptimeunit = LOG_UNIT_MONTHS; /* default: month */ loginfo.log_error_exptime_secs = -1; /* default: -1 */ loginfo.log_error_ctime = 0L; @@ -307,20 +307,20 @@ void g_log_init(int log_enabled) } /* AUDIT LOG */ - loginfo.log_audit_state = 0; + loginfo.log_audit_state = cfg->auditlog_logging_enabled; loginfo.log_audit_mode = SLAPD_DEFAULT_FILE_MODE; - loginfo.log_audit_maxnumlogs = 1; - loginfo.log_audit_maxlogsize = -1; - loginfo.log_audit_rotationsync_enabled = 0; - loginfo.log_audit_rotationsynchour = -1; - loginfo.log_audit_rotationsyncmin = -1; + loginfo.log_audit_maxnumlogs = cfg->auditlog_maxnumlogs; + loginfo.log_audit_maxlogsize = cfg->auditlog_maxlogsize; + loginfo.log_audit_rotationsync_enabled = cfg->auditlog_rotationsync_enabled; + loginfo.log_audit_rotationsynchour = cfg->auditlog_rotationsynchour; + loginfo.log_audit_rotationsyncmin = cfg->auditlog_rotationsyncmin; loginfo.log_audit_rotationsyncclock = -1; - loginfo.log_audit_rotationtime = 1; /* default: 1 */ + loginfo.log_audit_rotationtime = cfg->auditlog_rotationtime; /* default: 1 */ loginfo.log_audit_rotationunit = LOG_UNIT_WEEKS; /* default: week */ loginfo.log_audit_rotationtime_secs = 604800; /* default: 1 week */ - loginfo.log_audit_maxdiskspace = -1; - loginfo.log_audit_minfreespace = -1; - loginfo.log_audit_exptime = -1; /* default: -1 */ + loginfo.log_audit_maxdiskspace = cfg->auditlog_maxdiskspace; + loginfo.log_audit_minfreespace = cfg->auditlog_minfreespace; + loginfo.log_audit_exptime = cfg->auditlog_exptime; /* default: -1 */ loginfo.log_audit_exptimeunit = LOG_UNIT_WEEKS; /* default: week */ loginfo.log_audit_exptime_secs = -1; /* default: -1 */ loginfo.log_audit_ctime = 0L; @@ -334,20 +334,20 @@ void g_log_init(int log_enabled) } /* AUDIT LOG */ - loginfo.log_auditfail_state = 0; + loginfo.log_auditfail_state = cfg->auditfaillog_logging_enabled; loginfo.log_auditfail_mode = SLAPD_DEFAULT_FILE_MODE; - loginfo.log_auditfail_maxnumlogs = 1; - loginfo.log_auditfail_maxlogsize = -1; - loginfo.log_auditfail_rotationsync_enabled = 0; - loginfo.log_auditfail_rotationsynchour = -1; - loginfo.log_auditfail_rotationsyncmin = -1; + loginfo.log_auditfail_maxnumlogs = cfg->auditfaillog_maxnumlogs; + loginfo.log_auditfail_maxlogsize = cfg->auditfaillog_maxlogsize; + loginfo.log_auditfail_rotationsync_enabled = cfg->auditfaillog_rotationsync_enabled; + loginfo.log_auditfail_rotationsynchour = cfg->auditfaillog_rotationsynchour; + loginfo.log_auditfail_rotationsyncmin = cfg->auditfaillog_rotationsyncmin; loginfo.log_auditfail_rotationsyncclock = -1; - loginfo.log_auditfail_rotationtime = 1; /* default: 1 */ + loginfo.log_auditfail_rotationtime = cfg->auditfaillog_rotationtime; /* default: 1 */ loginfo.log_auditfail_rotationunit = LOG_UNIT_WEEKS; /* default: week */ loginfo.log_auditfail_rotationtime_secs = 604800; /* default: 1 week */ - loginfo.log_auditfail_maxdiskspace = -1; - loginfo.log_auditfail_minfreespace = -1; - loginfo.log_auditfail_exptime = -1; /* default: -1 */ + loginfo.log_auditfail_maxdiskspace = cfg->auditfaillog_maxdiskspace; + loginfo.log_auditfail_minfreespace = cfg->auditfaillog_minfreespace; + loginfo.log_auditfail_exptime = cfg->auditfaillog_exptime; /* default: -1 */ loginfo.log_auditfail_exptimeunit = LOG_UNIT_WEEKS; /* default: week */ loginfo.log_auditfail_exptime_secs = -1; /* default: -1 */ loginfo.log_auditfail_ctime = 0L; @@ -360,6 +360,7 @@ void g_log_init(int log_enabled) if ((loginfo.log_auditfail_rwlock =slapi_new_rwlock())== NULL ) { exit (-1); } + CFG_UNLOCK_READ(cfg); } /****************************************************************************** diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c index 78f21d0..7b7a5ed 100644 --- a/ldap/servers/slapd/main.c +++ b/ldap/servers/slapd/main.c @@ -669,7 +669,7 @@ main( int argc, char **argv) #endif slapd_init(); - g_log_init(1); + g_log_init(); vattr_init(); if (slapd_exemode == SLAPD_EXEMODE_REFERRAL) { diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h index 097bf41..c521fc2 100644 --- a/ldap/servers/slapd/proto-slap.h +++ b/ldap/servers/slapd/proto-slap.h @@ -811,7 +811,7 @@ int audit_log_openf( char *pathname, int locked); int auditfail_log_openf( char *pathname, int locked); void g_set_detached(int); -void g_log_init(int log_enabled); +void g_log_init(); char *g_get_access_log(void); char *g_get_error_log(void); char *g_get_audit_log(void); -- 1.8.3.1