Blame SOURCES/0104-IFP-Use-sized_domain_name-to-format-the-groups-the-u.patch

ecf709
From 956d7e794d6c07eec3c0009253c8a86320c3e741 Mon Sep 17 00:00:00 2001
ecf709
From: Jakub Hrozek <jhrozek@redhat.com>
ecf709
Date: Wed, 19 Apr 2017 17:46:03 +0200
ecf709
Subject: [PATCH 104/104] IFP: Use sized_domain_name to format the groups the
ecf709
 user is a member of
ecf709
MIME-Version: 1.0
ecf709
Content-Type: text/plain; charset=UTF-8
ecf709
Content-Transfer-Encoding: 8bit
ecf709
ecf709
Resolves:
ecf709
    https://pagure.io/SSSD/sssd/issue/3268
ecf709
ecf709
Uses the common function sized_domain_name() to format a group the user
ecf709
is a member of to the appropriate format.
ecf709
ecf709
To see the code is working correctly, run:
ecf709
        dbus-send --system --print-reply --dest=org.freedesktop.sssd.infopipe
ecf709
                  /org/freedesktop/sssd/infopipe
ecf709
                  org.freedesktop.sssd.infopipe.GetUserGroups
ecf709
                  string:trusted_user
ecf709
ecf709
Where trusted_user is a user from a trusted domain that is a member of groups
ecf709
from the joined domain and a trusted domain as well. The groups from the
ecf709
joined domain should not be qualified, the groups from the trusted
ecf709
domain should be qualified.
ecf709
ecf709
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
ecf709
(cherry picked from commit c9a73bb6ffa010ef206896a0d1c2801bc056fa45)
ecf709
---
ecf709
 src/responder/ifp/ifpsrv_cmd.c | 29 +++++++++++++++--------------
ecf709
 1 file changed, 15 insertions(+), 14 deletions(-)
ecf709
ecf709
diff --git a/src/responder/ifp/ifpsrv_cmd.c b/src/responder/ifp/ifpsrv_cmd.c
ecf709
index d10f35e41dbb1623a0b9de37a4c43363cbefc1a3..e4d6c42ef35ef372472803d3d26b17d4181021a8 100644
ecf709
--- a/src/responder/ifp/ifpsrv_cmd.c
ecf709
+++ b/src/responder/ifp/ifpsrv_cmd.c
ecf709
@@ -369,10 +369,11 @@ ifp_user_get_groups_reply(struct sss_domain_info *domain,
ecf709
                           struct ifp_req *ireq,
ecf709
                           struct ldb_result *res)
ecf709
 {
ecf709
-    int i, num;
ecf709
+    int i, gri, num;
ecf709
     const char *name;
ecf709
     const char **groupnames;
ecf709
-    char *out_name;
ecf709
+    struct sized_string *group_name;
ecf709
+    errno_t ret;
ecf709
 
ecf709
     /* one less, the first one is the user entry */
ecf709
     num = res->count - 1;
ecf709
@@ -381,6 +382,7 @@ ifp_user_get_groups_reply(struct sss_domain_info *domain,
ecf709
         return sbus_request_finish(ireq->dbus_req, NULL);
ecf709
     }
ecf709
 
ecf709
+    gri = 0;
ecf709
     for (i = 0; i < num; i++) {
ecf709
         name = sss_view_ldb_msg_find_attr_as_string(domain,
ecf709
                                                     res->msgs[i + 1],
ecf709
@@ -390,22 +392,21 @@ ifp_user_get_groups_reply(struct sss_domain_info *domain,
ecf709
             continue;
ecf709
         }
ecf709
 
ecf709
-        out_name = sss_output_name(ireq, name, domain->case_preserve,
ecf709
-                                   ireq->ifp_ctx->rctx->override_space);
ecf709
-        if (out_name == NULL) {
ecf709
+        ret = sized_domain_name(ireq, ireq->ifp_ctx->rctx, name, &group_name);
ecf709
+        if (ret != EOK) {
ecf709
+            DEBUG(SSSDBG_MINOR_FAILURE,
ecf709
+                  "Unable to get sized name for %s [%d]: %s\n",
ecf709
+                  name, ret, sss_strerror(ret));
ecf709
             continue;
ecf709
         }
ecf709
 
ecf709
-        if (domain->fqnames) {
ecf709
-            groupnames[i] = sss_tc_fqname(groupnames, domain->names,
ecf709
-                                          domain, out_name);
ecf709
-            if (out_name == NULL) {
ecf709
-                DEBUG(SSSDBG_CRIT_FAILURE, "sss_tc_fqname failed\n");
ecf709
-                continue;
ecf709
-            }
ecf709
-        } else {
ecf709
-            groupnames[i] = talloc_steal(groupnames, out_name);
ecf709
+        groupnames[gri] = talloc_strndup(groupnames,
ecf709
+                                         group_name->str, group_name->len);
ecf709
+        if (groupnames[gri] == NULL) {
ecf709
+            DEBUG(SSSDBG_MINOR_FAILURE, "talloc_strndup failed\n");
ecf709
+            continue;
ecf709
         }
ecf709
+        gri++;
ecf709
 
ecf709
         DEBUG(SSSDBG_TRACE_FUNC, "Adding group %s\n", groupnames[i]);
ecf709
     }
ecf709
-- 
ecf709
2.9.3
ecf709