From b1b83f1f70059935db8038c2e98c24fb73cf35a6 Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Mon, 5 Dec 2011 11:47:08 -0500 Subject: Revert "RHEL5: Remove UTF8 support for RHEL5" This reverts commit c417f0b8cde38ff5cc10241383f1481e3440879c. --- Makefile.am | 3 ++- configure.ac | 2 +- src/providers/ipa/hbac_evaluator.c | 36 ++++++++++++++++++++++++++++++++---- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/Makefile.am b/Makefile.am index ff1de126d..c51d484fb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -373,7 +373,8 @@ dist_pkgconfig_DATA += src/providers/ipa/ipa_hbac.pc libipa_hbac_la_SOURCES = \ src/providers/ipa/hbac_evaluator.c libipa_hbac_la_LDFLAGS = \ - -version 1:0:1 + -version 1:0:1 \ + -lunistring include_HEADERS = \ src/providers/ipa/ipa_hbac.h diff --git a/configure.ac b/configure.ac index 8c3c3a128..5e0878bca 100644 --- a/configure.ac +++ b/configure.ac @@ -123,7 +123,7 @@ m4_include([src/external/nsupdate.m4]) m4_include([src/external/libkeyutils.m4]) m4_include([src/external/libnl.m4]) m4_include([src/util/signal.m4]) -#m4_include([src/external/libunistring.m4]) +m4_include([src/external/libunistring.m4]) PKG_CHECK_MODULES([DBUS],[dbus-1]) dnl if test -n "`$PKG_CONFIG --modversion dbus-1 | grep '^0\.'`" ; then diff --git a/src/providers/ipa/hbac_evaluator.c b/src/providers/ipa/hbac_evaluator.c index db88f58d9..476ad6482 100644 --- a/src/providers/ipa/hbac_evaluator.c +++ b/src/providers/ipa/hbac_evaluator.c @@ -25,6 +25,8 @@ #include #include +#include +#include #include #include "providers/ipa/ipa_hbac.h" @@ -253,8 +255,21 @@ static errno_t hbac_evaluate_element(struct hbac_rule_element *rule_el, rule_name = (const uint8_t *) rule_el->names[i]; req_name = (const uint8_t *) req_el->name; - /* Do a case-insensitive comparison. */ - if (strcasecmp(rule_name, req_name) == 0) { + /* Do a case-insensitive comparison. + * The input must be encoded in UTF8. + * We have no way of knowing the language, + * so we'll pass NULL for the language and + * hope for the best. + */ + errno = 0; + ret = u8_casecmp(rule_name, u8_strlen(rule_name), + req_name, u8_strlen(req_name), + NULL, NULL, &result); + if (ret < 0) { + return errno; + } + + if (result == 0) { *matched = true; return EOK; } @@ -272,8 +287,21 @@ static errno_t hbac_evaluate_element(struct hbac_rule_element *rule_el, for (j = 0; req_el->groups[j]; j++) { req_name = (const uint8_t *) req_el->groups[j]; - /* Do a case-insensitive comparison. */ - if (strcasecmp(rule_name, req_name) == 0) { + /* Do a case-insensitive comparison. + * The input must be encoded in UTF8. + * We have no way of knowing the language, + * so we'll pass NULL for the language and + * hope for the best. + */ + errno = 0; + ret = u8_casecmp(rule_name, u8_strlen(rule_name), + req_name, u8_strlen(req_name), + NULL, NULL, &result); + if (ret < 0) { + return errno; + } + + if (result == 0) { *matched = true; return EOK; } -- cgit