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

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