}
/* Return true if we believe server can support enctype as a session key. */
-krb5_boolean
+static krb5_boolean
dbentry_supports_enctype(krb5_context context, krb5_db_entry *server,
krb5_enctype enctype)
{
int nktypes, krb5_enctype *ktype)
{
int i;
+ krb5_enctype first_permitted = 0;
for (i = 0; i < nktypes; i++) {
if (!krb5_c_valid_enctype(ktype[i]))
if (!krb5_is_permitted_enctype(context, ktype[i]))
continue;
+ if (first_permitted == 0)
+ first_permitted = ktype[i];
+
if (dbentry_supports_enctype(context, server, ktype[i]))
return ktype[i];
}
+
+ /*
+ * If we didn't find a match and the server is the local TGS server, this
+ * could be a keytab-based AS request where the keytab enctypes don't
+ * overlap the TGT principal enctypes. Try to make this work by using the
+ * first permitted enctype in the request, even though we can't be certain
+ * that other KDCs in the realm support it.
+ */
+ if (krb5_principal_compare(context, server->princ, tgs_server))
+ return first_permitted;
+
return 0;
}
#!/usr/bin/python
from k5test import *
-realm = K5Realm()
+for realm in multipass_realms(create_user=False):
+ # Test kinit with a keytab.
+ realm.kinit(realm.host_princ, flags=['-k'])
-# Test kinit with a keytab.
-realm.kinit(realm.host_princ, flags=['-k'])
+realm = K5Realm(get_creds=False)
# Test kinit with a partial keytab.
pkeytab = realm.keytab + '.partial'