summaryrefslogtreecommitdiff
path: root/src/providers/ipa
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2011-12-02 11:59:20 -0500
committerStephen Gallagher <sgallagh@redhat.com>2011-12-05 11:50:49 -0500
commitb32159300fea63222d8dd9200ed634087704ea74 (patch)
tree1df8dd260bc69f2611e53e05cc64b90e5583d576 /src/providers/ipa
parentf46b9fd64ef09aae23220c5adb2fe4d3e4adc553 (diff)
downloadsssd-b32159300fea63222d8dd9200ed634087704ea74.tar.gz
sssd-b32159300fea63222d8dd9200ed634087704ea74.tar.bz2
sssd-b32159300fea63222d8dd9200ed634087704ea74.zip
Allow using Glib for UTF8 support
Diffstat (limited to 'src/providers/ipa')
-rw-r--r--src/providers/ipa/hbac_evaluator.c44
1 files changed, 11 insertions, 33 deletions
diff --git a/src/providers/ipa/hbac_evaluator.c b/src/providers/ipa/hbac_evaluator.c
index 476ad648..a41aa5bb 100644
--- a/src/providers/ipa/hbac_evaluator.c
+++ b/src/providers/ipa/hbac_evaluator.c
@@ -25,10 +25,9 @@
#include <stdlib.h>
#include <string.h>
-#include <unistr.h>
-#include <unicase.h>
#include <errno.h>
#include "providers/ipa/ipa_hbac.h"
+#include "util/sss_utf8.h"
#ifndef HAVE_ERRNO_T
#define HAVE_ERRNO_T
@@ -240,7 +239,6 @@ static errno_t hbac_evaluate_element(struct hbac_rule_element *rule_el,
size_t i, j;
const uint8_t *rule_name;
const uint8_t *req_name;
- int result;
int ret;
if (rule_el->category & HBAC_CATEGORY_ALL) {
@@ -255,21 +253,11 @@ 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.
- * 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) {
+ /* Do a case-insensitive comparison. */
+ ret = sss_utf8_case_eq(rule_name, req_name);
+ if (ret != EOK && ret != ENOMATCH) {
+ return ret;
+ } else if (ret == EOK) {
*matched = true;
return EOK;
}
@@ -287,21 +275,11 @@ 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.
- * 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) {
+ /* Do a case-insensitive comparison. */
+ ret = sss_utf8_case_eq(rule_name, req_name);
+ if (ret != EOK && ret != ENOMATCH) {
+ return ret;
+ } else if (ret == EOK) {
*matched = true;
return EOK;
}