Skip to content

Commit

Permalink
Check leaf is writable before allowing edit
Browse files Browse the repository at this point in the history
When running edit-config operation on a leaf node, check that its
schema node is writable, if not abort with an error.
  • Loading branch information
tony-vanderpeet authored and carlgsmith committed Sep 6, 2023
1 parent 725212d commit 0c5be6c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions schema.c
Original file line number Diff line number Diff line change
Expand Up @@ -2951,6 +2951,17 @@ _sch_xml_to_gnode (_sch_xml_to_gnode_parms *_parms, sch_node * schema, xmlNs *ns
/* LEAF */
else
{
/* Check that this leaf is writable */
if (_parms->in_is_edit && !sch_is_writable (schema))
{
DEBUG (_parms->in_flags, "Attempt to edit non-writable node \"%s\"\n", name);
apteryx_free_tree (tree);
_parms->out_error.tag = NC_ERR_TAG_INVALID_VAL;
_parms->out_error.type = NC_ERR_TYPE_PROTOCOL;
tree = NULL;
goto exit;
}

if (g_strcmp0 (new_op, "delete") != 0 && g_strcmp0 (new_op, "remove") != 0 &&
g_strcmp0 (new_op, "none") != 0)
{
Expand Down

0 comments on commit 0c5be6c

Please sign in to comment.