krb5 commit [krb5-1.16]: Don't rely on default realm in S4U2Self client

Greg Hudson <[email protected]>
Newsgroups gmane.comp.encryption.kerberos.cvs
Message-ID <[email protected]>
https://github.com/krb5/krb5/commit/9a93a22e69f800ef81e8fd0b0220adbfb39dbef4
commit 9a93a22e69f800ef81e8fd0b0220adbfb39dbef4
Author: Isaac Boukris <[email protected]>
Date:   Sat Sep 15 10:28:48 2018 +0300

    Don't rely on default realm in S4U2Self client
    
    When converting server principal to enterprise name (to be possibly
    used for cross-realm), ignore the realm when reparsing, to avoid a
    spurious error if a default realm isn't configured.
    
    [[email protected]: added rewritten test case; edited commit message]
    
    (cherry picked from commit 13967567ca65a306c2d5fcb4a4aff71fb422cd80)
    
    ticket: 8741
    version_fixed: 1.16.2

 src/lib/krb5/krb/s4u_creds.c |    4 +++-
 src/tests/gssapi/t_s4u.py    |    5 ++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/lib/krb5/krb/s4u_creds.c b/src/lib/krb5/krb/s4u_creds.c
index ed05b67..91c02aa 100644
--- a/src/lib/krb5/krb/s4u_creds.c
+++ b/src/lib/krb5/krb/s4u_creds.c
@@ -452,7 +452,9 @@ convert_to_enterprise(krb5_context context, krb5_principal princ,
     code = krb5_unparse_name(context, princ, &str);
     if (code != 0)
         return code;
-    code = krb5_parse_name_flags(context, str, KRB5_PRINCIPAL_PARSE_ENTERPRISE,
+    code = krb5_parse_name_flags(context, str,
+                                 KRB5_PRINCIPAL_PARSE_ENTERPRISE |
+                                 KRB5_PRINCIPAL_PARSE_IGNORE_REALM,
                                  eprinc_out);
     krb5_free_unparsed_name(context, str);
     return code;
diff --git a/src/tests/gssapi/t_s4u.py b/src/tests/gssapi/t_s4u.py
index e4cd684..3da6544 100755
--- a/src/tests/gssapi/t_s4u.py
+++ b/src/tests/gssapi/t_s4u.py
@@ -142,9 +142,12 @@ realm.stop()
 
 # Exercise cross-realm S4U2Self.  The query in the foreign realm will
 # fail, but we can check that the right server principal was used.
+# Include a regression test for #8741 by unsetting the default realm.
 r1, r2 = cross_realms(2, create_user=False)
 r1.run([kinit, '-k', r1.host_princ])
-r1.run(['./t_s4u', 'p:' + r2.host_princ], expected_code=1,
+remove_default = {'libdefaults': {'default_realm': None}}
+no_default = r1.special_env('no_default', False, krb5_conf=remove_default)
+r1.run(['./t_s4u', 'p:' + r2.host_princ], env=no_default, expected_code=1,
        expected_msg='Server not found in Kerberos database')
 r1.stop()
 r2.stop()
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.