From ea4b1387c604093036559a1bfc0368c70d73fc4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20B=C5=99ezina?= Date: Sun, 11 Oct 2015 17:53:28 +0200 Subject: [PATCH 104/104] sudo: send original name and id with local views if possible Resolves: https://fedorahosted.org/sssd/ticket/2833 Reviewed-by: Sumit Bose Reviewed-by: Jakub Hrozek (cherry picked from commit fb8985a3a3a267940760967beaf8af3979ce91ea) --- src/responder/sudo/sudosrv_get_sudorules.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/responder/sudo/sudosrv_get_sudorules.c b/src/responder/sudo/sudosrv_get_sudorules.c index cc06977d97e3319584251bdab26e85855d275e8a..c3336960eeac18ee63167de81891984aa764540c 100644 --- a/src/responder/sudo/sudosrv_get_sudorules.c +++ b/src/responder/sudo/sudosrv_get_sudorules.c @@ -79,6 +79,7 @@ static errno_t sudosrv_get_user(struct sudo_dom_ctx *dctx) struct dp_callback_ctx *cb_ctx; const char *original_name = NULL; const char *extra_flag = NULL; + const char *search_name = NULL; char *name = NULL; uid_t uid = 0; errno_t ret; @@ -160,16 +161,23 @@ static errno_t sudosrv_get_user(struct sudo_dom_ctx *dctx) if ((user->count == 0 || cache_expire < time(NULL)) && dctx->check_provider) { - if (DOM_HAS_VIEWS(dom) && (user->count == 0 - || ldb_msg_find_attr_as_string(user->msgs[0], - OVERRIDE_PREFIX SYSDB_NAME, - NULL) != NULL)) { + search_name = cmd_ctx->username; + if (is_local_view(dom->view_name)) { + /* Search with original name in case of local view. */ + if (user->count != 0) { + search_name = ldb_msg_find_attr_as_string(user->msgs[0], + SYSDB_NAME, NULL); + } + } else if (DOM_HAS_VIEWS(dom) && (user->count == 0 + || ldb_msg_find_attr_as_string(user->msgs[0], + OVERRIDE_PREFIX SYSDB_NAME, + NULL) != NULL)) { extra_flag = EXTRA_INPUT_MAYBE_WITH_VIEW; } dpreq = sss_dp_get_account_send(cli_ctx, cli_ctx->rctx, dom, false, SSS_DP_INITGROUPS, - cmd_ctx->username, 0, extra_flag); + search_name, 0, extra_flag); if (!dpreq) { DEBUG(SSSDBG_CRIT_FAILURE, "Out of memory sending data provider request\n"); -- 2.4.3