5ee7c6
From 7618c29761368262fd8d633992816b52755ec028 Mon Sep 17 00:00:00 2001
5ee7c6
From: Hideo Yamauchi <renayama19661014@ybb.ne.jp>
5ee7c6
Date: Thu, 26 Apr 2018 12:51:06 +0900
5ee7c6
Subject: [PATCH] Mid: lib: Changed to lowercase comparison.
5ee7c6
5ee7c6
---
5ee7c6
 lib/cib/cib_attrs.c | 14 +++++++++-----
5ee7c6
 1 file changed, 9 insertions(+), 5 deletions(-)
5ee7c6
5ee7c6
diff --git a/lib/cib/cib_attrs.c b/lib/cib/cib_attrs.c
5ee7c6
index 8287a44..060d830 100644
5ee7c6
--- a/lib/cib/cib_attrs.c
5ee7c6
+++ b/lib/cib/cib_attrs.c
5ee7c6
@@ -471,17 +471,19 @@ get_uuid_from_result(xmlNode *result, char **uuid, int *is_remote)
5ee7c6
  * - guest node in resources section
5ee7c6
  * - orphaned remote node or bundle guest node in status section
5ee7c6
  */
5ee7c6
+#define XPATH_UPPER_TRANS "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
5ee7c6
+#define XPATH_LOWER_TRANS "abcdefghijklmnopqrstuvwxyz"
5ee7c6
 #define XPATH_NODE \
5ee7c6
     "/" XML_TAG_CIB "/" XML_CIB_TAG_CONFIGURATION "/" XML_CIB_TAG_NODES \
5ee7c6
-        "/" XML_CIB_TAG_NODE "[@" XML_ATTR_UNAME "='%s']" \
5ee7c6
+        "/" XML_CIB_TAG_NODE "[translate(@" XML_ATTR_UNAME ",'" XPATH_UPPER_TRANS "','" XPATH_LOWER_TRANS "') ='%s']" \
5ee7c6
     "|/" XML_TAG_CIB "/" XML_CIB_TAG_CONFIGURATION "/" XML_CIB_TAG_RESOURCES \
5ee7c6
         "/" XML_CIB_TAG_RESOURCE \
5ee7c6
-        "[@class='ocf'][@provider='pacemaker'][@type='remote'][@id='%s']" \
5ee7c6
+        "[@class='ocf'][@provider='pacemaker'][@type='remote'][translate(@id,'" XPATH_UPPER_TRANS "','" XPATH_LOWER_TRANS "') ='%s']" \
5ee7c6
     "|/" XML_TAG_CIB "/" XML_CIB_TAG_CONFIGURATION "/" XML_CIB_TAG_RESOURCES \
5ee7c6
         "/" XML_CIB_TAG_RESOURCE "/" XML_TAG_META_SETS "/" XML_CIB_TAG_NVPAIR \
5ee7c6
-        "[@name='" XML_RSC_ATTR_REMOTE_NODE "'][@value='%s']" \
5ee7c6
+        "[@name='" XML_RSC_ATTR_REMOTE_NODE "'][translate(@value,'" XPATH_UPPER_TRANS "','" XPATH_LOWER_TRANS "') ='%s']" \
5ee7c6
     "|/" XML_TAG_CIB "/" XML_CIB_TAG_STATUS "/" XML_CIB_TAG_STATE \
5ee7c6
-        "[@" XML_NODE_IS_REMOTE "='true'][@" XML_ATTR_UUID "='%s']"
5ee7c6
+        "[@" XML_NODE_IS_REMOTE "='true'][translate(@" XML_ATTR_UUID ",'" XPATH_UPPER_TRANS "','" XPATH_LOWER_TRANS "') ='%s']"
5ee7c6
 
5ee7c6
 int
5ee7c6
 query_node_uuid(cib_t * the_cib, const char *uname, char **uuid, int *is_remote_node)
5ee7c6
@@ -489,6 +491,7 @@ query_node_uuid(cib_t * the_cib, const char *uname, char **uuid, int *is_remote_
5ee7c6
     int rc = pcmk_ok;
5ee7c6
     char *xpath_string;
5ee7c6
     xmlNode *xml_search = NULL;
5ee7c6
+    char *host_lowercase = g_ascii_strdown(uname, -1);
5ee7c6
 
5ee7c6
     CRM_ASSERT(uname != NULL);
5ee7c6
 
5ee7c6
@@ -499,7 +502,7 @@ query_node_uuid(cib_t * the_cib, const char *uname, char **uuid, int *is_remote_
5ee7c6
         *is_remote_node = FALSE;
5ee7c6
     }
5ee7c6
 
5ee7c6
-    xpath_string = crm_strdup_printf(XPATH_NODE, uname, uname, uname, uname);
5ee7c6
+    xpath_string = crm_strdup_printf(XPATH_NODE, host_lowercase, host_lowercase, host_lowercase, host_lowercase);
5ee7c6
     if (cib_internal_op(the_cib, CIB_OP_QUERY, NULL, xpath_string, NULL,
5ee7c6
                         &xml_search, cib_sync_call|cib_scope_local|cib_xpath,
5ee7c6
                         NULL) == pcmk_ok) {
5ee7c6
@@ -509,6 +512,7 @@ query_node_uuid(cib_t * the_cib, const char *uname, char **uuid, int *is_remote_
5ee7c6
     }
5ee7c6
     free(xpath_string);
5ee7c6
     free_xml(xml_search);
5ee7c6
+    free(host_lowercase);
5ee7c6
 
5ee7c6
     if (rc != pcmk_ok) {
5ee7c6
         crm_debug("Could not map node name '%s' to a UUID: %s",
5ee7c6
-- 
5ee7c6
1.8.3.1
5ee7c6