ldap/servers/slapd/configdse.c | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-)
New commits: commit 72b7e914195cf9c65aa1f635d786859d8b578aaf Author: Mark Reynolds mreynolds@redhat.com Date: Fri May 25 16:41:22 2012 -0400
Ticket #28 - MOD operations with chained delete/add get back error 53 on backend config
Bug Description: If you try and delete/add a config attribute, an error 53 is returned.
Fix Description: Allow a delete of a config attribute if we add it back in the same mod set.
https://fedorahosted.org/389/ticket/28
Reviewed by: Noriko (Thanks!)
diff --git a/ldap/servers/slapd/configdse.c b/ldap/servers/slapd/configdse.c index 12175c4..51f9165 100644 --- a/ldap/servers/slapd/configdse.c +++ b/ldap/servers/slapd/configdse.c @@ -55,6 +55,7 @@ #include "pw.h"
static int check_all_maxdiskspace_and_mlogsize(Slapi_PBlock *pb, LDAPMod **mod, char *returntext); +static int is_delete_a_replace(LDAPMod **mods, int mod_count); static void get_log_max_size( LDAPMod *mod, char *maxdiskspace_str, char *mlogsize_str, @@ -423,9 +424,17 @@ modify_config_dse(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e, in config_attr); } } else { - rc= LDAP_UNWILLING_TO_PERFORM; - PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE, - "Deleting attributes is not allowed"); + /* + * Check if this delete is followed by an add of the same attribute, as some + * clients do a replace by deleting and adding the attribute. + */ + if(is_delete_a_replace(mods, i)){ + rc = config_set(config_attr, mods[i]->mod_bvalues, returntext, apply_mods); + } else { + rc= LDAP_UNWILLING_TO_PERFORM; + PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE, + "Deleting attributes is not allowed"); + } } } else if (SLAPI_IS_MOD_REPLACE(mods[i]->mod_op)) { if (( checked_all_maxdiskspace_and_mlogsize == 0 ) && @@ -600,3 +609,26 @@ get_log_max_size( LDAPMod *mod, *mlogsize = atoi((char *) mod->mod_bvalues[0]->bv_val); } } + +/* + * Loops through all the mods, if we add the attribute back, it's a replace, but we need + * to keep looking through the mods in case it gets deleted again. + */ +static int +is_delete_a_replace(LDAPMod **mods, int mod_count){ + char *del_attr = mods[mod_count]->mod_type; + int rc = 0; + int i; + + for(i = mod_count + 1; mods[i] != NULL; i++){ + if(strcasecmp(mods[i]->mod_type, del_attr) == 0 && SLAPI_IS_MOD_ADD(mods[i]->mod_op)){ + /* ok, we are adding this attribute back */ + rc = 1; + } else if(strcasecmp(mods[i]->mod_type, del_attr) == 0 && SLAPI_IS_MOD_DELETE(mods[i]->mod_op)){ + /* whoops we deleted it again */ + rc = 0; + } + } + + return rc; +}
389-commits@lists.fedoraproject.org