Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
531a838
Refactor: libcrmcommon: Make pcmk__unpack_acls() static
nrwahl2 Dec 29, 2025
8ce5b37
Refactor: libcrmcommon: Unindent xml_acl_disable()
nrwahl2 Dec 29, 2025
93b9040
Refactor: libcrmcommon: New pcmk__xml_doc_clear_flags()
nrwahl2 Dec 29, 2025
678bc08
Refactor: libcrmcommon: Simplify xml_acl_denied()
nrwahl2 Dec 29, 2025
90826ce
Refactor: libcrmcommon: Drop xml_acl_denied() internally
nrwahl2 Dec 29, 2025
9510745
API: libcrmcommon: Deprecate xml_acl_denied()
nrwahl2 Dec 29, 2025
adf8732
Refactor: libcrmcommon: New pcmk__acl_required()
nrwahl2 Dec 29, 2025
7959304
API: libcrmcommon: Deprecate pcmk_acl_required()
nrwahl2 Dec 29, 2025
c3811ab
Refactor: libcrmcommon: Move pcmk__is_user_in_group_test.c to utils
nrwahl2 Dec 29, 2025
9ac2567
Refactor: libcrmcommon: Functionize appending XML-escaped character
nrwahl2 Dec 30, 2025
92b57fe
Refactor: libcrmcommon: Functionize XML escape append modes
nrwahl2 Dec 30, 2025
e8e0116
Refactor: libcrmcommon: Drop pcmk__xml_needs_escape()
nrwahl2 Dec 30, 2025
664d6c3
Refactor: libcrmcommon: New pcmk__xml_foreach_child()
nrwahl2 Dec 30, 2025
ad74728
Refactor: libcrmcommon: Functionize check/set matching XML children
nrwahl2 Dec 30, 2025
b298968
Refactor: libcrmcommon: Use foreach_child for find_matching_children
nrwahl2 Dec 30, 2025
0db5d75
Refactor: libcrmcommon: Functionize marking child changed or deleted
nrwahl2 Dec 30, 2025
d6017ae
Refactor: libcrmcommon: Functionize marking child moved or created
nrwahl2 Dec 30, 2025
e4016c3
Refactor: libcrmcommon: Functionize marking child as created
nrwahl2 Dec 30, 2025
fb7199d
Refactor: libcrmcommon: Defunctionize mark_xml_tree_dirty_created()
nrwahl2 Dec 30, 2025
014ba16
Refactor: libcrmcommon: Expose reset_doc_private_data() as lib-private
nrwahl2 Dec 30, 2025
e9694f9
Refactor: libcrmcommon: Expose free_xml_with_position() as lib-private
nrwahl2 Dec 30, 2025
992a91b
Refactor: libcrmcommon: Split XML change code into its own file
nrwahl2 Dec 30, 2025
4b6a2f2
Refactor: libcrmcommon: Drop pcmk__xe_set_props()
nrwahl2 Dec 30, 2025
ab61cf8
Refactor: libpe_status: Return void from pe__name_and_nvpairs_xml()
nrwahl2 Dec 30, 2025
f53421a
Refactor: libpe_status: Drop pe__name_and_nvpairs_xml()
nrwahl2 Dec 30, 2025
a633f18
Refactor: libcrmcommon: pcmk__output_xml_create_parent() drops list arg
nrwahl2 Dec 30, 2025
d487f93
Refactor: libcrmcommon: pcmk__output_create_xml_node() drops list arg
nrwahl2 Dec 31, 2025
31bb528
Refactor: libpe_status: Drop a pcmk__itoa() call
nrwahl2 Dec 31, 2025
78a4936
Refactor: libcrmcommon: Drop pcmk__xe_set_propv()
nrwahl2 Dec 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions daemons/controld/controld_join_dc.c
Original file line number Diff line number Diff line change
Expand Up @@ -962,11 +962,9 @@ finalize_join_for(void *key, void *value, void *user_data)
}

remote = pcmk__xe_create(remotes, PCMK_XE_NODE);
pcmk__xe_set_props(remote,
PCMK_XA_ID, node->name,
PCMK__XA_NODE_STATE, node->state,
PCMK__XA_CONNECTION_HOST, node->conn_host,
NULL);
pcmk__xe_set(remote, PCMK_XA_ID, node->name);
pcmk__xe_set(remote, PCMK__XA_NODE_STATE, node->state);
pcmk__xe_set(remote, PCMK__XA_CONNECTION_HOST, node->conn_host);
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions daemons/pacemakerd/pacemakerd.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ PCMK__OUTPUT_ARGS("features")
static int
pacemakerd_features_xml(pcmk__output_t *out, va_list args) {
gchar **feature_list = g_strsplit(CRM_FEATURES, " ", 0);
xmlNode *xml = pcmk__output_xml_create_parent(out, PCMK_XE_PACEMAKERD);

pcmk__xe_set(xml, PCMK_XA_VERSION, PACEMAKER_VERSION);
pcmk__xe_set(xml, PCMK_XA_BUILD, BUILD_VERSION);
pcmk__xe_set(xml, PCMK_XA_FEATURE_SET, CRM_FEATURE_SET);

pcmk__output_xml_create_parent(out, PCMK_XE_PACEMAKERD,
PCMK_XA_VERSION, PACEMAKER_VERSION,
PCMK_XA_BUILD, BUILD_VERSION,
PCMK_XA_FEATURE_SET, CRM_FEATURE_SET,
NULL);
out->begin_list(out, NULL, NULL, PCMK_XE_FEATURES);

for (char **s = feature_list; *s != NULL; s++) {
Expand Down
3 changes: 0 additions & 3 deletions include/crm/common/acl.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ extern "C" {
*/

void xml_acl_disable(xmlNode *xml);
bool xml_acl_denied(const xmlNode *xml);

bool pcmk_acl_required(const char *user);

#ifdef __cplusplus
}
Expand Down
6 changes: 6 additions & 0 deletions include/crm/common/acl_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ bool xml_acl_enabled(const xmlNode *xml);
bool xml_acl_filtered_copy(const char *user, xmlNode *acl_source, xmlNode *xml,
xmlNode **result);

//! \deprecated Do not use
bool xml_acl_denied(const xmlNode *xml);

//! \deprecated Do not use
bool pcmk_acl_required(const char *user);

#ifdef __cplusplus
}
#endif
Expand Down
15 changes: 15 additions & 0 deletions include/crm/common/acl_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ pcmk__is_privileged(const char *user)
return user && (!strcmp(user, CRM_DAEMON_USER) || !strcmp(user, "root"));
}

/*!
* \internal
* \brief Check whether an ACL is required for a given user to access the CIB
*
* \param[in] user User name
*
* \return \c true if \p user requires an ACL to access the CIB, or \c false
* otherwise
*/
static inline bool
pcmk__acl_required(const char *user)
{
return !pcmk__str_empty(user) && !pcmk__is_privileged(user);
}

void pcmk__enable_acls(xmlDoc *source, xmlDoc *target, const char *user);

xmlNode *pcmk__acl_filtered_copy(const char *user, xmlDoc *acl_source,
Expand Down
12 changes: 4 additions & 8 deletions include/crm/common/output_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -757,11 +757,9 @@ void pcmk__output_set_log_filter(pcmk__output_t *out, const char *file,
*
* \param[in,out] out The output functions structure.
* \param[in] name The name of the node to be created.
* \param[in] ... Name/value pairs to set as XML properties.
*/
xmlNodePtr
pcmk__output_xml_create_parent(pcmk__output_t *out, const char *name, ...)
G_GNUC_NULL_TERMINATED;
xmlNode *
pcmk__output_xml_create_parent(pcmk__output_t *out, const char *name);

/*!
* \internal
Expand All @@ -781,11 +779,9 @@ pcmk__output_xml_add_node_copy(pcmk__output_t *out, xmlNodePtr node);
*
* \param[in,out] out The output functions structure.
* \param[in] name The name of the node to be created.
* \param[in] ... Name/value pairs to set as XML properties.
*/
xmlNodePtr
pcmk__output_create_xml_node(pcmk__output_t *out, const char *name, ...)
G_GNUC_NULL_TERMINATED;
xmlNode *
pcmk__output_create_xml_node(pcmk__output_t *out, const char *name);

/*!
* \internal
Expand Down
25 changes: 0 additions & 25 deletions include/crm/common/xml_element_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,31 +85,6 @@ void pcmk__xe_sort_attrs(xmlNode *xml);
void pcmk__xe_set_id(xmlNode *xml, const char *format, ...)
G_GNUC_PRINTF(2, 3);

/*!
* \internal
* \brief Like pcmk__xe_set_props, but takes a va_list instead of
* arguments directly.
*
* \param[in,out] node XML to add attributes to
* \param[in] pairs NULL-terminated list of name/value pairs to add
*/
void
pcmk__xe_set_propv(xmlNodePtr node, va_list pairs);

/*!
* \internal
* \brief Add a NULL-terminated list of name/value pairs to the given
* XML node as properties.
*
* \param[in,out] node XML node to add properties to
* \param[in] ... NULL-terminated list of name/value pairs
*
* \note A NULL name terminates the arguments; a NULL value will be skipped.
*/
void
pcmk__xe_set_props(xmlNodePtr node, ...)
G_GNUC_NULL_TERMINATED;

/*!
* \internal
* \brief Get first attribute of an XML element
Expand Down
7 changes: 3 additions & 4 deletions include/crm/common/xml_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <crm/common/xml_idref_internal.h>
#include <crm/common/xml_io_internal.h>
#include <crm/common/xml_names_internal.h>
#include <crm/common/xml_tracking_internal.h>
#include <crm/common/xpath_internal.h>

#include <libxml/relaxng.h>
Expand Down Expand Up @@ -260,7 +261,6 @@ enum pcmk__xml_escape_type {
pcmk__xml_escape_attr_pretty,
};

bool pcmk__xml_needs_escape(const char *text, enum pcmk__xml_escape_type type);
char *pcmk__xml_escape(const char *text, enum pcmk__xml_escape_type type);

/*!
Expand Down Expand Up @@ -427,9 +427,8 @@ enum pcmk__xml_flags {
void pcmk__xml_doc_set_flags(xmlDoc *doc, uint32_t flags);
bool pcmk__xml_doc_all_flags_set(const xmlDoc *xml, uint32_t flags);

void pcmk__xml_commit_changes(xmlDoc *doc);
void pcmk__xml_mark_changes(xmlNode *old_xml, xmlNode *new_xml);

bool pcmk__xml_foreach_child(xmlNode *xml, bool (*fn)(xmlNode *, void *),
void *user_data);
bool pcmk__xml_tree_foreach(xmlNode *xml, bool (*fn)(xmlNode *, void *),
void *user_data);

Expand Down
30 changes: 30 additions & 0 deletions include/crm/common/xml_tracking_internal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright 2017-2025 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
* This source code is licensed under the GNU Lesser General Public License
* version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
*/

#ifndef PCMK__CRM_COMMON_XML_TRACKING_INTERNAL__H
#define PCMK__CRM_COMMON_XML_TRACKING_INTERNAL__H

/*
* Internal-only functions for tracking, calculating, and committing XML changes
*/

#include <libxml/tree.h> // xmlDoc, xmlNode

#ifdef __cplusplus
extern "C" {
#endif

void pcmk__xml_mark_changes(xmlNode *old_xml, xmlNode *new_xml);
void pcmk__xml_commit_changes(xmlDoc *doc);

#ifdef __cplusplus
}
#endif

#endif // PCMK__CRM_COMMON_XML_TRACKING_INTERNAL__H
2 changes: 0 additions & 2 deletions include/crm/pengine/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ gchar *pcmk__native_output_string(const pcmk_resource_t *rsc, const char *name,
const pcmk_node_t *node, uint32_t show_opts,
const char *target_role, bool show_nodes);

int pe__name_and_nvpairs_xml(pcmk__output_t *out, bool is_list, const char *tag_name,
...) G_GNUC_NULL_TERMINATED;
char *pe__node_display_name(pcmk_node_t *node, bool print_detail);


Expand Down
10 changes: 4 additions & 6 deletions lib/cib/cib_remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -505,12 +505,10 @@ cib_tls_signon(cib_t *cib, pcmk__remote_t *connection, gboolean event_channel)

/* login to server */
login = pcmk__xe_create(NULL, PCMK__XE_CIB_COMMAND);
pcmk__xe_set_props(login,
PCMK_XA_OP, "authenticate",
PCMK_XA_USER, private->user,
PCMK__XA_PASSWORD, private->passwd,
PCMK__XA_HIDDEN, PCMK__VALUE_PASSWORD,
NULL);
pcmk__xe_set(login, PCMK_XA_OP, "authenticate");
pcmk__xe_set(login, PCMK_XA_USER, private->user);
pcmk__xe_set(login, PCMK__XA_PASSWORD, private->passwd);
pcmk__xe_set(login, PCMK__XA_HIDDEN, PCMK__VALUE_PASSWORD);

pcmk__remote_send_xml(connection, login);
pcmk__xml_free(login);
Expand Down
4 changes: 2 additions & 2 deletions lib/cib/cib_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ cib_acl_enabled(xmlNode *xml, const char *user)
GHashTable *options = NULL;
bool rc = false;

if ((xml == NULL) || !pcmk_acl_required(user)) {
if ((xml == NULL) || !pcmk__acl_required(user)) {
return false;
}

Expand Down Expand Up @@ -579,7 +579,7 @@ cib__perform_op_rw(enum cib_variant variant, cib__op_fn_t fn, xmlNode *req,
// Allow ourselves to make any additional necessary changes
xml_acl_disable(*cib);

if (xml_acl_denied(*cib)) {
if (pcmk__xml_doc_all_flags_set((*cib)->doc, pcmk__xf_acl_denied)) {
pcmk__trace("ACL rejected part or all of the proposed changes");
rc = EACCES;
goto done;
Expand Down
1 change: 1 addition & 0 deletions lib/common/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ libcrmcommon_la_SOURCES += xml_display.c
libcrmcommon_la_SOURCES += xml_element.c
libcrmcommon_la_SOURCES += xml_idref.c
libcrmcommon_la_SOURCES += xml_io.c
libcrmcommon_la_SOURCES += xml_tracking.c
libcrmcommon_la_SOURCES += xpath.c

#
Expand Down
Loading