From 4ecec8dac601b77a25ebc390f138aad1ee48d805 Mon Sep 17 00:00:00 2001
From: Mark Reynolds <mreynolds@redhat.com>
Date: Thu, 19 Oct 2017 12:20:48 -0400
Subject: [PATCH] Ticket 49374 - server fails to start because maxdisksize is
recognized incorrectly
Bug Description: When directly editting dse.ldif, the server had a check
when setting the log maxdiskspace vs maxlogsize. If the
maxlogsize is processed first and it is higher than the
default maxdisksspace then it throw an error and the server
fails to start.
If you attempt this same operation using ldapmodify it
works as "live" updates check all the mods first, so the
order of the attributes does not matter.
Fix description: Remove the size checks from the attribute set function.
It is technically redundant since it is correctly checked
by the configdse code.
https://pagure.io/389-ds-base/issue/49374
Reviewed by: tbordaz(Thanks!)
(cherry picked from commit 63a0a59c9b09af08151831209ee6711b4363aee2)
---
ldap/servers/slapd/log.c | 60 ++++++++++++------------------------------------
1 file changed, 15 insertions(+), 45 deletions(-)
diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c
index e16d89cc5..998efaef3 100644
--- a/ldap/servers/slapd/log.c
+++ b/ldap/servers/slapd/log.c
@@ -960,7 +960,6 @@ int
log_set_logsize(const char *attrname, char *logsize_str, int logtype, char *returntext, int apply)
{
int rv = LDAP_SUCCESS;
- PRInt64 mdiskspace = 0; /* in bytes */
PRInt64 max_logsize; /* in bytes */
int logsize; /* in megabytes */
slapdFrontendConfig_t *fe_cfg = getFrontendConfig();
@@ -979,72 +978,43 @@ log_set_logsize(const char *attrname, char *logsize_str, int logtype, char *retu
switch (logtype) {
case SLAPD_ACCESS_LOG:
- LOG_ACCESS_LOCK_WRITE();
- mdiskspace = loginfo.log_access_maxdiskspace;
- break;
- case SLAPD_ERROR_LOG:
- LOG_ERROR_LOCK_WRITE();
- mdiskspace = loginfo.log_error_maxdiskspace;
- break;
- case SLAPD_AUDIT_LOG:
- LOG_AUDIT_LOCK_WRITE();
- mdiskspace = loginfo.log_audit_maxdiskspace;
- break;
- case SLAPD_AUDITFAIL_LOG:
- LOG_AUDITFAIL_LOCK_WRITE();
- mdiskspace = loginfo.log_auditfail_maxdiskspace;
- break;
- default:
- PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: invalid logtype %d", attrname, logtype);
- rv = LDAP_OPERATIONS_ERROR;
- }
-
- if ((max_logsize > mdiskspace) && (mdiskspace != -1)) {
- rv = 2;
- }
-
- switch (logtype) {
- case SLAPD_ACCESS_LOG:
- if (!rv && apply) {
+ if (apply) {
+ LOG_ACCESS_LOCK_WRITE();
loginfo.log_access_maxlogsize = max_logsize;
fe_cfg->accesslog_maxlogsize = logsize;
+ LOG_ACCESS_UNLOCK_WRITE();
}
- LOG_ACCESS_UNLOCK_WRITE();
break;
case SLAPD_ERROR_LOG:
- if (!rv && apply) {
+ if (apply) {
+ LOG_ERROR_LOCK_WRITE();
loginfo.log_error_maxlogsize = max_logsize;
fe_cfg->errorlog_maxlogsize = logsize;
+ LOG_ERROR_UNLOCK_WRITE();
}
- LOG_ERROR_UNLOCK_WRITE();
break;
case SLAPD_AUDIT_LOG:
- if (!rv && apply) {
+ if (apply) {
+ LOG_AUDIT_LOCK_WRITE();
loginfo.log_audit_maxlogsize = max_logsize;
fe_cfg->auditlog_maxlogsize = logsize;
+ LOG_AUDIT_UNLOCK_WRITE();
}
- LOG_AUDIT_UNLOCK_WRITE();
break;
case SLAPD_AUDITFAIL_LOG:
- if (!rv && apply) {
+ if (apply) {
+ LOG_AUDITFAIL_LOCK_WRITE();
loginfo.log_auditfail_maxlogsize = max_logsize;
fe_cfg->auditfaillog_maxlogsize = logsize;
+ LOG_AUDITFAIL_UNLOCK_WRITE();
}
- LOG_AUDITFAIL_UNLOCK_WRITE();
break;
default:
- rv = 1;
- }
- /* logsize is in MB */
- if (rv == 2) {
- slapi_log_err(SLAPI_LOG_ERR, "log_set_logsize",
- "Invalid value for Maximum log size:"
- "Maxlogsize:%d (MB) exceeds Maxdisksize:%ld (MB)\n",
- logsize, (long int)(mdiskspace / LOG_MB_IN_BYTES));
-
+ PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE,
+ "%s: invalid logtype %d", attrname, logtype);
rv = LDAP_OPERATIONS_ERROR;
}
+
return rv;
}
--
2.13.6