Blame SOURCES/0018-Ticket-49374-server-fails-to-start-because-maxdisksi.patch

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