Skip to content

Commit 5fe98f4

Browse files
committed
Fix: libcib: Don't match element based on XPath matching an attribute
A concrete example is clearer. Suppose the CIB contains the following constraint: <rsc_location id="cli-prefer-dummy" rsc="dummy" role="Promoted" node="laptop" score="INFINITY"/> Then a cibadmin --query for the score attribute outputs the entire rsc_location element: $ cibadmin --query --xpath '//@score' <rsc_location id="loc_cons" rsc="dummy" node="laptop" score="INFINITY"/> Similarly but worse, a cibadmin --delete command for the score attribute deletes the entire element. $ cibadmin --delete --xpath '//@score' $ cibadmin --query --xpath '//@score' Call failed: No such device or address Signed-off-by: Reid Wahl <[email protected]>
1 parent 89a4476 commit 5fe98f4

File tree

1 file changed

+0
-14
lines changed

1 file changed

+0
-14
lines changed

lib/cib/cib_ops.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -712,20 +712,6 @@ cib_process_xpath(const char *op, int options, const char *section,
712712
continue;
713713
}
714714

715-
/* @TODO This is a longstanding bug in the CIB API. If an XPath
716-
* expression matches a non-element node (for example, an attribute),
717-
* then we operate on the parent element. Similarly, if it matches the
718-
* document itself, then we operate on the root element (which at least
719-
* seems more reasonable).
720-
*
721-
* Some CIB operations might not make much sense for non-element nodes.
722-
* However, operating on a matched node's parent is surprising behavior.
723-
*/
724-
match = pcmk__xpath_match_element(match);
725-
if (match == NULL) {
726-
continue;
727-
}
728-
729715
path = xmlGetNodePath(match);
730716
crm_debug("Processing %s op for %s with %s", op, section, path);
731717
free(path);

0 commit comments

Comments
 (0)