Page MenuHomeFreeBSD

pam_ksu: Fix crash when no ticket is present
ClosedPublic

Authored by ivy on Aug 8 2025, 4:17 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Nov 28, 2:36 PM
Unknown Object (File)
Tue, Nov 25, 6:08 AM
Unknown Object (File)
Tue, Nov 25, 4:01 AM
Unknown Object (File)
Sat, Nov 22, 11:50 AM
Unknown Object (File)
Tue, Nov 18, 12:27 AM
Unknown Object (File)
Thu, Nov 6, 4:05 AM
Unknown Object (File)
Nov 3 2025, 9:54 PM
Unknown Object (File)
Oct 14 2025, 5:00 AM
Subscribers

Details

Summary

When building with MIT Kerberos, pam_ksu crashes if the user doesn't
have a ticket because default_principal is never populated in
get_su_principal().

Change the compatibility function to use krb5_build_principal_alloc_va
instead, and make its interface compatible with the equivalent Heimdal
function.

Despite what the comment says, we do free the default principal later
in get_su_principal() so this shouldn't cause any leaks.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

ivy requested review of this revision.Aug 8 2025, 4:17 PM
This revision is now accepted and ready to land.Aug 8 2025, 4:19 PM

remove unneeded prototype for krb5_build_principal_va

This revision now requires review to proceed.Aug 8 2025, 4:19 PM

Note that we still have Heimdal and the option to use it, and I don't see a krb5_free_principal() call anywhere in your patch...

In D51829#1184019, @des wrote:

Note that we still have Heimdal and the option to use it, and I don't see a krb5_free_principal() call anywhere in your patch...

line 270 is:

	krb5_free_principal(context, default_principal);

i am not an expert on the krb5 API but this seems to do what we want.

ah so the comment is bogus...

I don't know if this works with Heimdal, but I have verified that it builds, so I think we're good to go.

This revision is now accepted and ready to land.Aug 8 2025, 9:31 PM

I tested this in the FreeBSD.org cluster and it works. Many thanks!

This revision was automatically updated to reflect the committed changes.