File pacemaker-libcrmcommon-filter-attributes.patch of Package pacemaker.14737
commit d8f99a0c06124011595b2392018ba0300505dc73
Author: Ken Gaillot <kgaillot@redhat.com>
Date: Fri Apr 7 15:40:11 2017 -0500
Fix: libcrmcommon: filter attributes with '#' from XML fields
The PE passes node attributes to fence agents using hash2metafield(),
but this would generate invalid XML syntax with per-operation fail counts,
which contain '#'. Cluster-generated attributes aren't intended to be passed
anyway, so just filter such names out when adding to XML.
diff --git a/lib/common/xml.c b/lib/common/xml.c
index 0ea33d956..b313ad9d0 100644
--- a/lib/common/xml.c
+++ b/lib/common/xml.c
@@ -4903,10 +4903,15 @@ hash2metafield(gpointer key, gpointer value, gpointer user_data)
if (key == NULL || value == NULL) {
return;
- } else if (((char *)key)[0] == '#') {
- return;
- } else if (strstr(key, ":")) {
- return;
+ }
+
+ /* Filter out cluster-generated attributes that contain a '#' or ':'
+ * (like fail-count and last-failure).
+ */
+ for (crm_name = key; *crm_name; ++crm_name) {
+ if ((*crm_name == '#') || (*crm_name == ':')) {
+ return;
+ }
}
crm_name = crm_meta_name(key);
diff --git a/pengine/graph.c b/pengine/graph.c
index 2dba08eee..550937de0 100644
--- a/pengine/graph.c
+++ b/pengine/graph.c
@@ -1137,6 +1137,12 @@ action2xml(action_t * action, gboolean as_input, pe_working_set_t *data_set)
}
} else if (safe_str_eq(action->task, CRM_OP_FENCE) && action->node) {
+ /* Pass the node's attributes as meta-attributes.
+ *
+ * @TODO: Determine whether it is still necessary to do this. It was
+ * added in 33d99707, probably for the libfence-based implementation in
+ * c9a90bd, which is no longer used.
+ */
g_hash_table_foreach(action->node->details->attrs, hash2metafield, args_xml);
}