ebb3a9f2b4
- https://fedorahosted.org/sssd/ticket/{id} - Regressions: #2471, #2475, #2483, #2487, #2529, #2535 - Bugs: #2287, #2445
89 lines
3.7 KiB
Diff
89 lines
3.7 KiB
Diff
From 0370ef147287888604147bea95153795ffed318f Mon Sep 17 00:00:00 2001
|
|
From: Michal Zidek <mzidek@redhat.com>
|
|
Date: Mon, 24 Nov 2014 19:50:14 +0100
|
|
Subject: [PATCH 18/26] util: Special-case PCRE_ERROR_NOMATCH in sss_parse_name
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
Add new SSSD specific error code for the case when
|
|
pcre_exec returns PCRE_ERROR_NOMATCH.
|
|
|
|
Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
|
|
|
|
Conflicts:
|
|
src/util/util_errors.c
|
|
src/util/util_errors.h
|
|
---
|
|
src/tests/cmocka/test_fqnames.c | 14 +++++++-------
|
|
src/util/usertools.c | 2 +-
|
|
src/util/util_errors.c | 1 +
|
|
src/util/util_errors.h | 1 +
|
|
4 files changed, 10 insertions(+), 8 deletions(-)
|
|
|
|
diff --git a/src/tests/cmocka/test_fqnames.c b/src/tests/cmocka/test_fqnames.c
|
|
index de208437d3d11429ebb4fd92ac6b1469564d9174..b9b6230b9e2c86dafae159630d5202e46992f5f3 100644
|
|
--- a/src/tests/cmocka/test_fqnames.c
|
|
+++ b/src/tests/cmocka/test_fqnames.c
|
|
@@ -471,13 +471,13 @@ void sss_parse_name_fail(void **state)
|
|
struct parse_name_test_ctx *test_ctx = talloc_get_type(*state,
|
|
struct parse_name_test_ctx);
|
|
|
|
- sss_parse_name_check(test_ctx, "", EINVAL, NULL, NULL);
|
|
- sss_parse_name_check(test_ctx, "@", EINVAL, NULL, NULL);
|
|
- sss_parse_name_check(test_ctx, "\\", EINVAL, NULL, NULL);
|
|
- sss_parse_name_check(test_ctx, "\\"NAME, EINVAL, NULL, NULL);
|
|
- sss_parse_name_check(test_ctx, "@"NAME, EINVAL, NULL, NULL);
|
|
- sss_parse_name_check(test_ctx, NAME"@", EINVAL, NULL, NULL);
|
|
- sss_parse_name_check(test_ctx, NAME"\\", EINVAL, NULL, NULL);
|
|
+ sss_parse_name_check(test_ctx, "", ERR_REGEX_NOMATCH, NULL, NULL);
|
|
+ sss_parse_name_check(test_ctx, "@", ERR_REGEX_NOMATCH, NULL, NULL);
|
|
+ sss_parse_name_check(test_ctx, "\\", ERR_REGEX_NOMATCH, NULL, NULL);
|
|
+ sss_parse_name_check(test_ctx, "\\"NAME, ERR_REGEX_NOMATCH, NULL, NULL);
|
|
+ sss_parse_name_check(test_ctx, "@"NAME, ERR_REGEX_NOMATCH, NULL, NULL);
|
|
+ sss_parse_name_check(test_ctx, NAME"@", ERR_REGEX_NOMATCH, NULL, NULL);
|
|
+ sss_parse_name_check(test_ctx, NAME"\\", ERR_REGEX_NOMATCH, NULL, NULL);
|
|
}
|
|
|
|
void test_sss_get_domain_name(void **state)
|
|
diff --git a/src/util/usertools.c b/src/util/usertools.c
|
|
index 809b42d67c7b1cdfa0729c3a7e835fab37297596..16478998d8936cd2e260c1e53db6b68f1563b0f8 100644
|
|
--- a/src/util/usertools.c
|
|
+++ b/src/util/usertools.c
|
|
@@ -306,7 +306,7 @@ int sss_parse_name(TALLOC_CTX *memctx,
|
|
|
|
ret = pcre_exec(re, NULL, orig, origlen, 0, PCRE_NOTEMPTY, ovec, 30);
|
|
if (ret == PCRE_ERROR_NOMATCH) {
|
|
- return EINVAL;
|
|
+ return ERR_REGEX_NOMATCH;
|
|
} else if (ret < 0) {
|
|
DEBUG(SSSDBG_MINOR_FAILURE, "PCRE Matching error, %d\n", ret);
|
|
return EINVAL;
|
|
diff --git a/src/util/util_errors.c b/src/util/util_errors.c
|
|
index 5b36780ffcdc6733241cdb942865ecdf38da3bca..c1ac45ac5f8a53871d548bb0d218eabb03c69aa9 100644
|
|
--- a/src/util/util_errors.c
|
|
+++ b/src/util/util_errors.c
|
|
@@ -62,6 +62,7 @@ struct err_string error_to_str[] = {
|
|
{ "Bus method not supported" }, /* ERR_SBUS_NOSUP */
|
|
{ "Cannot connect to system bus" }, /* ERR_NO_SYSBUS */
|
|
{ "LDAP search returned a referral" }, /* ERR_REFERRAL */
|
|
+ { "Username format not allowed by re_expression" }, /* ERR_REGEX_NOMATCH */
|
|
};
|
|
|
|
|
|
diff --git a/src/util/util_errors.h b/src/util/util_errors.h
|
|
index e040ba903b27d06ec75cea31485d2f3111ca5302..8609dca22dcef33641efd0d717085d77c10224f8 100644
|
|
--- a/src/util/util_errors.h
|
|
+++ b/src/util/util_errors.h
|
|
@@ -84,6 +84,7 @@ enum sssd_errors {
|
|
ERR_SBUS_NOSUP,
|
|
ERR_NO_SYSBUS,
|
|
ERR_REFERRAL,
|
|
+ ERR_REGEX_NOMATCH,
|
|
ERR_LAST /* ALWAYS LAST */
|
|
};
|
|
|
|
--
|
|
2.1.0
|
|
|