From e52bf2202dc187c5d10497d62a8ceb6db2156902 Mon Sep 17 00:00:00 2001 From: Packit Date: Aug 19 2020 12:54:23 +0000 Subject: Apply patch 0003-library-_adcli_krb5_build_principal-allow-principals.patch patch_name: 0003-library-_adcli_krb5_build_principal-allow-principals.patch location_in_specfile: 39 present_in_specfile: true --- diff --git a/library/adkrb5.c b/library/adkrb5.c index 7f77373..da835d7 100644 --- a/library/adkrb5.c +++ b/library/adkrb5.c @@ -41,12 +41,16 @@ _adcli_krb5_build_principal (krb5_context k5, krb5_principal *principal) { krb5_error_code code; - char *name; + char *name = NULL; - if (asprintf (&name, "%s@%s", user, realm) < 0) - return_val_if_reached (ENOMEM); + /* Use user if user contains a @-character and add @realm otherwise */ + if (strchr (user, '@') == NULL) { + if (asprintf (&name, "%s@%s", user, realm) < 0) { + return_val_if_reached (ENOMEM); + } + } - code = krb5_parse_name (k5, name, principal); + code = krb5_parse_name (k5, name != NULL ? name : user, principal); return_val_if_fail (code == 0, code); free (name);