Browse Source

Bug 616850 - ldapmodify failed to reject the replace operation
if its targeted for an Unknown attribute

https://bugzilla.redhat.com/show_bug.cgi?id=616850

Description: Attempting to modify an unknown attribute in the
config entry fails with LDAP_UNWILLING_TO_PERFORM, while starting
up just ignores unknown attributes and the server successfully
starts.

Noriko Hosoi 15 years ago
parent
commit
f1899ba0ea
2 changed files with 19 additions and 4 deletions
  1. 18 3
      ldap/servers/slapd/configdse.c
  2. 1 1
      ldap/servers/slapd/libglobs.c

+ 18 - 3
ldap/servers/slapd/configdse.c

@@ -329,9 +329,12 @@ load_config_dse(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* ignored, int *ret
 					retval = LDAP_SUCCESS;
 				}
 			} else {
-				if ((retval != LDAP_SUCCESS) &&
-					slapi_attr_flag_is_set(attr, SLAPI_ATTR_FLAG_OPATTR)) {
-					retval = LDAP_SUCCESS; /* ignore attempts to modify operational attrs */
+				if (((retval != LDAP_SUCCESS) &&
+					slapi_attr_flag_is_set(attr, SLAPI_ATTR_FLAG_OPATTR)) ||
+					(LDAP_NO_SUCH_ATTRIBUTE == retval)) {
+					/* ignore attempts to modify operational attrs and */
+					/* ignore attempts to modify unknown attributes for load. */
+					retval = LDAP_SUCCESS;
 				}
 			}
 		}
@@ -425,6 +428,12 @@ modify_config_dse(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e, in
 				}
 				rc = config_set(config_attr, mods[i]->mod_bvalues, 
 								returntext, apply_mods);
+				if (LDAP_NO_SUCH_ATTRIBUTE == rc) {
+					/* config_set returns LDAP_NO_SUCH_ATTRIBUTE if the
+					 * attr is not defined for cn=config. 
+					 * map it to LDAP_UNWILLING_TO_PERFORM */
+					rc = LDAP_UNWILLING_TO_PERFORM;
+				}
 			} else if (SLAPI_IS_MOD_DELETE(mods[i]->mod_op)) {
 				/* Need to allow deleting some configuration attrs */
 			    if (allowed_to_delete_attrs(config_attr)) {
@@ -458,6 +467,12 @@ modify_config_dse(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e, in
 
 				rc = config_set(config_attr, mods[i]->mod_bvalues, returntext,
 								apply_mods);
+				if (LDAP_NO_SUCH_ATTRIBUTE == rc) {
+					/* config_set returns LDAP_NO_SUCH_ATTRIBUTE if the
+					 * attr is not defined for cn=config. 
+					 * map it to LDAP_UNWILLING_TO_PERFORM */
+					rc = LDAP_UNWILLING_TO_PERFORM;
+				}
 			}
 		}
 	}

+ 1 - 1
ldap/servers/slapd/libglobs.c

@@ -5671,7 +5671,7 @@ config_set(const char *attr, struct berval **values, char *errorbuf, int apply)
 #endif
 		PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Unknown attribute %s will be ignored", attr);
 		slapi_log_error(SLAPI_LOG_FATAL, "config", "%s\n", errorbuf);
-		return retval;
+		return LDAP_NO_SUCH_ATTRIBUTE;
 	}
 
 	switch (cgas->config_var_type)