From 2560e3fde55be3d6be42855ec504d079a47ee69c Mon Sep 17 00:00:00 2001 From: Packit Service Date: Dec 23 2020 06:09:30 +0000 Subject: Apply patch 0003-library-_adcli_krb5_build_principal-allow-principals.patch patch_name: 0003-library-_adcli_krb5_build_principal-allow-principals.patch present_in_specfile: true location_in_specfile: 39 --- 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);