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

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