|
|
6cf099 |
From f9f227bb5a7fe6e5af83debbbd892bdb4e13894d Mon Sep 17 00:00:00 2001
|
|
|
6cf099 |
From: Sumit Bose <sbose@redhat.com>
|
|
|
6cf099 |
Date: Tue, 14 Jul 2015 14:41:34 +0200
|
|
|
6cf099 |
Subject: [PATCH 14/14] nss_check_name_of_well_known_sid() improve name
|
|
|
6cf099 |
splitting
|
|
|
6cf099 |
MIME-Version: 1.0
|
|
|
6cf099 |
Content-Type: text/plain; charset=UTF-8
|
|
|
6cf099 |
Content-Transfer-Encoding: 8bit
|
|
|
6cf099 |
|
|
|
6cf099 |
Currently in the default configuration
|
|
|
6cf099 |
nss_check_name_of_well_known_sid() can only split fully-qualified names
|
|
|
6cf099 |
in the user@domain.name style. DOM\user style names will cause an error
|
|
|
6cf099 |
and terminate the whole request.
|
|
|
6cf099 |
|
|
|
6cf099 |
With this patch both styles can be handled by default, additionally if
|
|
|
6cf099 |
the name could not be split nss_check_name_of_well_known_sid() returns
|
|
|
6cf099 |
ENOENT which can be handled more gracefully by the caller.
|
|
|
6cf099 |
|
|
|
6cf099 |
Resolves https://fedorahosted.org/sssd/ticket/2717
|
|
|
6cf099 |
|
|
|
6cf099 |
Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
|
|
|
6cf099 |
---
|
|
|
6cf099 |
src/responder/nss/nsssrv_cmd.c | 8 ++++
|
|
|
6cf099 |
src/tests/cmocka/test_nss_srv.c | 90 ++++++++++++++++++++++++-----------------
|
|
|
6cf099 |
src/util/usertools.c | 3 +-
|
|
|
6cf099 |
3 files changed, 61 insertions(+), 40 deletions(-)
|
|
|
6cf099 |
|
|
|
6cf099 |
diff --git a/src/responder/nss/nsssrv_cmd.c b/src/responder/nss/nsssrv_cmd.c
|
|
|
6cf099 |
index 0129467302f16af318bbbb0a5be47ff2e235da65..b3998015fa621cad8e06a126a674f94d26158dda 100644
|
|
|
6cf099 |
--- a/src/responder/nss/nsssrv_cmd.c
|
|
|
6cf099 |
+++ b/src/responder/nss/nsssrv_cmd.c
|
|
|
6cf099 |
@@ -1255,6 +1255,14 @@ static int nss_check_name_of_well_known_sid(struct nss_cmd_ctx *cmdctx,
|
|
|
6cf099 |
return ret;
|
|
|
6cf099 |
}
|
|
|
6cf099 |
|
|
|
6cf099 |
+ if (wk_dom_name == NULL || wk_name == NULL) {
|
|
|
6cf099 |
+ DEBUG(SSSDBG_OP_FAILURE,
|
|
|
6cf099 |
+ "Unable to split [%s] in name and domain part. " \
|
|
|
6cf099 |
+ "Skipping check for well-known name.\n", full_name);
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+ return ENOENT;
|
|
|
6cf099 |
+ }
|
|
|
6cf099 |
+
|
|
|
6cf099 |
ret = name_to_well_known_sid(wk_dom_name, wk_name, &wk_sid);
|
|
|
6cf099 |
talloc_free(wk_dom_name);
|
|
|
6cf099 |
talloc_free(wk_name);
|
|
|
6cf099 |
diff --git a/src/tests/cmocka/test_nss_srv.c b/src/tests/cmocka/test_nss_srv.c
|
|
|
6cf099 |
index 3ab8d39c44a8bb8cacae20f534dcbeb6ca7dec08..84d3413be70bc0af433b7fd23cf7d78b4b9298f1 100644
|
|
|
6cf099 |
--- a/src/tests/cmocka/test_nss_srv.c
|
|
|
6cf099 |
+++ b/src/tests/cmocka/test_nss_srv.c
|
|
|
6cf099 |
@@ -1734,63 +1734,77 @@ void test_nss_well_known_getidbysid_failure(void **state)
|
|
|
6cf099 |
void test_nss_well_known_getsidbyname(void **state)
|
|
|
6cf099 |
{
|
|
|
6cf099 |
errno_t ret;
|
|
|
6cf099 |
+ const char *names[] = { "Cryptographic Operators@BUILTIN",
|
|
|
6cf099 |
+ "BUILTIN\\Cryptographic Operators", NULL};
|
|
|
6cf099 |
+ size_t c;
|
|
|
6cf099 |
|
|
|
6cf099 |
- will_return(__wrap_sss_packet_get_body, WRAP_CALL_WRAPPER);
|
|
|
6cf099 |
- will_return(__wrap_sss_packet_get_body, "Cryptographic Operators@BUILTIN");
|
|
|
6cf099 |
- will_return(__wrap_sss_packet_get_body, 0);
|
|
|
6cf099 |
- will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETSIDBYNAME);
|
|
|
6cf099 |
- will_return(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
|
|
|
6cf099 |
- will_return(test_nss_well_known_sid_check, "S-1-5-32-569");
|
|
|
6cf099 |
+ for (c = 0; names[c] != NULL; c++) {
|
|
|
6cf099 |
+ will_return(__wrap_sss_packet_get_body, WRAP_CALL_WRAPPER);
|
|
|
6cf099 |
+ will_return(__wrap_sss_packet_get_body, names[c]);
|
|
|
6cf099 |
+ will_return(__wrap_sss_packet_get_body, 0);
|
|
|
6cf099 |
+ will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETSIDBYNAME);
|
|
|
6cf099 |
+ will_return(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
|
|
|
6cf099 |
+ will_return(test_nss_well_known_sid_check, "S-1-5-32-569");
|
|
|
6cf099 |
|
|
|
6cf099 |
- set_cmd_cb(test_nss_well_known_sid_check);
|
|
|
6cf099 |
- ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETSIDBYNAME,
|
|
|
6cf099 |
- nss_test_ctx->nss_cmds);
|
|
|
6cf099 |
- assert_int_equal(ret, EOK);
|
|
|
6cf099 |
+ set_cmd_cb(test_nss_well_known_sid_check);
|
|
|
6cf099 |
+ ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETSIDBYNAME,
|
|
|
6cf099 |
+ nss_test_ctx->nss_cmds);
|
|
|
6cf099 |
+ assert_int_equal(ret, EOK);
|
|
|
6cf099 |
|
|
|
6cf099 |
- /* Wait until the test finishes with EOK */
|
|
|
6cf099 |
- ret = test_ev_loop(nss_test_ctx->tctx);
|
|
|
6cf099 |
- assert_int_equal(ret, EOK);
|
|
|
6cf099 |
+ /* Wait until the test finishes with EOK */
|
|
|
6cf099 |
+ ret = test_ev_loop(nss_test_ctx->tctx);
|
|
|
6cf099 |
+ assert_int_equal(ret, EOK);
|
|
|
6cf099 |
+ }
|
|
|
6cf099 |
}
|
|
|
6cf099 |
|
|
|
6cf099 |
void test_nss_well_known_getsidbyname_nonexisting(void **state)
|
|
|
6cf099 |
{
|
|
|
6cf099 |
errno_t ret;
|
|
|
6cf099 |
+ const char *names[] = { "Abc@BUILTIN", "BUILTIN\\Abc", NULL };
|
|
|
6cf099 |
+ size_t c;
|
|
|
6cf099 |
|
|
|
6cf099 |
- will_return(__wrap_sss_packet_get_body, WRAP_CALL_WRAPPER);
|
|
|
6cf099 |
- will_return(__wrap_sss_packet_get_body, "Abc@BUILTIN");
|
|
|
6cf099 |
- will_return(__wrap_sss_packet_get_body, 0);
|
|
|
6cf099 |
- will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETSIDBYNAME);
|
|
|
6cf099 |
- will_return(test_nss_well_known_sid_check, NULL);
|
|
|
6cf099 |
+ for (c = 0; names[c] != NULL; c++) {
|
|
|
6cf099 |
+ will_return(__wrap_sss_packet_get_body, WRAP_CALL_WRAPPER);
|
|
|
6cf099 |
+ will_return(__wrap_sss_packet_get_body, names[c]);
|
|
|
6cf099 |
+ will_return(__wrap_sss_packet_get_body, 0);
|
|
|
6cf099 |
+ will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETSIDBYNAME);
|
|
|
6cf099 |
+ will_return(test_nss_well_known_sid_check, NULL);
|
|
|
6cf099 |
|
|
|
6cf099 |
- set_cmd_cb(test_nss_well_known_sid_check);
|
|
|
6cf099 |
- ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETSIDBYNAME,
|
|
|
6cf099 |
- nss_test_ctx->nss_cmds);
|
|
|
6cf099 |
- assert_int_equal(ret, EOK);
|
|
|
6cf099 |
+ set_cmd_cb(test_nss_well_known_sid_check);
|
|
|
6cf099 |
+ ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETSIDBYNAME,
|
|
|
6cf099 |
+ nss_test_ctx->nss_cmds);
|
|
|
6cf099 |
+ assert_int_equal(ret, EOK);
|
|
|
6cf099 |
|
|
|
6cf099 |
- /* Wait until the test finishes with EOK */
|
|
|
6cf099 |
- ret = test_ev_loop(nss_test_ctx->tctx);
|
|
|
6cf099 |
- assert_int_equal(ret, EOK);
|
|
|
6cf099 |
+ /* Wait until the test finishes with EOK */
|
|
|
6cf099 |
+ ret = test_ev_loop(nss_test_ctx->tctx);
|
|
|
6cf099 |
+ assert_int_equal(ret, EOK);
|
|
|
6cf099 |
+ }
|
|
|
6cf099 |
}
|
|
|
6cf099 |
|
|
|
6cf099 |
void test_nss_well_known_getsidbyname_special(void **state)
|
|
|
6cf099 |
{
|
|
|
6cf099 |
errno_t ret;
|
|
|
6cf099 |
+ const char *names[] = { "CREATOR OWNER@CREATOR AUTHORITY",
|
|
|
6cf099 |
+ "CREATOR AUTHORITY\\CREATOR OWNER", NULL };
|
|
|
6cf099 |
+ size_t c;
|
|
|
6cf099 |
|
|
|
6cf099 |
- will_return(__wrap_sss_packet_get_body, WRAP_CALL_WRAPPER);
|
|
|
6cf099 |
- will_return(__wrap_sss_packet_get_body, "CREATOR OWNER@CREATOR AUTHORITY");
|
|
|
6cf099 |
- will_return(__wrap_sss_packet_get_body, 0);
|
|
|
6cf099 |
- will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETSIDBYNAME);
|
|
|
6cf099 |
- will_return(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
|
|
|
6cf099 |
- will_return(test_nss_well_known_sid_check, "S-1-3-0");
|
|
|
6cf099 |
+ for (c = 0; names[c] != NULL; c++) {
|
|
|
6cf099 |
+ will_return(__wrap_sss_packet_get_body, WRAP_CALL_WRAPPER);
|
|
|
6cf099 |
+ will_return(__wrap_sss_packet_get_body, names[c]);
|
|
|
6cf099 |
+ will_return(__wrap_sss_packet_get_body, 0);
|
|
|
6cf099 |
+ will_return(__wrap_sss_packet_get_cmd, SSS_NSS_GETSIDBYNAME);
|
|
|
6cf099 |
+ will_return(__wrap_sss_packet_get_body, WRAP_CALL_REAL);
|
|
|
6cf099 |
+ will_return(test_nss_well_known_sid_check, "S-1-3-0");
|
|
|
6cf099 |
|
|
|
6cf099 |
- set_cmd_cb(test_nss_well_known_sid_check);
|
|
|
6cf099 |
- ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETSIDBYNAME,
|
|
|
6cf099 |
- nss_test_ctx->nss_cmds);
|
|
|
6cf099 |
- assert_int_equal(ret, EOK);
|
|
|
6cf099 |
+ set_cmd_cb(test_nss_well_known_sid_check);
|
|
|
6cf099 |
+ ret = sss_cmd_execute(nss_test_ctx->cctx, SSS_NSS_GETSIDBYNAME,
|
|
|
6cf099 |
+ nss_test_ctx->nss_cmds);
|
|
|
6cf099 |
+ assert_int_equal(ret, EOK);
|
|
|
6cf099 |
|
|
|
6cf099 |
- /* Wait until the test finishes with EOK */
|
|
|
6cf099 |
- ret = test_ev_loop(nss_test_ctx->tctx);
|
|
|
6cf099 |
- assert_int_equal(ret, EOK);
|
|
|
6cf099 |
+ /* Wait until the test finishes with EOK */
|
|
|
6cf099 |
+ ret = test_ev_loop(nss_test_ctx->tctx);
|
|
|
6cf099 |
+ assert_int_equal(ret, EOK);
|
|
|
6cf099 |
+ }
|
|
|
6cf099 |
}
|
|
|
6cf099 |
|
|
|
6cf099 |
static int test_nss_getorigbyname_check(uint32_t status, uint8_t *body,
|
|
|
6cf099 |
diff --git a/src/util/usertools.c b/src/util/usertools.c
|
|
|
6cf099 |
index c43d420e31c6c690628ef6179d932eaf99826fee..87a8d7411312c3a80c32374a1fd93bbf0e767a91 100644
|
|
|
6cf099 |
--- a/src/util/usertools.c
|
|
|
6cf099 |
+++ b/src/util/usertools.c
|
|
|
6cf099 |
@@ -249,8 +249,7 @@ int sss_names_init(TALLOC_CTX *mem_ctx, struct confdb_ctx *cdb,
|
|
|
6cf099 |
}
|
|
|
6cf099 |
|
|
|
6cf099 |
if (!re_pattern) {
|
|
|
6cf099 |
- re_pattern = talloc_strdup(tmpctx,
|
|
|
6cf099 |
- "(?P<name>[^@]+)@?(?P<domain>[^@]*$)");
|
|
|
6cf099 |
+ re_pattern = talloc_strdup(tmpctx, IPA_AD_DEFAULT_RE);
|
|
|
6cf099 |
if (!re_pattern) {
|
|
|
6cf099 |
ret = ENOMEM;
|
|
|
6cf099 |
goto done;
|
|
|
6cf099 |
--
|
|
|
6cf099 |
2.4.3
|
|
|
6cf099 |
|