|
|
f441eb |
From 10a4dbb5978b6f05cf75f820d97da908e735ace8 Mon Sep 17 00:00:00 2001
|
|
|
f441eb |
From: Sumit Bose <sbose@redhat.com>
|
|
|
f441eb |
Date: Fri, 22 Mar 2019 10:37:11 +0100
|
|
|
f441eb |
Subject: [PATCH 3/4] library: _adcli_krb5_build_principal allow principals as
|
|
|
f441eb |
names
|
|
|
f441eb |
|
|
|
f441eb |
Make _adcli_krb5_build_principal a bit more robust by checking if the
|
|
|
f441eb |
given name already contains a realm suffix.
|
|
|
f441eb |
|
|
|
f441eb |
Related to https://bugzilla.redhat.com/show_bug.cgi?id=1630187
|
|
|
f441eb |
---
|
|
|
f441eb |
library/adkrb5.c | 12 ++++++++----
|
|
|
f441eb |
1 file changed, 8 insertions(+), 4 deletions(-)
|
|
|
f441eb |
|
|
|
f441eb |
diff --git a/library/adkrb5.c b/library/adkrb5.c
|
|
|
f441eb |
index 7f77373..da835d7 100644
|
|
|
f441eb |
--- a/library/adkrb5.c
|
|
|
f441eb |
+++ b/library/adkrb5.c
|
|
|
f441eb |
@@ -41,12 +41,16 @@ _adcli_krb5_build_principal (krb5_context k5,
|
|
|
f441eb |
krb5_principal *principal)
|
|
|
f441eb |
{
|
|
|
f441eb |
krb5_error_code code;
|
|
|
f441eb |
- char *name;
|
|
|
f441eb |
+ char *name = NULL;
|
|
|
f441eb |
|
|
|
f441eb |
- if (asprintf (&name, "%s@%s", user, realm) < 0)
|
|
|
f441eb |
- return_val_if_reached (ENOMEM);
|
|
|
f441eb |
+ /* Use user if user contains a @-character and add @realm otherwise */
|
|
|
f441eb |
+ if (strchr (user, '@') == NULL) {
|
|
|
f441eb |
+ if (asprintf (&name, "%s@%s", user, realm) < 0) {
|
|
|
f441eb |
+ return_val_if_reached (ENOMEM);
|
|
|
f441eb |
+ }
|
|
|
f441eb |
+ }
|
|
|
f441eb |
|
|
|
f441eb |
- code = krb5_parse_name (k5, name, principal);
|
|
|
f441eb |
+ code = krb5_parse_name (k5, name != NULL ? name : user, principal);
|
|
|
f441eb |
return_val_if_fail (code == 0, code);
|
|
|
f441eb |
|
|
|
f441eb |
free (name);
|
|
|
f441eb |
--
|
|
|
f441eb |
2.20.1
|
|
|
f441eb |
|