]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Allow kinit with keytab to defer canonicalization
authorRobbie Harwood <rharwood@redhat.com>
Thu, 3 Jun 2021 20:03:07 +0000 (16:03 -0400)
committerGreg Hudson <ghudson@mit.edu>
Wed, 9 Jun 2021 00:53:09 +0000 (20:53 -0400)
[ghudson@mit.edu: added tests]

ticket: 9012 (new)

src/clients/kinit/kinit.c
src/tests/t_keytab.py

index d54bb05344dea741d0d16d1d12dbb71071dda303..79775c2c476bd3cc1210b4b0b14ae7ffbfcda1fa 100644 (file)
@@ -505,17 +505,6 @@ k5_begin(struct k_opts *opts, struct k5_data *k5)
                     _("when creating default server principal name"));
             goto cleanup;
         }
-        if (k5->me->realm.data[0] == 0) {
-            ret = krb5_unparse_name(k5->ctx, k5->me, &k5->name);
-            if (ret == 0) {
-                com_err(progname, KRB5_ERR_HOST_REALM_UNKNOWN,
-                        _("(principal %s)"), k5->name);
-            } else {
-                com_err(progname, KRB5_ERR_HOST_REALM_UNKNOWN,
-                        _("for local services"));
-            }
-            goto cleanup;
-        }
     } else if (k5->out_cc != NULL) {
         /* If the output ccache is initialized, use its principal. */
         if (krb5_cc_get_principal(k5->ctx, k5->out_cc, &princ) == 0)
index 850375c921ee3bbc2cade9d560371705ef5da7d4..a9adebb26e0ee287bad0be7780908b9bf5d0d4d7 100755 (executable)
@@ -41,6 +41,19 @@ realm.kinit(realm.user_princ, flags=['-i'],
             expected_msg='keytab specified, forcing -k')
 realm.klist(realm.user_princ)
 
+# Test default principal for -k.  This operation requires
+# canonicalization against the keytab in krb5_get_init_creds_keytab()
+# as the krb5_sname_to_principal() result won't have a realm.  Try
+# with and without without fallback processing since the code paths
+# are different.
+mark('default principal for -k')
+realm.run([kinit, '-k'])
+realm.klist(realm.host_princ)
+no_canon_conf = {'libdefaults': {'dns_canonicalize_hostname': 'false'}}
+no_canon = realm.special_env('no_canon', False, krb5_conf=no_canon_conf)
+realm.run([kinit, '-k'], env=no_canon)
+realm.klist(realm.host_princ)
+
 # Test extracting keys with multiple key versions present.
 mark('multi-kvno extract')
 os.remove(realm.keytab)