22 #define BEST_EFFORT_STATUS 0 33 dump_xml_for_digest(xmlNodePtr xml)
35 GString *buffer = g_string_sized_new(1024);
38 g_string_append_c(buffer,
' ');
40 g_string_append_c(buffer,
'\n');
56 calculate_xml_digest_v1(xmlNode *
input, gboolean sort, gboolean ignored)
59 GString *buffer = NULL;
69 buffer = dump_xml_for_digest(
input);
71 g_string_free(buffer, TRUE);
74 digest =
crm_md5sum((
const char *) buffer->str);
77 g_string_free(buffer, TRUE);
91 calculate_xml_digest_v2(
const xmlNode *source, gboolean do_filter)
94 GString *buf = g_string_sized_new(1024);
96 crm_trace(
"Begin digest %s", do_filter?
"filtered":
"");
117 g_string_free(buf, TRUE);
136 return calculate_xml_digest_v1(
input, FALSE, FALSE);
151 return calculate_xml_digest_v1(
input, TRUE, FALSE);
166 gboolean do_filter,
const char *
version)
181 crm_trace(
"Using v1 digest algorithm for %s",
182 pcmk__s(
version,
"unknown feature set"));
183 return calculate_xml_digest_v1(
input, sort, do_filter);
185 crm_trace(
"Using v2 digest algorithm for %s",
186 pcmk__s(
version,
"unknown feature set"));
187 return calculate_xml_digest_v2(
input, do_filter);
202 char *calculated = NULL;
207 if (calculated == NULL) {
208 crm_perror(LOG_ERR,
"Could not calculate digest for comparison");
214 crm_trace(
"Digest comparison passed: %s", calculated);
216 crm_err(
"Digest comparison failed: expected %s, calculated %s",
217 expected, calculated);
234 static const char *filter[] = {
243 if (strcmp(
name, filter[i]) == 0) {
253 int lpc = 0, len = 0;
257 if (buffer == NULL) {
260 len = strlen(buffer);
262 crm_trace(
"Beginning digest of %d bytes", len);
267 sprintf(digest + (2 * lpc),
"%02x", raw_digest[lpc]);
273 crm_err(
"Could not create digest");
280 should_filter_for_digest(xmlAttrPtr a,
void *user_data)
282 if (strncmp((
const char *) a->name,
CRM_META "_",
307 guint interval_ms = 0;
309 if (param_set == NULL) {
322 if (interval_ms != 0) {
#define CRM_CHECK(expr, failure_action)
#define pcmk__if_tracing(if_action, else_action)
#define PCMK_XA_UPDATE_ORIGIN
void save_xml_to_file(const xmlNode *xml, const char *desc, const char *filename)
void pcmk__xml_string(const xmlNode *data, uint32_t options, GString *buffer, int depth)
char * calculate_on_disk_digest(xmlNode *input)
Calculate and return digest of XML tree, suitable for storing on disk.
Exclude certain XML attributes (for calculating digests)
#define PCMK_XA_NUM_UPDATES
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
#define PCMK_XA_CIB_LAST_WRITTEN
#define PCMK__META_ON_NODE
void pcmk__filter_op_for_digest(xmlNode *param_set)
int crm_element_value_ms(const xmlNode *data, const char *name, guint *dest)
Retrieve the millisecond value of an XML attribute.
char * crm_element_value_copy(const xmlNode *data, const char *name)
Retrieve a copy of the value of an XML attribute.
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
void pcmk__xe_remove_matching_attrs(xmlNode *element, bool(*match)(xmlAttrPtr, void *), void *user_data)
#define PCMK__XA_OP_DIGEST
#define crm_trace(fmt, args...)
#define PCMK_XA_UPDATE_USER
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1
#define PCMK__META_ON_NODE_UUID
Wrappers for and extensions to libxml2.
bool pcmk__xa_filterable(const char *name)
void free_xml(xmlNode *child)
bool pcmk__str_any_of(const char *s,...) G_GNUC_NULL_TERMINATED
char * calculate_xml_versioned_digest(xmlNode *input, gboolean sort, gboolean do_filter, const char *version)
Calculate and return digest of XML tree.
#define PCMK_META_TIMEOUT
xmlNode * sorted_xml(xmlNode *input, xmlNode *parent, gboolean recursive)
#define PCMK_XA_CRM_FEATURE_SET
const char * pcmk__get_tmpdir(void)
bool pcmk__verify_digest(xmlNode *input, const char *expected)
#define PCMK_META_INTERVAL
#define crm_perror(level, fmt, args...)
Send a system error message to both the log and stderr.
#define crm_err(fmt, args...)
int compare_version(const char *version1, const char *version2)
char * calculate_operation_digest(xmlNode *input, const char *version)
Calculate and return digest of XML operation.
void * md5_buffer(const char *buffer, size_t len, void *resblock)
#define crm_log_xml_trace(xml, text)
char * crm_md5sum(const char *buffer)
#define PCMK_XA_ADMIN_EPOCH
#define PCMK_XA_CRM_DEBUG_ORIGIN
#define PCMK_XA_UPDATE_CLIENT
char * crm_meta_name(const char *field)
Get the environment variable equivalent of a meta-attribute name.