Blame SOURCES/0009-Issue-50653-objectclass-parsing-fails-to-log-error-m.patch

4c04d8
From df8ad0467a6c5e69b8bd5f48e23582734d78b356 Mon Sep 17 00:00:00 2001
4c04d8
From: Mark Reynolds <mreynolds@redhat.com>
4c04d8
Date: Wed, 16 Oct 2019 14:16:55 -0400
4c04d8
Subject: [PATCH] Issue 50653 -  objectclass parsing fails to log error message
4c04d8
 text
4c04d8
4c04d8
Description:  When replacing an objectclass, if it already exists we
4c04d8
              log an error but we do not log what objectclass it is.
4c04d8
              This commit adds the error message text.
4c04d8
4c04d8
relates: https://pagure.io/389-ds-base/issue/50653
4c04d8
4c04d8
Reviewed by: abbra(Thanks!)
4c04d8
---
4c04d8
 ldap/servers/slapd/schema.c | 10 +++++++---
4c04d8
 1 file changed, 7 insertions(+), 3 deletions(-)
4c04d8
4c04d8
diff --git a/ldap/servers/slapd/schema.c b/ldap/servers/slapd/schema.c
4c04d8
index 68c98341a..e4f0d663e 100644
4c04d8
--- a/ldap/servers/slapd/schema.c
4c04d8
+++ b/ldap/servers/slapd/schema.c
4c04d8
@@ -126,7 +126,7 @@ static struct dse *pschemadse = NULL;
4c04d8
 
4c04d8
 static void oc_add_nolock(struct objclass *newoc);
4c04d8
 static int oc_delete_nolock(char *ocname);
4c04d8
-static int oc_replace_nolock(const char *ocname, struct objclass *newoc);
4c04d8
+static int oc_replace_nolock(const char *ocname, struct objclass *newoc, char *errorbuf, size_t errorbufsize);
4c04d8
 static int oc_check_required(Slapi_PBlock *, Slapi_Entry *, struct objclass *);
4c04d8
 static int oc_check_allowed_sv(Slapi_PBlock *, Slapi_Entry *e, const char *type, struct objclass **oclist);
4c04d8
 static int schema_delete_objectclasses(Slapi_Entry *entryBefore,
4c04d8
@@ -1110,7 +1110,7 @@ oc_find_oid_nolock(const char *ocoid)
4c04d8
 */
4c04d8
 
4c04d8
 static int
4c04d8
-oc_replace_nolock(const char *ocname, struct objclass *newoc)
4c04d8
+oc_replace_nolock(const char *ocname, struct objclass *newoc, char *errorbuf, size_t errorbufsize)
4c04d8
 {
4c04d8
     struct objclass *oc, *pnext;
4c04d8
     int rc = LDAP_SUCCESS;
4c04d8
@@ -1130,6 +1130,8 @@ oc_replace_nolock(const char *ocname, struct objclass *newoc)
4c04d8
         for (pnext = oc; pnext != NULL;
4c04d8
              oc = pnext, pnext = pnext->oc_next) {
4c04d8
             if (pnext->oc_name == NULL) {
4c04d8
+                schema_create_errormsg(errorbuf, errorbufsize, schema_errprefix_oc,
4c04d8
+                                       ocname, "Failed to replace objectclass");
4c04d8
                 rc = LDAP_OPERATIONS_ERROR;
4c04d8
                 break;
4c04d8
             }
4c04d8
@@ -1146,6 +1148,8 @@ oc_replace_nolock(const char *ocname, struct objclass *newoc)
4c04d8
                     break;
4c04d8
 
4c04d8
                 } else {
4c04d8
+                    schema_create_errormsg(errorbuf, errorbufsize, schema_errprefix_oc,
4c04d8
+                                           ocname, "Can not replace objectclass that already exists");
4c04d8
                     rc = LDAP_TYPE_OR_VALUE_EXISTS;
4c04d8
                     break;
4c04d8
                 }
4c04d8
@@ -2817,7 +2821,7 @@ add_oc_internal(struct objclass *pnew_oc, char *errorbuf, size_t errorbufsize, i
4c04d8
     /* insert new objectclass exactly where the old one one in the linked list*/
4c04d8
     if (!rc && redefined_oc) {
4c04d8
         pnew_oc->oc_flags |= OC_FLAG_REDEFINED_OC;
4c04d8
-        rc = oc_replace_nolock(pnew_oc->oc_name, pnew_oc);
4c04d8
+        rc = oc_replace_nolock(pnew_oc->oc_name, pnew_oc, errorbuf, errorbufsize);
4c04d8
     }
4c04d8
 
4c04d8
     if (!rc && !redefined_oc) {
4c04d8
-- 
4c04d8
2.21.0
4c04d8