diff options
Diffstat (limited to 'src/back-shr.c')
-rw-r--r-- | src/back-shr.c | 62 |
1 files changed, 50 insertions, 12 deletions
diff --git a/src/back-shr.c b/src/back-shr.c index 6a874a3..29463a5 100644 --- a/src/back-shr.c +++ b/src/back-shr.c @@ -852,6 +852,7 @@ struct backend_shr_update_references_cbdata { Slapi_PBlock *pb; Slapi_Entry *e; LDAPMod **mods; + char *modlist; }; static bool_t @@ -925,7 +926,6 @@ backend_shr_update_references_cb(const char *group, const char *set, } } if (cbdata->mods[i] == NULL) { - modlist = backend_shr_mods_as_string(cbdata->mods); slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, "no interesting reference-based " @@ -934,10 +934,20 @@ backend_shr_update_references_cb(const char *group, const char *set, set_data->group, set_data->set, slapi_entry_get_ndn(cbdata->e), - modlist, + cbdata->modlist, backend_shr_get_rel_attr_list(set_data)); - free(modlist); return TRUE; + } else { + slapi_log_error(SLAPI_LOG_PLUGIN, + state->plugin_desc->spd_id, + "interesting reference-based " + "changes for \"%s\"/\"%s\" " + "made in \"%s\" (%s in %s)\n", + set_data->group, + set_data->set, + slapi_entry_get_ndn(cbdata->e), + cbdata->modlist, + backend_shr_get_rel_attr_list(set_data)); } } @@ -1454,16 +1464,18 @@ backend_shr_update_references_cb(const char *group, const char *set, return TRUE; } -void +static void backend_shr_update_references(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, - LDAPMod **mods) + LDAPMod **mods, + char *modlist) { struct backend_shr_update_references_cbdata cbdata; cbdata.pb = pb; cbdata.e = e; cbdata.mods = mods; + cbdata.modlist = modlist ? modlist : backend_shr_mods_as_string(mods); if (!map_data_foreach_map(state, NULL, backend_shr_update_references_cb, &cbdata)) { slapi_log_error(SLAPI_LOG_PLUGIN, @@ -1471,6 +1483,9 @@ backend_shr_update_references(struct plugin_state *state, "error updating references for \"%s\"\n", slapi_entry_get_ndn(cbdata.e)); } + if (modlist != cbdata.modlist) { + free(cbdata.modlist); + } } /* Add any map entries which correspond to a directory server entry in this @@ -1591,7 +1606,7 @@ backend_shr_add_cb(Slapi_PBlock *pb) } /* Update entries in maps which are affected by this entry. */ - backend_shr_update_references(cbdata.state, pb, cbdata.e, NULL); + backend_shr_update_references(cbdata.state, pb, cbdata.e, NULL, NULL); map_unlock(); wrap_dec_call_level(); @@ -1607,6 +1622,7 @@ struct backend_shr_modify_entry_cbdata { struct plugin_state *state; Slapi_PBlock *pb; LDAPMod **mods; + Slapi_Mods *real_mods; Slapi_Entry *e_pre, *e_post; char *ndn; char *modlist; @@ -1619,6 +1635,7 @@ backend_shr_modify_entry_cb(const char *group, const char *set, bool_t flag, struct backend_shr_set_data *set_data; struct backend_shr_modify_entry_cbdata *cbdata; int i, j; + LDAPMod *mod; set_data = backend_data; cbdata = cbdata_ptr; @@ -1641,9 +1658,9 @@ backend_shr_modify_entry_cb(const char *group, const char *set, bool_t flag, } if (set_data->skip_uninteresting_updates && (cbdata->mods != NULL) && (set_data->rel_attrs != NULL)) { - for (i = 0; cbdata->mods[i] != NULL; i++) { + for (i = 0; (mod = cbdata->mods[i]) != NULL; i++) { for (j = 0; set_data->rel_attrs[j] != NULL; j++) { - if (slapi_attr_types_equivalent(cbdata->mods[i]->mod_type, + if (slapi_attr_types_equivalent(mod->mod_type, set_data->rel_attrs[j])) { break; } @@ -1652,7 +1669,7 @@ backend_shr_modify_entry_cb(const char *group, const char *set, bool_t flag, break; } } - if (cbdata->mods[i] == NULL) { + if (mod == NULL) { slapi_log_error(SLAPI_LOG_PLUGIN, cbdata->state->plugin_desc->spd_id, "no interesting changes for " @@ -1664,6 +1681,17 @@ backend_shr_modify_entry_cb(const char *group, const char *set, bool_t flag, cbdata->modlist, backend_shr_get_rel_attr_list(set_data)); return TRUE; + } else { + slapi_log_error(SLAPI_LOG_PLUGIN, + cbdata->state->plugin_desc->spd_id, + "interesting changes for " + "\"%s\"/\"%s\" made in (\"%s\") " + "(%s in %s)\n", + set_data->group, + set_data->set, + cbdata->ndn, + cbdata->modlist, + backend_shr_get_rel_attr_list(set_data)); } } /* If the entry used to match the map, remove it. */ @@ -1753,6 +1781,11 @@ backend_shr_modify_cb(Slapi_PBlock *pb) "post-modify entry is NULL\n"); return 0; } + /* Don't do a lot of work for other plugins which initiated a no-op + * modify. */ + cbdata.real_mods = slapi_mods_new(); + slapi_entry_diff(cbdata.real_mods, cbdata.e_pre, cbdata.e_post, 0); + cbdata.mods = slapi_mods_get_ldapmods_byref(cbdata.real_mods); cbdata.ndn = slapi_entry_get_ndn(cbdata.e_pre); cbdata.modlist = backend_shr_mods_as_string(cbdata.mods); /* Modify map entries which corresponded to this directory server @@ -1768,10 +1801,15 @@ backend_shr_modify_cb(Slapi_PBlock *pb) } /* Update entries which need to be updated in case they are no longer * affected by this entry. */ - backend_shr_update_references(cbdata.state, pb, cbdata.e_pre, cbdata.mods); + backend_shr_update_references(cbdata.state, pb, cbdata.e_pre, + cbdata.mods, cbdata.modlist); /* Update entries which need to be updated in case they are now * affected by this entry. */ - backend_shr_update_references(cbdata.state, pb, cbdata.e_post, cbdata.mods); + backend_shr_update_references(cbdata.state, pb, cbdata.e_post, + cbdata.mods, cbdata.modlist); + /* Done with the "real" mods. */ + slapi_mods_free(&cbdata.real_mods); + slapi_pblock_get(pb, SLAPI_MODIFY_MODS, &cbdata.mods); /* If it's a map configuration entry, reconfigure, clear, and * repopulate the map. */ if (backend_shr_entry_is_a_set(cbdata.state, pb, cbdata.e_pre)) { @@ -2062,7 +2100,7 @@ backend_shr_delete_cb(Slapi_PBlock *pb) } /* Update entries which need to be updated in case they are no longer * affected by this entry. */ - backend_shr_update_references(cbdata.state, pb, cbdata.e, NULL); + backend_shr_update_references(cbdata.state, pb, cbdata.e, NULL, NULL); map_unlock(); wrap_dec_call_level(); return 0; |