From 2892ddd30663dbc94d15c94a5549fa74260072ce Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Tue, 14 Jun 2016 16:08:22 +0200 Subject: KRB5: Use shortname when expanding the user template in Kerberos ccache Creating the username part of the ccache file is an output operation, it makes sense to use sss_output_name() there which parses the name out of the internal qualified name. Reviewed-by: Sumit Bose --- src/providers/krb5/krb5_utils.c | 8 ++++---- src/tests/krb5_utils-tests.c | 8 ++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/providers/krb5/krb5_utils.c b/src/providers/krb5/krb5_utils.c index 7fd490514..0ac60daee 100644 --- a/src/providers/krb5/krb5_utils.c +++ b/src/providers/krb5/krb5_utils.c @@ -280,12 +280,12 @@ char *expand_ccname_template(TALLOC_CTX *mem_ctx, struct krb5child_req *kr, if (kr->pd->user == NULL) { DEBUG(SSSDBG_CRIT_FAILURE, "Cannot expand user name template " - "because user name is empty.\n"); + "because user name is empty.\n"); goto done; } - name = sss_get_cased_name(tmp_ctx, kr->pd->user, - case_sensitive); - if (!name) { + + name = sss_output_name(tmp_ctx, kr->pd->user, case_sensitive, 0); + if (name == NULL) { DEBUG(SSSDBG_CRIT_FAILURE, "sss_get_cased_name failed\n"); goto done; diff --git a/src/tests/krb5_utils-tests.c b/src/tests/krb5_utils-tests.c index ea40feb45..515a19415 100644 --- a/src/tests/krb5_utils-tests.c +++ b/src/tests/krb5_utils-tests.c @@ -38,6 +38,8 @@ #define FILENAME "ghi" #define USERNAME "testuser" +#define USERNAME_CASE "TestUser" +#define DOMAIN_NAME "testdomain" #define UID "12345" #define PRINCIPAL_NAME "testuser@EXAMPLE.COM" #define REALM "REALM.ORG" @@ -297,7 +299,8 @@ void setup_talloc_context(void) krb5_ctx = talloc_zero(tmp_ctx, struct krb5_ctx); fail_unless(pd != NULL, "Cannot create krb5_ctx structure."); - pd->user = discard_const(USERNAME); + pd->user = sss_create_internal_fqname(pd, USERNAME, DOMAIN_NAME); + fail_unless(pd->user != NULL); kr->uid = atoi(UID); kr->upn = discard_const(PRINCIPAL_NAME); pd->cli_pid = atoi(PID); @@ -370,7 +373,8 @@ START_TEST(test_case_sensitive) const char *expected_cs = BASE"_TestUser"; const char *expected_ci = BASE"_testuser"; - kr->pd->user = discard_const("TestUser"); + kr->pd->user = sss_create_internal_fqname(kr, USERNAME_CASE, DOMAIN_NAME); + fail_unless(kr->pd->user != NULL); ret = dp_opt_set_string(kr->krb5_ctx->opts, KRB5_CCACHEDIR, CCACHE_DIR); fail_unless(ret == EOK, "Failed to set Ccache dir"); -- cgit