From 6505a4a36592efe94bfbdbfb07ca4d198a699a8b Mon Sep 17 00:00:00 2001
From: Michal Zidek <mzidek@redhat.com>
Date: Thu, 6 Nov 2014 19:25:59 +0100
Subject: [PATCH 82/82] PROXY: Preserve service name in proxy provider
Fixes:
https://fedorahosted.org/sssd/ticket/2461
Reviewed-by: Pavel Reichl <preichl@redhat.com>
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
---
src/providers/proxy/proxy_services.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/src/providers/proxy/proxy_services.c b/src/providers/proxy/proxy_services.c
index 16e90b009cba86ea17d8d29a4fbeb19efe6947fc..2aa44dbf7f061b99a551b199d0265393e5399a06 100644
--- a/src/providers/proxy/proxy_services.c
+++ b/src/providers/proxy/proxy_services.c
@@ -38,12 +38,14 @@ proxy_save_service(struct sss_domain_info *domain,
const char **protocols;
const char **cased_aliases;
TALLOC_CTX *tmp_ctx;
+ char *lc_alias = NULL;
time_t now = time(NULL);
tmp_ctx = talloc_new(NULL);
if (!tmp_ctx) return ENOMEM;
- cased_name = sss_get_cased_name(tmp_ctx, svc->s_name, !lowercase);
+ cased_name = sss_get_cased_name(tmp_ctx, svc->s_name,
+ domain->case_preserve);
if (!cased_name) {
ret = ENOMEM;
goto done;
@@ -71,6 +73,24 @@ proxy_save_service(struct sss_domain_info *domain,
goto done;
}
+ if (domain->case_preserve) {
+ /* Add lowercased alias to allow case-insensitive lookup */
+ lc_alias = sss_tc_utf8_str_tolower(tmp_ctx, svc->s_name);
+ if (lc_alias == NULL) {
+ DEBUG(SSSDBG_OP_FAILURE, "Cannot convert name to lowercase.\n");
+ ret = ENOMEM;
+ goto done;
+ }
+
+ ret = add_string_to_list(tmp_ctx, lc_alias,
+ discard_const_p(char **, &cased_aliases));
+ if (ret != EOK) {
+ DEBUG(SSSDBG_OP_FAILURE,
+ "Failed to add lowercased name alias.\n");
+ goto done;
+ }
+ }
+
ret = sysdb_store_service(domain,
cased_name,
ntohs(svc->s_port),
--
1.9.3