summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2014-08-01 07:31:39 +0200
committerJakub Hrozek <jhrozek@redhat.com>2014-08-13 15:21:22 +0200
commit6bbb1da6dd9365592b4be309cf3bd7f245d844a8 (patch)
tree69ed784f96e46ac9c371dcbfda745d963ea58874
parentf9cab654c8217a4f1b983bcf92dc36acffffe58f (diff)
downloadsssd-6bbb1da6dd9365592b4be309cf3bd7f245d844a8.tar.gz
sssd-6bbb1da6dd9365592b4be309cf3bd7f245d844a8.tar.xz
sssd-6bbb1da6dd9365592b4be309cf3bd7f245d844a8.zip
IFP: Use the override_space option
https://fedorahosted.org/sssd/ticket/2397 The input of the InfoPipe responder substitutes the configured character for space and the GetUserAttrs and GetUserGroups functions substitute space for the configured character in their output. Reviewed-by: Pavel Březina <pbrezina@redhat.com> Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com> (cherry picked from commit fcfd1cb69762c49ba56326dfc85008c1d83333b2)
-rw-r--r--src/responder/ifp/ifpsrv_cmd.c53
1 files changed, 51 insertions, 2 deletions
diff --git a/src/responder/ifp/ifpsrv_cmd.c b/src/responder/ifp/ifpsrv_cmd.c
index 6c34f0479..7d97ca1b7 100644
--- a/src/responder/ifp/ifpsrv_cmd.c
+++ b/src/responder/ifp/ifpsrv_cmd.c
@@ -174,6 +174,26 @@ static void ifp_user_get_attr_process(struct tevent_req *req)
}
static errno_t
+ifp_user_get_attr_replace_space(TALLOC_CTX *mem_ctx,
+ struct ldb_message_element *el,
+ const char sub)
+{
+ int i;
+
+ for (i = 0; i < el->num_values; i++) {
+ el->values[i].data = (uint8_t *) sss_replace_space(mem_ctx,
+ (const char *) el->values[i].data,
+ sub);
+ if (el->values[i].data == NULL) {
+ DEBUG(SSSDBG_CRIT_FAILURE, "sss_replace_space failed, skipping\n");
+ return ENOMEM;
+ }
+ }
+
+ return EOK;
+}
+
+static errno_t
ifp_user_get_attr_handle_reply(struct ifp_req *ireq,
const char **attrs, struct ldb_result *res)
{
@@ -214,6 +234,18 @@ ifp_user_get_attr_handle_reply(struct ifp_req *ireq,
continue;
}
+ /* Normalize white space in user names */
+ if (ireq->ifp_ctx->rctx->override_space != '\0' &&
+ strcmp(attrs[ai], SYSDB_NAME) == 0) {
+ ret = ifp_user_get_attr_replace_space(ireq, el,
+ ireq->ifp_ctx->rctx->override_space);
+ if (ret != EOK) {
+ DEBUG(SSSDBG_MINOR_FAILURE, "Cannot normalize %s\n",
+ attrs[ai]);
+ continue;
+ }
+ }
+
ret = ifp_add_ldb_el_to_dict(&iter_dict, el);
if (ret != EOK) {
DEBUG(SSSDBG_MINOR_FAILURE,
@@ -343,8 +375,17 @@ ifp_user_get_groups_reply(struct ifp_req *ireq, struct ldb_result *res)
continue;
}
- DEBUG(SSSDBG_TRACE_FUNC, "Adding group %s\n", name);
- groupnames[i] = name;
+ if (ireq->ifp_ctx->rctx->override_space != '\0') {
+ groupnames[i] = sss_replace_space(groupnames, name,
+ ireq->ifp_ctx->rctx->override_space);
+ if (groupnames[i] == NULL) {
+ DEBUG(SSSDBG_MINOR_FAILURE, "Cannot normalize %s\n", name);
+ continue;
+ }
+ } else {
+ groupnames[i] = name;
+ }
+ DEBUG(SSSDBG_TRACE_FUNC, "Adding group %s\n", groupnames[i]);
}
return infopipe_iface_GetUserGroups_finish(ireq->dbus_req,
@@ -495,6 +536,14 @@ static errno_t ifp_user_get_attr_search(struct tevent_req *req)
name = sss_get_cased_name(state, state->name, dom->case_sensitive);
if (!name) return ENOMEM;
+ state->name = sss_reverse_replace_space(state, name,
+ state->rctx->override_space);
+ if (state->name == NULL) {
+ DEBUG(SSSDBG_CRIT_FAILURE,
+ "sss_reverse_replace_space failed\n");
+ return ENOMEM;
+ }
+
/* verify this user has not yet been negatively cached,
* or has been permanently filtered */
ret = sss_ncache_check_user(state->ncache,