dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone

Blame SOURCES/0162-IFP-Only-format-the-output-name-to-the-short-version.patch

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