diff options
author | Michal Zidek <mzidek@redhat.com> | 2014-11-24 19:50:14 +0100 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2014-11-25 13:47:57 +0100 |
commit | 8394eddba54b5d3e3fda868145e3751247bdbdb2 (patch) | |
tree | 29991e2b1cdd0d130b12b840414512ca96cb385d | |
parent | 5777a98940bd742d213fba8ff55c070c5a058fc6 (diff) | |
download | sssd-8394eddba54b5d3e3fda868145e3751247bdbdb2.tar.gz sssd-8394eddba54b5d3e3fda868145e3751247bdbdb2.tar.xz sssd-8394eddba54b5d3e3fda868145e3751247bdbdb2.zip |
util: Special-case PCRE_ERROR_NOMATCH in sss_parse_name
Add new SSSD specific error code for the case when
pcre_exec returns PCRE_ERROR_NOMATCH.
Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
-rw-r--r-- | src/tests/cmocka/test_fqnames.c | 14 | ||||
-rw-r--r-- | src/util/usertools.c | 2 | ||||
-rw-r--r-- | src/util/util_errors.c | 1 | ||||
-rw-r--r-- | 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 de208437d..b9b6230b9 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 a0b914e2f..09cfd6b35 100644 --- a/src/util/usertools.c +++ b/src/util/usertools.c @@ -309,7 +309,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 c1ed0fb63..16d16fc77 100644 --- a/src/util/util_errors.c +++ b/src/util/util_errors.c @@ -64,6 +64,7 @@ struct err_string error_to_str[] = { { "Cannot connect to system bus" }, /* ERR_NO_SYSBUS */ { "LDAP search returned a referral" }, /* ERR_REFERRAL */ { "Error setting SELinux user context" }, /* ERR_SELINUX_CONTEXT */ + { "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 f71ede8d0..39455dc8a 100644 --- a/src/util/util_errors.h +++ b/src/util/util_errors.h @@ -86,6 +86,7 @@ enum sssd_errors { ERR_NO_SYSBUS, ERR_REFERRAL, ERR_SELINUX_CONTEXT, + ERR_REGEX_NOMATCH, ERR_LAST /* ALWAYS LAST */ }; |