}
if (vp->vp_edit) {
- RWDEBUG("Attribute cannot be removed, as it is being used in a 'foreach' loop - %pP", vp);
- continue;
+ REDEBUG("Attribute cannot be removed, as it is being used in a 'foreach' loop - %pP", vp);
+ return -1;
}
if (fr_edit_list_pair_delete(current->el, list, vp) < 0) {
+ RPEDEBUG("Failed deleting attribute");
tmpl_dcursor_clear(&cc);
return -1;
}
/*
* Delete all of them. We'll create one later for the SET operation.
*/
- if (fr_edit_list_pair_delete(current->el, &parent->vp_group, vp) < 0) return -1;
+ if (fr_edit_list_pair_delete(current->el, &parent->vp_group, vp) < 0) {
+ RPWDEBUG("Failed deleting attribute");
+ return -1;
+ }
tmpl_dcursor_clear(&cc);
}
* No need to save the value.
*/
case FR_EDIT_VALUE:
+ if (fr_pair_immutable(vp)) {
+ fr_strerror_printf("Cannot modify immutable value for %s", vp->da->name);
+ return -1;
+ }
return 0;
/*
* No need to save the value.
*/
case FR_EDIT_DELETE:
+ /*
+ * We silently refuse to delete immutable attributes.
+ */
+ if (fr_pair_immutable(vp)) return 0;
+
+ if (vp->vp_edit) {
+ vp_edit_error:
+ fr_strerror_printf("Attribute cannot be removed, as it is being used in a 'foreach' loop - %pP", vp);
+ return -1;
+ }
+
fr_pair_remove(list, vp);
return 0;
* which has been deleted!
*/
e->op = FR_EDIT_DELETE;
+ fr_assert(!e->vp->vp_edit);
fr_dlist_remove(&el->undo, e);
goto delete;
case FR_EDIT_DELETE:
delete:
+ /*
+ * We silently refuse to delete immutable attributes.
+ */
+ if (fr_pair_immutable(e->vp)) {
+ talloc_free(e);
+ return 0;
+ }
+
+ if (e->vp->vp_edit) {
+ talloc_free(e);
+ goto vp_edit_error;
+ }
+
fr_assert(list != NULL);
fr_assert(ref == NULL);
*/
int fr_edit_list_pair_delete(fr_edit_list_t *el, fr_pair_list_t *list, fr_pair_t *vp)
{
- if (fr_pair_immutable(vp)) {
- fr_strerror_printf("Cannot modify immutable value for %s", vp->da->name);
- return -1;
- }
-
if (!el) {
fr_pair_delete(list, vp);
return 0;
* Delete all VPs with a matching da.
*/
fr_pair_list_foreach(list, vp) {
- if (fr_pair_immutable(vp)) continue;
-
if (vp->da != da) continue;
- (void) fr_pair_remove(list, vp);
-
if (edit_record(el, FR_EDIT_DELETE, vp, list, NULL) < 0) return -1;
}
{
if (!fr_type_is_leaf(vp->vp_type)) return -1;
- if (vp->vp_immutable) {
- fr_strerror_printf("Cannot modify immutable value for %s", vp->da->name);
- return -1;
- }
-
if (el && (edit_record(el, FR_EDIT_VALUE, vp, NULL, NULL) < 0)) return -1;
if (!fr_type_is_fixed_size(vp->vp_type)) fr_value_box_clear(&vp->data);
{
if (to_replace->da != vp->da) return -1;
- if (fr_pair_immutable(to_replace)) {
- fr_strerror_printf("Cannot modify immutable value for %s", vp->da->name);
- return -1;
- }
-
if (!el) {
if (fr_pair_insert_after(list, to_replace, vp) < 0) return -1;
fr_pair_delete(list, to_replace);