summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2017-04-19 17:46:03 +0200
committerJakub Hrozek <jhrozek@redhat.com>2017-04-21 11:24:41 +0200
commitc9a73bb6ffa010ef206896a0d1c2801bc056fa45 (patch)
treeba5abd623b1a7f2a8e67b97475a4a3c59fa15ad4
parent7c074ba2f923985ab0d4f9d6a5e01ff3f2f0a7a8 (diff)
downloadsssd-c9a73bb6ffa010ef206896a0d1c2801bc056fa45.tar.gz
sssd-c9a73bb6ffa010ef206896a0d1c2801bc056fa45.tar.xz
sssd-c9a73bb6ffa010ef206896a0d1c2801bc056fa45.zip
IFP: Use sized_domain_name to format the groups the user is a member of
Resolves: https://pagure.io/SSSD/sssd/issue/3268 Uses the common function sized_domain_name() to format a group the user is a member of to the appropriate format. To see the code is working correctly, run: dbus-send --system --print-reply --dest=org.freedesktop.sssd.infopipe /org/freedesktop/sssd/infopipe org.freedesktop.sssd.infopipe.GetUserGroups string:trusted_user Where trusted_user is a user from a trusted domain that is a member of groups from the joined domain and a trusted domain as well. The groups from the joined domain should not be qualified, the groups from the trusted domain should be qualified. Reviewed-by: Pavel Březina <pbrezina@redhat.com>
-rw-r--r--src/responder/ifp/ifpsrv_cmd.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/responder/ifp/ifpsrv_cmd.c b/src/responder/ifp/ifpsrv_cmd.c
index d10f35e41..e4d6c42ef 100644
--- a/src/responder/ifp/ifpsrv_cmd.c
+++ b/src/responder/ifp/ifpsrv_cmd.c
@@ -369,10 +369,11 @@ ifp_user_get_groups_reply(struct sss_domain_info *domain,
struct ifp_req *ireq,
struct ldb_result *res)
{
- int i, num;
+ int i, gri, num;
const char *name;
const char **groupnames;
- char *out_name;
+ struct sized_string *group_name;
+ errno_t ret;
/* one less, the first one is the user entry */
num = res->count - 1;
@@ -381,6 +382,7 @@ ifp_user_get_groups_reply(struct sss_domain_info *domain,
return sbus_request_finish(ireq->dbus_req, NULL);
}
+ gri = 0;
for (i = 0; i < num; i++) {
name = sss_view_ldb_msg_find_attr_as_string(domain,
res->msgs[i + 1],
@@ -390,22 +392,21 @@ ifp_user_get_groups_reply(struct sss_domain_info *domain,
continue;
}
- out_name = sss_output_name(ireq, name, domain->case_preserve,
- ireq->ifp_ctx->rctx->override_space);
- if (out_name == NULL) {
+ ret = sized_domain_name(ireq, ireq->ifp_ctx->rctx, name, &group_name);
+ if (ret != EOK) {
+ DEBUG(SSSDBG_MINOR_FAILURE,
+ "Unable to get sized name for %s [%d]: %s\n",
+ name, ret, sss_strerror(ret));
continue;
}
- if (domain->fqnames) {
- groupnames[i] = sss_tc_fqname(groupnames, domain->names,
- domain, out_name);
- if (out_name == NULL) {
- DEBUG(SSSDBG_CRIT_FAILURE, "sss_tc_fqname failed\n");
- continue;
- }
- } else {
- groupnames[i] = talloc_steal(groupnames, out_name);
+ groupnames[gri] = talloc_strndup(groupnames,
+ group_name->str, group_name->len);
+ if (groupnames[gri] == NULL) {
+ DEBUG(SSSDBG_MINOR_FAILURE, "talloc_strndup failed\n");
+ continue;
}
+ gri++;
DEBUG(SSSDBG_TRACE_FUNC, "Adding group %s\n", groupnames[i]);
}