From eaccdcf75b651a0cc4fc02526180f5991a16c553 Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: Fri, 28 Aug 2015 07:07:40 +0200 Subject: [PATCH 68/68] NSS: Don't ignore backslash in usernames with ldap provider The regression was caused by changing default domain regex for ldap provider in ticket #2717 Resolves: https://fedorahosted.org/sssd/ticket/2772 Reviewed-by: Sumit Bose --- src/responder/nss/nsssrv.c | 4 ++-- src/tests/cmocka/test_nss_srv.c | 4 ++-- src/util/usertools.c | 11 ++++++++++- src/util/util.h | 3 +++ 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/responder/nss/nsssrv.c b/src/responder/nss/nsssrv.c index 2b3bca892a5b9c483d1f6f099fd4a6493e9afcab..d8eff7968c4929663412aa56d08414689b921a22 100644 --- a/src/responder/nss/nsssrv.c +++ b/src/responder/nss/nsssrv.c @@ -552,9 +552,9 @@ int nss_process_init(TALLOC_CTX *mem_ctx, goto fail; } - ret = sss_names_init(nctx, nctx->rctx->cdb, NULL, &nctx->global_names); + ret = sss_ad_default_names_ctx(nctx, &nctx->global_names); if (ret != EOK) { - DEBUG(SSSDBG_CRIT_FAILURE, "sss_names_init failed.\n"); + DEBUG(SSSDBG_CRIT_FAILURE, "sss_ad_default_names_ctx failed.\n"); goto fail; } diff --git a/src/tests/cmocka/test_nss_srv.c b/src/tests/cmocka/test_nss_srv.c index 84d3413be70bc0af433b7fd23cf7d78b4b9298f1..3cf9f06e61b9e4f13d5d755f7cbd8020194d52d6 100644 --- a/src/tests/cmocka/test_nss_srv.c +++ b/src/tests/cmocka/test_nss_srv.c @@ -1043,8 +1043,8 @@ void test_nss_setup(struct sss_test_conf_param params[], nss_test_ctx->nctx = mock_nctx(nss_test_ctx); assert_non_null(nss_test_ctx->nctx); - ret = sss_names_init(nss_test_ctx->nctx, nss_test_ctx->tctx->confdb, - NULL, &nss_test_ctx->nctx->global_names); + ret = sss_ad_default_names_ctx(nss_test_ctx->nctx, + &nss_test_ctx->nctx->global_names); assert_int_equal(ret, EOK); assert_non_null(nss_test_ctx->nctx->global_names); diff --git a/src/util/usertools.c b/src/util/usertools.c index 87a8d7411312c3a80c32374a1fd93bbf0e767a91..ccbf7a0c8c2fb6d1d07afbfe46d978fc33093432 100644 --- a/src/util/usertools.c +++ b/src/util/usertools.c @@ -249,7 +249,8 @@ int sss_names_init(TALLOC_CTX *mem_ctx, struct confdb_ctx *cdb, } if (!re_pattern) { - re_pattern = talloc_strdup(tmpctx, IPA_AD_DEFAULT_RE); + re_pattern = talloc_strdup(tmpctx, + "(?P[^@]+)@?(?P[^@]*$)"); if (!re_pattern) { ret = ENOMEM; goto done; @@ -294,6 +295,14 @@ done: return ret; } +int sss_ad_default_names_ctx(TALLOC_CTX *mem_ctx, + struct sss_names_ctx **_out) +{ + return sss_names_init_from_args(mem_ctx, IPA_AD_DEFAULT_RE, + CONFDB_DEFAULT_FULL_NAME_FORMAT, + _out); +} + int sss_parse_name(TALLOC_CTX *memctx, struct sss_names_ctx *snctx, const char *orig, char **_domain, char **_name) diff --git a/src/util/util.h b/src/util/util.h index a20d1d82eb8f10dac515ad25e7e424713bb1c099..c998e91f92b0a86e0f4308ff0c07ff802588b5cf 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -298,6 +298,9 @@ int sss_names_init(TALLOC_CTX *mem_ctx, const char *domain, struct sss_names_ctx **out); +int sss_ad_default_names_ctx(TALLOC_CTX *mem_ctx, + struct sss_names_ctx **_out); + int sss_parse_name(TALLOC_CTX *memctx, struct sss_names_ctx *snctx, const char *orig, char **_domain, char **_name); -- 2.4.3