From 653e2b3c2802fbdf1179f37b782c071311630fc0 Mon Sep 17 00:00:00 2001 From: Ken Gaillot Date: Mar 09 2021 06:18:41 +0000 Subject: Low: scheduler: treat missing parameter as NULL in rules with value-source Previously, if value-source were set to "param" or "meta", and an affected resource did not have the specified parameter, the parameter name would wrongly be used as the value to compare against. Now, use NULL as the value to compare against. patch_name: 009-digests.patch present_in_specfile: true location_in_specfile: 9 squash_commits: true --- diff --git a/lib/pengine/rules.c b/lib/pengine/rules.c index 1bd807f..e5d452f 100644 --- a/lib/pengine/rules.c +++ b/lib/pengine/rules.c @@ -1041,6 +1041,7 @@ pe__eval_attr_expr(xmlNodePtr expr, pe_rule_eval_data_t *rule_data) gboolean attr_allocated = FALSE; const char *h_val = NULL; GHashTable *table = NULL; + bool literal = true; const char *op = NULL; const char *type = NULL; @@ -1071,18 +1072,22 @@ pe__eval_attr_expr(xmlNodePtr expr, pe_rule_eval_data_t *rule_data) } if (pcmk__str_eq(value_source, "param", pcmk__str_casei)) { + literal = false; table = rule_data->match_data->params; } else if (pcmk__str_eq(value_source, "meta", pcmk__str_casei)) { + literal = false; table = rule_data->match_data->meta; } } - if (table) { + if (!literal) { const char *param_name = value; const char *param_value = NULL; - if (param_name && param_name[0]) { - if ((param_value = (const char *)g_hash_table_lookup(table, param_name))) { + value = NULL; + if ((table != NULL) && !pcmk__str_empty(param_name)) { + param_value = (const char *)g_hash_table_lookup(table, param_name); + if (param_value != NULL) { value = param_value; } }