summaryrefslogtreecommitdiffstats
path: root/lib/common/acl.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/common/acl.c')
-rw-r--r--lib/common/acl.c41
1 files changed, 19 insertions, 22 deletions
diff --git a/lib/common/acl.c b/lib/common/acl.c
index 33a4e00..1ebd765 100644
--- a/lib/common/acl.c
+++ b/lib/common/acl.c
@@ -26,7 +26,7 @@
typedef struct xml_acl_s {
enum xml_private_flags mode;
- char *xpath;
+ gchar *xpath;
} xml_acl_t;
static void
@@ -35,7 +35,7 @@ free_acl(void *data)
if (data) {
xml_acl_t *acl = data;
- free(acl->xpath);
+ g_free(acl->xpath);
free(acl);
}
}
@@ -68,7 +68,7 @@ create_acl(const xmlNode *xml, GList *acls, enum xml_private_flags mode)
if ((tag == NULL) && (ref == NULL) && (xpath == NULL)) {
// Schema should prevent this, but to be safe ...
crm_trace("Ignoring ACL <%s> element without selection criteria",
- crm_element_name(xml));
+ xml->name);
return NULL;
}
@@ -77,10 +77,9 @@ create_acl(const xmlNode *xml, GList *acls, enum xml_private_flags mode)
acl->mode = mode;
if (xpath) {
- acl->xpath = strdup(xpath);
- CRM_ASSERT(acl->xpath != NULL);
+ acl->xpath = g_strdup(xpath);
crm_trace("Unpacked ACL <%s> element using xpath: %s",
- crm_element_name(xml), acl->xpath);
+ xml->name, acl->xpath);
} else {
GString *buf = g_string_sized_new(128);
@@ -101,12 +100,11 @@ create_acl(const xmlNode *xml, GList *acls, enum xml_private_flags mode)
pcmk__g_strcat(buf, "//", pcmk__s(tag, "*"), NULL);
}
- acl->xpath = strdup((const char *) buf->str);
- CRM_ASSERT(acl->xpath != NULL);
+ acl->xpath = buf->str;
- g_string_free(buf, TRUE);
+ g_string_free(buf, FALSE);
crm_trace("Unpacked ACL <%s> element as xpath: %s",
- crm_element_name(xml), acl->xpath);
+ xml->name, acl->xpath);
}
return g_list_append(acls, acl);
@@ -131,10 +129,10 @@ parse_acl_entry(const xmlNode *acl_top, const xmlNode *acl_entry, GList *acls)
for (child = pcmk__xe_first_child(acl_entry); child;
child = pcmk__xe_next(child)) {
- const char *tag = crm_element_name(child);
+ const char *tag = (const char *) child->name;
const char *kind = crm_element_value(child, XML_ACL_ATTR_KIND);
- if (strcmp(XML_ACL_TAG_PERMISSION, tag) == 0){
+ if (pcmk__xe_is(child, XML_ACL_TAG_PERMISSION)) {
CRM_ASSERT(kind != NULL);
crm_trace("Unpacking ACL <%s> element of kind '%s'", tag, kind);
tag = kind;
@@ -157,7 +155,7 @@ parse_acl_entry(const xmlNode *acl_top, const xmlNode *acl_entry, GList *acls)
if (role_id && strcmp(ref_role, role_id) == 0) {
crm_trace("Unpacking referenced role '%s' in ACL <%s> element",
- role_id, crm_element_name(acl_entry));
+ role_id, acl_entry->name);
acls = parse_acl_entry(acl_top, role, acls);
break;
}
@@ -304,10 +302,9 @@ pcmk__unpack_acl(xmlNode *source, xmlNode *target, const char *user)
for (child = pcmk__xe_first_child(acls); child;
child = pcmk__xe_next(child)) {
- const char *tag = crm_element_name(child);
- if (!strcmp(tag, XML_ACL_TAG_USER)
- || !strcmp(tag, XML_ACL_TAG_USERv1)) {
+ if (pcmk__xe_is(child, XML_ACL_TAG_USER)
+ || pcmk__xe_is(child, XML_ACL_TAG_USERv1)) {
const char *id = crm_element_value(child, XML_ATTR_NAME);
if (id == NULL) {
@@ -318,7 +315,7 @@ pcmk__unpack_acl(xmlNode *source, xmlNode *target, const char *user)
crm_debug("Unpacking ACLs for user '%s'", id);
docpriv->acls = parse_acl_entry(acls, child, docpriv->acls);
}
- } else if (!strcmp(tag, XML_ACL_TAG_GROUP)) {
+ } else if (pcmk__xe_is(child, XML_ACL_TAG_GROUP)) {
const char *id = crm_element_value(child, XML_ATTR_NAME);
if (id == NULL) {
@@ -392,7 +389,7 @@ purge_xml_attributes(xmlNode *xml)
if (test_acl_mode(nodepriv->flags, pcmk__xf_acl_read)) {
crm_trace("%s[@" XML_ATTR_ID "=%s] is readable",
- crm_element_name(xml), ID(xml));
+ xml->name, ID(xml));
return true;
}
@@ -571,22 +568,22 @@ pcmk__apply_creation_acl(xmlNode *xml, bool check_top)
if (implicitly_allowed(xml)) {
crm_trace("Creation of <%s> scaffolding with id=\"%s\""
" is implicitly allowed",
- crm_element_name(xml), display_id(xml));
+ xml->name, display_id(xml));
} else if (pcmk__check_acl(xml, NULL, pcmk__xf_acl_write)) {
crm_trace("ACLs allow creation of <%s> with id=\"%s\"",
- crm_element_name(xml), display_id(xml));
+ xml->name, display_id(xml));
} else if (check_top) {
crm_trace("ACLs disallow creation of <%s> with id=\"%s\"",
- crm_element_name(xml), display_id(xml));
+ xml->name, display_id(xml));
pcmk_free_xml_subtree(xml);
return;
} else {
crm_notice("ACLs would disallow creation of %s<%s> with id=\"%s\"",
((xml == xmlDocGetRootElement(xml->doc))? "root element " : ""),
- crm_element_name(xml), display_id(xml));
+ xml->name, display_id(xml));
}
}