This file is indexed.

/usr/include/pacemaker/crm/compatibility.h is in libcrmcommon-dev 1.1.16-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
/*
 * Copyright (C) 2012 Andrew Beekhof <andrew@beekhof.net>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
#ifndef CRM_COMPATIBILITY__H
#  define CRM_COMPATIBILITY__H
#  define LOG_DEBUG_2  LOG_TRACE
#  define LOG_DEBUG_3  LOG_TRACE
#  define LOG_DEBUG_4  LOG_TRACE
#  define LOG_DEBUG_5  LOG_TRACE
#  define LOG_DEBUG_6  LOG_TRACE

#  define XML_CIB_ATTR_HASTATE         "ha"
#  define XML_CIB_ATTR_JOINSTATE       XML_NODE_JOIN_STATE
#  define XML_CIB_ATTR_EXPSTATE        XML_NODE_EXPECTED
#  define XML_CIB_ATTR_INCCM           XML_NODE_IN_CLUSTER
#  define XML_CIB_ATTR_CRMDSTATE       XML_NODE_IS_PEER

#  define CRMD_STATE_ACTIVE            CRMD_JOINSTATE_MEMBER
#  define CRMD_STATE_INACTIVE          CRMD_JOINSTATE_DOWN

#define pcmk_err_dtd_validation pcmk_err_schema_validation

/* *INDENT-OFF* */
enum cib_errors {
    cib_ok			=  pcmk_ok,
    cib_operation		= -EINVAL,
    cib_create_msg		= -EPROTO,
    cib_not_connected           = -ENOTCONN,
    cib_not_authorized          = -EACCES,
    cib_send_failed		= -ECOMM,
    cib_reply_failed            = -ENOMSG,
    cib_return_code		= -EPROTO,
    cib_output_data		= -ENOMSG,
    cib_connection		= -ENOTCONN,
    cib_authentication  	= -EPROTO,
    cib_missing 		= -EINVAL,
    cib_variant                 = -EPROTONOSUPPORT,
    CIBRES_MISSING_FIELD	= -EINVAL,
    cib_unknown                 = -EINVAL,
    cib_STALE                   = -ENOKEY,
    cib_EXISTS                  = -ENOTUNIQ,
    cib_NOTEXISTS		= -ENXIO,
    cib_ACTIVATION		= -ENODATA,
    cib_NOOBJECT		= -EINVAL,
    cib_NOPARENT		= -EINVAL,
    cib_NOTSUPPORTED            = -EPROTONOSUPPORT,
    cib_registration_msg	= -EPROTO,
    cib_callback_token          = -EPROTO,
    cib_callback_register	= -ECOMM,
    cib_client_gone		= -ECONNRESET,
    cib_not_master		= -EPERM,
    cib_missing_data            = -EINVAL,
    cib_remote_timeout          = -ETIME,
    cib_no_quorum		= -pcmk_err_no_quorum,
    cib_diff_failed		= -pcmk_err_diff_failed,
    cib_diff_resync		= -pcmk_err_diff_resync,
    cib_old_data		= -pcmk_err_old_data,
    cib_dtd_validation  	= -pcmk_err_schema_validation,
    cib_bad_section		= -EINVAL,
    cib_bad_permissions         = -EACCES,
    cib_invalid_argument	= -EINVAL,
    cib_transform_failed        = -pcmk_err_transform_failed,
    cib_permission_denied	= -EACCES,
};

enum stonith_errors {
    stonith_ok			=  pcmk_ok,
    stonith_pending		= -EINPROGRESS,
    st_err_generic		= -pcmk_err_generic,
    st_err_internal		= -EPROTO,
    st_err_not_supported	= -EPROTONOSUPPORT,
    st_err_connection		= -ENOTCONN,
    st_err_missing		= -EINVAL,
    st_err_exists		= -ENOTUNIQ,
    st_err_timeout		= -ETIME,
    st_err_ipc			= -ECOMM,
    st_err_peer			= -ENOMSG,
    st_err_unknown_operation	= -EOPNOTSUPP,
    st_err_unknown_device	= -ENODEV,
    st_err_none_available	= -EHOSTUNREACH,
    st_err_signal		= -ECONNABORTED,
    st_err_agent_fork		= -ECHILD,
    st_err_agent_args		= -EREMOTEIO,
    st_err_agent		= -ECONNABORTED,
    st_err_invalid_level	= -EINVAL,
};


enum lrmd_errors {
    lrmd_ok                      =  pcmk_ok,
    lrmd_pending                 = -EINPROGRESS,
    lrmd_err_generic             = -EPROTONOSUPPORT,
    lrmd_err_internal            = -EPROTO,
    lrmd_err_connection          = -ENOTCONN,
    lrmd_err_missing             = -EINVAL,
    lrmd_err_ipc                 = -ECOMM,
    lrmd_err_peer                = -ENOMSG,
    lrmd_err_unknown_operation   = -EOPNOTSUPP,
    lrmd_err_unknown_rsc         = -ENODEV,
    lrmd_err_no_metadata         = -EIO,
    lrmd_err_stonith_connection  = -EUNATCH,
    lrmd_err_provider_required   = -EINVAL,
};
/* *INDENT-ON* */

#  define stonith_error2string pcmk_strerror
#  define lrmd_error2string    pcmk_strerror
#  define cib_error2string     pcmk_strerror

static inline void
slist_basic_destroy(GListPtr list)
{
    GListPtr gIter = NULL;

    for (gIter = list; gIter != NULL; gIter = gIter->next) {
        free(gIter->data);
    }
    g_list_free(list);
}

#  define crm_strdup strdup
#  define set_bit_inplace set_bit
#  define clear_bit_inplace clear_bit

#  define crm_malloc0(malloc_obj, length) do {				\
	malloc_obj = malloc(length);					\
	if(malloc_obj == NULL) {					\
	    crm_err("Failed allocation of %lu bytes", (unsigned long)length); \
	    CRM_ASSERT(malloc_obj != NULL);				\
	}								\
	memset(malloc_obj, 0, length);					\
    } while(0)

#  define crm_malloc(malloc_obj, length) do {				\
	malloc_obj = malloc(length);					\
	if(malloc_obj == NULL) {					\
	    crm_err("Failed allocation of %lu bytes", (unsigned long)length); \
	    CRM_ASSERT(malloc_obj != NULL);				\
	}								\
    } while(0)

#  define crm_realloc(realloc_obj, length) do {				\
	realloc_obj = realloc(realloc_obj, length);			\
	CRM_ASSERT(realloc_obj != NULL);				\
    } while(0)

#  define crm_free(free_obj) do { free(free_obj); free_obj=NULL; } while(0)

/* These two child iterator macros are no longer to be used
 * They exist for compatibility reasons and will be removed in a
 * future release
 */
#  define xml_child_iter(parent, child, code) do {			\
	if(parent != NULL) {						\
		xmlNode *child = NULL;					\
		xmlNode *__crm_xml_iter = parent->children;		\
		while(__crm_xml_iter != NULL) {				\
			child = __crm_xml_iter;				\
			__crm_xml_iter = __crm_xml_iter->next;		\
			if(child->type == XML_ELEMENT_NODE) {		\
			    code;					\
			}						\
		}							\
	}								\
    } while(0)

#  define xml_child_iter_filter(parent, child, filter, code) do {	\
	if(parent != NULL) {						\
	    xmlNode *child = NULL;					\
	    xmlNode *__crm_xml_iter = parent->children;			\
	    while(__crm_xml_iter != NULL) {				\
		child = __crm_xml_iter;					\
		__crm_xml_iter = __crm_xml_iter->next;			\
		if(child->type == XML_ELEMENT_NODE) {			\
		    if(filter == NULL					\
		       || crm_str_eq(filter, (const char *)child->name, TRUE)) { \
			code;						\
		    }							\
		}							\
	    }								\
	}								\
    } while(0)

#  define xml_prop_iter(parent, prop_name, prop_value, code) do {	\
	if(parent != NULL) {						\
	    xmlAttrPtr prop_iter = parent->properties;			\
	    const char *prop_name = NULL;				\
	    const char *prop_value = NULL;				\
	    while(prop_iter != NULL) {					\
		prop_name = (const char *)prop_iter->name;		\
		prop_value = crm_element_value(parent, prop_name);	\
		prop_iter = prop_iter->next;				\
		if(prop_name) {						\
		    code;						\
		}							\
	    }								\
	}								\
    } while(0)

#  define xml_prop_name_iter(parent, prop_name, code) do {		\
	if(parent != NULL) {						\
	    xmlAttrPtr prop_iter = parent->properties;			\
	    const char *prop_name = NULL;				\
	    while(prop_iter != NULL) {					\
		prop_name = (const char *)prop_iter->name;		\
		prop_iter = prop_iter->next;				\
		if(prop_name) {						\
		    code;						\
		}							\
	    }								\
	}								\
    } while(0)

#  define zap_xml_from_parent(parent, xml_obj) free_xml(xml_obj); xml_obj = NULL

/* For ABI compatibility with version < 1.1.4 */
static inline char *
calculate_xml_digest(xmlNode * input, gboolean sort, gboolean do_filter)
{
    return calculate_xml_digest_v1(input, sort, do_filter);
}

static inline void
free_xml_from_parent(xmlNode * parent, xmlNode * a_node)
{
    free_xml(a_node);
}

/* Use something like this instead of the next macro:

    GListPtr gIter = rsc->children;
    for(; gIter != NULL; gIter = gIter->next) {
	resource_t *child_rsc = (resource_t*)gIter->data;
	...
    }
 */
#  define slist_destroy(child_type, child, parent, a) do {		\
	GListPtr __crm_iter_head = parent;				\
	child_type *child = NULL;					\
	while(__crm_iter_head != NULL) {				\
	    child = (child_type *) __crm_iter_head->data;		\
	    __crm_iter_head = __crm_iter_head->next;			\
	    { a; }							\
	}								\
	g_list_free(parent);						\
    } while(0)

#  ifdef CRM_ATTRD__H
static inline gboolean
attrd_update(crm_ipc_t * cluster, char command, const char *host, const char *name,
             const char *value, const char *section, const char *set, const char *dampen)
{
    return attrd_update_delegate(cluster, command, host, name, value, section, set, dampen,
                                 NULL, attrd_opt_none) > 0;
}

static inline gboolean
attrd_lazy_update(char command, const char *host, const char *name,
                  const char *value, const char *section, const char *set, const char *dampen)
{
    return attrd_update_delegate(NULL, command, host, name, value, section, set, dampen, NULL, attrd_opt_none) > 0;
}

static inline gboolean
attrd_update_no_mainloop(int *connection, char command, const char *host,
                         const char *name, const char *value, const char *section,
                         const char *set, const char *dampen)
{
    return attrd_update_delegate(NULL, command, host, name, value, section, set, dampen, NULL, attrd_opt_none) > 0;
}
#  endif

#  ifdef CIB_UTIL__H
static inline int
update_attr(cib_t * the_cib, int call_options,
            const char *section, const char *node_uuid, const char *set_type, const char *set_name,
            const char *attr_id, const char *attr_name, const char *attr_value, gboolean to_console)
{
    return update_attr_delegate(the_cib, call_options, section, node_uuid, set_type, set_name,
                                attr_id, attr_name, attr_value, to_console, NULL, NULL);
}

static inline int
find_nvpair_attr(cib_t * the_cib, const char *attr, const char *section, const char *node_uuid,
                 const char *set_type, const char *set_name, const char *attr_id,
                 const char *attr_name, gboolean to_console, char **value)
{
    return find_nvpair_attr_delegate(the_cib, attr, section, node_uuid, set_type,
                                     set_name, attr_id, attr_name, to_console, value, NULL);
}

static inline int
read_attr(cib_t * the_cib,
          const char *section, const char *node_uuid, const char *set_type, const char *set_name,
          const char *attr_id, const char *attr_name, char **attr_value, gboolean to_console)
{
    return read_attr_delegate(the_cib, section, node_uuid, set_type, set_name,
                              attr_id, attr_name, attr_value, to_console, NULL);
}

static inline int
delete_attr(cib_t * the_cib, int options,
            const char *section, const char *node_uuid, const char *set_type, const char *set_name,
            const char *attr_id, const char *attr_name, const char *attr_value, gboolean to_console)
{
    return delete_attr_delegate(the_cib, options, section, node_uuid, set_type, set_name,
                                attr_id, attr_name, attr_value, to_console, NULL);
}

static inline void
log_cib_diff(int log_level, xmlNode * diff, const char *function)
{
    xml_log_patchset(log_level, function, diff);
}

static inline gboolean
apply_cib_diff(xmlNode * old, xmlNode * diff, xmlNode ** new)
{
    *new = copy_xml(old);
    return (xml_apply_patchset(*new, diff, TRUE) == pcmk_ok);
}

#  endif

#  ifdef CRM_COMMON_XML__H
void
log_xml_diff(uint8_t log_level, xmlNode * diff, const char *function)
{
    xml_log_patchset(log_level, function, diff);
}
#  endif

#endif