sssd/0015-PROXY-Remove-lowercase-attribute-from-save_user.patch

115 lines
4.3 KiB
Diff
Raw Normal View History

From 18c3db957a198351f8d3c13c51dff976ad736021 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= <fidencio@redhat.com>
Date: Wed, 24 Aug 2016 13:16:31 +0200
Subject: [PATCH 15/39] PROXY: Remove lowercase attribute from save_user()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
As this function already receives a struct sss_domain_info * parameter
as argument, we can simply check whether we will need a lowercase name
by accessing domain->case_sensitive.
Related:
https://fedorahosted.org/sssd/ticket/3134
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
(cherry picked from commit 413aef1529fb3d5ed4d0f38e219f5456d7fe3ae0)
---
src/providers/proxy/proxy_id.c | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)
diff --git a/src/providers/proxy/proxy_id.c b/src/providers/proxy/proxy_id.c
index b0c82807b42d91a4212578ca98af7f96484735b1..ff2631c9b493c8c688919139114da5520b428e04 100644
--- a/src/providers/proxy/proxy_id.c
+++ b/src/providers/proxy/proxy_id.c
@@ -31,7 +31,7 @@
/* =Getpwnam-wrapper======================================================*/
static int save_user(struct sss_domain_info *domain,
- bool lowercase, struct passwd *pwd, const char *real_name,
+ struct passwd *pwd, const char *real_name,
const char *alias, uint64_t cache_timeout);
static int
@@ -143,8 +143,7 @@ static int get_pw_name(struct proxy_id_ctx *ctx,
}
/* Both lookups went fine, we can save the user now */
- ret = save_user(dom, !dom->case_sensitive, pwd,
- real_name, i_name, dom->user_timeout);
+ ret = save_user(dom, pwd, real_name, i_name, dom->user_timeout);
done:
talloc_zfree(tmpctx);
@@ -224,7 +223,7 @@ delete_user(struct sss_domain_info *domain,
}
static int save_user(struct sss_domain_info *domain,
- bool lowercase, struct passwd *pwd, const char *real_name,
+ struct passwd *pwd, const char *real_name,
const char *alias, uint64_t cache_timeout)
{
const char *shell;
@@ -246,7 +245,7 @@ static int save_user(struct sss_domain_info *domain,
gecos = NULL;
}
- if (lowercase || alias) {
+ if (!domain->case_sensitive || alias) {
attrs = sysdb_new_attrs(NULL);
if (!attrs) {
DEBUG(SSSDBG_CRIT_FAILURE, "Allocation error ?!\n");
@@ -255,7 +254,7 @@ static int save_user(struct sss_domain_info *domain,
}
}
- if (lowercase) {
+ if (!domain->case_sensitive) {
lc_pw_name = sss_tc_utf8_str_tolower(attrs, real_name);
if (lc_pw_name == NULL) {
DEBUG(SSSDBG_OP_FAILURE, "Cannot convert name to lowercase.\n");
@@ -273,7 +272,7 @@ static int save_user(struct sss_domain_info *domain,
}
if (alias) {
- cased_alias = sss_get_cased_name(attrs, alias, !lowercase);
+ cased_alias = sss_get_cased_name(attrs, alias, domain->case_sensitive);
if (!cased_alias) {
ret = ENOMEM;
goto done;
@@ -366,8 +365,7 @@ static int get_pw_uid(struct proxy_id_ctx *ctx,
pwd->pw_name);
goto done;
}
- ret = save_user(dom, !dom->case_sensitive, pwd,
- name, NULL, dom->user_timeout);
+ ret = save_user(dom, pwd, name, NULL, dom->user_timeout);
done:
talloc_zfree(tmpctx);
@@ -497,8 +495,7 @@ static int enum_users(TALLOC_CTX *mem_ctx,
pwd->pw_name);
goto done;
}
- ret = save_user(dom, !dom->case_sensitive, pwd,
- name, NULL, dom->user_timeout);
+ ret = save_user(dom, pwd, name, NULL, dom->user_timeout);
if (ret) {
/* Do not fail completely on errors.
* Just report the failure to save and go on */
@@ -1331,8 +1328,7 @@ static int get_initgr(TALLOC_CTX *mem_ctx,
goto done;
}
- ret = save_user(dom, !dom->case_sensitive, pwd,
- real_name, i_name, dom->user_timeout);
+ ret = save_user(dom, pwd, real_name, i_name, dom->user_timeout);
if (ret) {
DEBUG(SSSDBG_OP_FAILURE, "Could not save user\n");
goto fail;
--
2.9.3