Blame SOURCES/0078-Ticket-447-Possible-to-add-invalid-attribute-to-nssl.patch

cc3dff
From 31a7087a26c153ff3430a1028be34c64839d0fd0 Mon Sep 17 00:00:00 2001
cc3dff
From: Noriko Hosoi <nhosoi@redhat.com>
cc3dff
Date: Wed, 8 Jan 2014 10:30:04 -0800
cc3dff
Subject: [PATCH 78/78] Ticket #447 - Possible to add invalid attribute to
cc3dff
 nsslapd-allowed-to-delete-attrs
cc3dff
cc3dff
Bug description: If given value of nsslapd-allowed-to-delete-attrs are
cc3dff
all invalid attributes, e.g.,
cc3dff
  nsslapd-allowed-to-delete-attrs: invalid0 invalid1
cc3dff
they were logged as invalid, but accidentally set to nsslapd-allowed-
cc3dff
to-delete-attrs.
cc3dff
cc3dff
Fix description: This patch checks the validation result and if there
cc3dff
is no valid attributes given to nsslapd-allowed-to-delete-attrs, it
cc3dff
issues a message in the error log:
cc3dff
  nsslapd-allowed-to-delete-attrs: Given attributes are all invalid.
cc3dff
  No effects.
cc3dff
and it returns an error.  The modify operation fails with "DSA is
cc3dff
unwilling to perform".
cc3dff
cc3dff
https://fedorahosted.org/389/ticket/447
cc3dff
cc3dff
Reviewed by rmeggins@redhat.com (Thank you, Rich!)
cc3dff
(cherry picked from commit 31cd7a838aef30d80be6efe519cc2e821811c645)
cc3dff
(cherry picked from commit eab32225c129f6a5115bbd5ac2a3c2035f4393b2)
cc3dff
(cherry picked from commit c392aa891e67b8be189d3e354a179fc376998642)
cc3dff
---
cc3dff
 ldap/servers/slapd/libglobs.c | 24 ++++++++++++++++--------
cc3dff
 1 file changed, 16 insertions(+), 8 deletions(-)
cc3dff
cc3dff
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
cc3dff
index 64510d6..6df225d 100644
cc3dff
--- a/ldap/servers/slapd/libglobs.c
cc3dff
+++ b/ldap/servers/slapd/libglobs.c
cc3dff
@@ -6720,15 +6720,23 @@ config_set_allowed_to_delete_attrs( const char *attrname, char *value,
cc3dff
             /* given value included unknown attribute,
cc3dff
              * we need to re-create a value. */
cc3dff
             /* reuse the duplicated string for the new attr value. */
cc3dff
-            for (s = allowed, d = vcopy; s && *s; s++) {
cc3dff
-                size_t slen = strlen(*s);
cc3dff
-                memmove(d, *s, slen);
cc3dff
-                d += slen;
cc3dff
-                memmove(d, " ", 1);
cc3dff
-                d++;
cc3dff
+            if (allowed && (NULL == *allowed)) {
cc3dff
+                /* all the values to allow to delete are invalid */
cc3dff
+                slapi_log_error(SLAPI_LOG_FATAL, "config",
cc3dff
+                        "%s: Given attributes are all invalid.  No effects.\n",
cc3dff
+                        CONFIG_ALLOWED_TO_DELETE_ATTRIBUTE);
cc3dff
+                return LDAP_NO_SUCH_ATTRIBUTE;
cc3dff
+            } else {
cc3dff
+                for (s = allowed, d = vcopy; s && *s; s++) {
cc3dff
+                    size_t slen = strlen(*s);
cc3dff
+                    memmove(d, *s, slen);
cc3dff
+                    d += slen;
cc3dff
+                    memmove(d, " ", 1);
cc3dff
+                    d++;
cc3dff
+                }
cc3dff
+                *(d-1) = '\0';
cc3dff
+                strcpy(value, vcopy); /* original value needs to be refreshed */
cc3dff
             }
cc3dff
-            *(d-1) = '\0';
cc3dff
-            strcpy(value, vcopy); /* original value needs to be refreshed */
cc3dff
         } else {
cc3dff
             slapi_ch_free_string(&vcopy);
cc3dff
             vcopy = slapi_ch_strdup(value);
cc3dff
-- 
cc3dff
1.8.1.4
cc3dff