|
|
bb7cd1 |
From f5bee70057370c72ed111b50937e3252e36ccefb Mon Sep 17 00:00:00 2001
|
|
|
bb7cd1 |
From: Jakub Hrozek <jhrozek@redhat.com>
|
|
|
bb7cd1 |
Date: Tue, 9 May 2017 12:21:32 +0200
|
|
|
bb7cd1 |
Subject: [PATCH 162/166] IFP: Only format the output name to the short version
|
|
|
bb7cd1 |
before output
|
|
|
bb7cd1 |
MIME-Version: 1.0
|
|
|
bb7cd1 |
Content-Type: text/plain; charset=UTF-8
|
|
|
bb7cd1 |
Content-Transfer-Encoding: 8bit
|
|
|
bb7cd1 |
|
|
|
bb7cd1 |
The ifp_user_get_attr_done() request handler was reused for both
|
|
|
bb7cd1 |
GetUserGroups and GetUserAttrs requests. Yet, it performed output
|
|
|
bb7cd1 |
formatting of name and nameAlias.
|
|
|
bb7cd1 |
|
|
|
bb7cd1 |
This is bad, because the output formatting should really be done only
|
|
|
bb7cd1 |
during output. Also, it broke any post-processing of the returned
|
|
|
bb7cd1 |
message which the request might do later.
|
|
|
bb7cd1 |
|
|
|
bb7cd1 |
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
|
|
|
bb7cd1 |
---
|
|
|
bb7cd1 |
src/responder/ifp/ifpsrv_cmd.c | 64 ++++++++++++------------------------------
|
|
|
bb7cd1 |
1 file changed, 18 insertions(+), 46 deletions(-)
|
|
|
bb7cd1 |
|
|
|
bb7cd1 |
diff --git a/src/responder/ifp/ifpsrv_cmd.c b/src/responder/ifp/ifpsrv_cmd.c
|
|
|
bb7cd1 |
index e4d6c42ef35ef372472803d3d26b17d4181021a8..915f77e38e94c703f6c67e8d5fdcc59d189943be 100644
|
|
|
bb7cd1 |
--- a/src/responder/ifp/ifpsrv_cmd.c
|
|
|
bb7cd1 |
+++ b/src/responder/ifp/ifpsrv_cmd.c
|
|
|
bb7cd1 |
@@ -181,26 +181,6 @@ static void ifp_user_get_attr_process(struct tevent_req *req)
|
|
|
bb7cd1 |
}
|
|
|
bb7cd1 |
|
|
|
bb7cd1 |
static errno_t
|
|
|
bb7cd1 |
-ifp_user_get_attr_replace_space(TALLOC_CTX *mem_ctx,
|
|
|
bb7cd1 |
- struct ldb_message_element *el,
|
|
|
bb7cd1 |
- const char sub)
|
|
|
bb7cd1 |
-{
|
|
|
bb7cd1 |
- int i;
|
|
|
bb7cd1 |
-
|
|
|
bb7cd1 |
- for (i = 0; i < el->num_values; i++) {
|
|
|
bb7cd1 |
- el->values[i].data = (uint8_t *) sss_replace_space(mem_ctx,
|
|
|
bb7cd1 |
- (const char *) el->values[i].data,
|
|
|
bb7cd1 |
- sub);
|
|
|
bb7cd1 |
- if (el->values[i].data == NULL) {
|
|
|
bb7cd1 |
- DEBUG(SSSDBG_CRIT_FAILURE, "sss_replace_space failed, skipping\n");
|
|
|
bb7cd1 |
- return ENOMEM;
|
|
|
bb7cd1 |
- }
|
|
|
bb7cd1 |
- }
|
|
|
bb7cd1 |
-
|
|
|
bb7cd1 |
- return EOK;
|
|
|
bb7cd1 |
-}
|
|
|
bb7cd1 |
-
|
|
|
bb7cd1 |
-static errno_t
|
|
|
bb7cd1 |
ifp_user_get_attr_handle_reply(struct sss_domain_info *domain,
|
|
|
bb7cd1 |
struct ifp_req *ireq,
|
|
|
bb7cd1 |
const char **attrs,
|
|
|
bb7cd1 |
@@ -234,6 +214,24 @@ ifp_user_get_attr_handle_reply(struct sss_domain_info *domain,
|
|
|
bb7cd1 |
}
|
|
|
bb7cd1 |
|
|
|
bb7cd1 |
if (res->count > 0) {
|
|
|
bb7cd1 |
+ ret = ifp_ldb_el_output_name(ireq->ifp_ctx->rctx, res->msgs[0],
|
|
|
bb7cd1 |
+ SYSDB_NAME, domain);
|
|
|
bb7cd1 |
+ if (ret != EOK) {
|
|
|
bb7cd1 |
+ DEBUG(SSSDBG_CRIT_FAILURE,
|
|
|
bb7cd1 |
+ "Cannot convert SYSDB_NAME to output format [%d]: %s\n",
|
|
|
bb7cd1 |
+ ret, sss_strerror(ret));
|
|
|
bb7cd1 |
+ return sbus_request_finish(ireq->dbus_req, NULL);
|
|
|
bb7cd1 |
+ }
|
|
|
bb7cd1 |
+
|
|
|
bb7cd1 |
+ ret = ifp_ldb_el_output_name(ireq->ifp_ctx->rctx, res->msgs[0],
|
|
|
bb7cd1 |
+ SYSDB_NAME_ALIAS, domain);
|
|
|
bb7cd1 |
+ if (ret != EOK) {
|
|
|
bb7cd1 |
+ DEBUG(SSSDBG_CRIT_FAILURE,
|
|
|
bb7cd1 |
+ "Cannot convert SYSDB_NAME_ALIAS to output format [%d]: %s\n",
|
|
|
bb7cd1 |
+ ret, sss_strerror(ret));
|
|
|
bb7cd1 |
+ return sbus_request_finish(ireq->dbus_req, NULL);
|
|
|
bb7cd1 |
+ }
|
|
|
bb7cd1 |
+
|
|
|
bb7cd1 |
for (ai = 0; attrs[ai]; ai++) {
|
|
|
bb7cd1 |
el = sss_view_ldb_msg_find_element(domain, res->msgs[0], attrs[ai]);
|
|
|
bb7cd1 |
if (el == NULL || el->num_values == 0) {
|
|
|
bb7cd1 |
@@ -243,18 +241,6 @@ ifp_user_get_attr_handle_reply(struct sss_domain_info *domain,
|
|
|
bb7cd1 |
continue;
|
|
|
bb7cd1 |
}
|
|
|
bb7cd1 |
|
|
|
bb7cd1 |
- /* Normalize white space in user names */
|
|
|
bb7cd1 |
- if (ireq->ifp_ctx->rctx->override_space != '\0' &&
|
|
|
bb7cd1 |
- strcmp(attrs[ai], SYSDB_NAME) == 0) {
|
|
|
bb7cd1 |
- ret = ifp_user_get_attr_replace_space(ireq, el,
|
|
|
bb7cd1 |
- ireq->ifp_ctx->rctx->override_space);
|
|
|
bb7cd1 |
- if (ret != EOK) {
|
|
|
bb7cd1 |
- DEBUG(SSSDBG_MINOR_FAILURE, "Cannot normalize %s\n",
|
|
|
bb7cd1 |
- attrs[ai]);
|
|
|
bb7cd1 |
- continue;
|
|
|
bb7cd1 |
- }
|
|
|
bb7cd1 |
- }
|
|
|
bb7cd1 |
-
|
|
|
bb7cd1 |
ret = ifp_add_ldb_el_to_dict(&iter_dict, el);
|
|
|
bb7cd1 |
if (ret != EOK) {
|
|
|
bb7cd1 |
DEBUG(SSSDBG_MINOR_FAILURE,
|
|
|
bb7cd1 |
@@ -575,20 +561,6 @@ static void ifp_user_get_attr_done(struct tevent_req *subreq)
|
|
|
bb7cd1 |
}
|
|
|
bb7cd1 |
}
|
|
|
bb7cd1 |
|
|
|
bb7cd1 |
- ret = ifp_ldb_el_output_name(state->rctx, state->res->msgs[0],
|
|
|
bb7cd1 |
- SYSDB_NAME, state->dom);
|
|
|
bb7cd1 |
- if (ret != EOK) {
|
|
|
bb7cd1 |
- tevent_req_error(req, ret);
|
|
|
bb7cd1 |
- return;
|
|
|
bb7cd1 |
- }
|
|
|
bb7cd1 |
-
|
|
|
bb7cd1 |
- ret = ifp_ldb_el_output_name(state->rctx, state->res->msgs[0],
|
|
|
bb7cd1 |
- SYSDB_NAME_ALIAS, state->dom);
|
|
|
bb7cd1 |
- if (ret != EOK) {
|
|
|
bb7cd1 |
- tevent_req_error(req, ret);
|
|
|
bb7cd1 |
- return;
|
|
|
bb7cd1 |
- }
|
|
|
bb7cd1 |
-
|
|
|
bb7cd1 |
tevent_req_done(req);
|
|
|
bb7cd1 |
}
|
|
|
bb7cd1 |
|
|
|
bb7cd1 |
--
|
|
|
bb7cd1 |
2.9.4
|
|
|
bb7cd1 |
|