andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone

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

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