Change default principal for krb5_set_password
Russ Allbery <[email protected]>
| Newsgroups | gmane.comp.encryption.kerberos.heimdal.general |
|---|---|
| Organization | The Eyrie |
| Message-ID | <[email protected]> |
For background, I'm trying to write a Kerberos PAM module with as little code difference between Kerberos implementations as possible (since, among other things, this makes it much easier to test). I was previously always using krb5_set_password to do password change, passing the client principal in. But with MIT Kerberos, passing in a client principal causes it to use the new set password protocol rather than the old change password protocol, which is not compatible with old KDCs. The recommendation on the MIT side is to pass in NULL for the principal, which causes it to fall back to the change password protocol. But if one passes NULL to the current Heimdal krb5_set_password function, it uses krb5_get_default_principal to figure out the client principal. This is frequently going to be wrong in a PAM context. krb5_set_password requires credentials for the password change service be passed in, and those credentials are already associated with a client principal. I think this is a much better choice of default client principal than krb5_get_default_principal. The attached patch implements that change, although I've not tested it. (I haven't checked whether one could take the easier route of not copying and freeing the principal and instead just referencing the principal inside the credential structure.) -- Russ Allbery ([email protected]) <http://www.eyrie.org/~eagle/>
0002-Set-default-principal-for-password-change-to-credent.patch
(text/x-diff, 1.1 KB)
From 22f00a87b45e25d6103ad798f574ade417a75d07 Mon Sep 17 00:00:00 2001 From: Russ Allbery <[email protected]> Date: Thu, 22 Dec 2011 11:18:33 -0800 Subject: [PATCH 2/2] Set default principal for password change to credential client The default client principal for krb5_set_password, if the principal argument were NULL, was krb5_get_default_principal. But krb5_set_password requires credentials for the password change service be passed in, and those credentials are already associated with a client principal that's much more likely to be the correct choice for a default. Use that principal instead of krb5_get_default_principal. --- lib/krb5/changepw.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/lib/krb5/changepw.c b/lib/krb5/changepw.c index 1e7cd0d..dee4e1c 100644 --- a/lib/krb5/changepw.c +++ b/lib/krb5/changepw.c @@ -744,7 +744,7 @@ krb5_set_password(krb5_context context, krb5_data_zero(result_string); if (targprinc == NULL) { - ret = krb5_get_default_principal(context, &principal); + ret = krb5_copy_principal(context, creds->client, &principal); if (ret) return ret; } else -- 1.7.7.3